diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2013-12-23 14:09:19 -0200 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2013-12-23 14:09:19 -0200 |
commit | fcd9688ed5af9c621779d33bb3e604ffab0b4aec (patch) | |
tree | 153a908b17e20817c21f4a8900a4f4c13001795c /share | |
parent | 928d388568308691e2a714cdcfee15335de94346 (diff) | |
download | hydra-fcd9688ed5af9c621779d33bb3e604ffab0b4aec.tar.gz hydra-fcd9688ed5af9c621779d33bb3e604ffab0b4aec.tar.bz2 |
Split code into functions at system-upgrade
Diffstat (limited to 'share')
-rwxr-xr-x | share/hydractl/system-upgrade | 87 |
1 files changed, 47 insertions, 40 deletions
diff --git a/share/hydractl/system-upgrade b/share/hydractl/system-upgrade index 7942813..815217e 100755 --- a/share/hydractl/system-upgrade +++ b/share/hydractl/system-upgrade @@ -24,53 +24,61 @@ hydra_config_load BASENAME="`basename $0`" NEXTRELEASE="$1" -# Available releases -#release="`facter lsbdistcodename`" # this doesn't work on squeeze -release="`facter 2> /dev/null | grep lsbdistcodename | sed -e 's/lsbdistcodename => //'`" -nextrelease="`hydra_next_debian_release $release`" - -# Check release -if [ "$?" != "0" ]; then - echo "Unsupported release" - exit 1 -fi - -# Check optional parameter -if [ ! -z "$NEXTRELEASE" ]; then - if [ "$NEXTRELEASE" == "$release" ]; then - echo "System is already upgraded to $NEXTRELEASE" +# Prepare the environment for a system upgrade +function hydra_system_upgrade_prepare { + # Available releases + #release="`facter lsbdistcodename`" # this doesn't work on squeeze + release="`facter 2> /dev/null | grep lsbdistcodename | sed -e 's/lsbdistcodename => //'`" + nextrelease="`hydra_next_debian_release $release`" + + # Check release + if [ "$?" != "0" ]; then + echo "Unsupported release" exit 1 fi - if [ "$NEXTRELEASE" != "$nextrelease" ]; then - echo "Cannot upgrade: next release for this system is $nextrelease" - exit 1 + # Check optional parameter + if [ ! -z "$NEXTRELEASE" ]; then + if [ "$NEXTRELEASE" == "$release" ]; then + echo "System is already upgraded to $NEXTRELEASE" + exit 1 + fi + + if [ "$NEXTRELEASE" != "$nextrelease" ]; then + echo "Cannot upgrade: next release for this system is $nextrelease" + exit 1 + fi fi -fi -# Ensure puppet is stopped during the process -echo "Disabling puppet during the upgrade..." -service puppet stop -sed -i -e 's/START=yes/START=no/' /etc/default/puppet + # Ensure puppet is stopped during the process + echo "Disabling puppet during the upgrade..." + hydractl puppet-disable -# Configure apt for the next debian release -echo "" -echo "Updating apt configuration..." -sed -i -e "s/$release/$nextrelease/g" /etc/apt/sources.list -sed -i -e "s/$release/$nextrelease/g" /etc/apt/preferences -sed -i -e 's|^deb http://backports.debian.org/debian-backports|#deb http://backports.debian.org/debian-backports|' /etc/apt/sources.list + # Configure apt for the next debian release + echo "" + echo "Updating apt configuration..." + sed -i -e "s/$release/$nextrelease/g" /etc/apt/sources.list + sed -i -e "s/$release/$nextrelease/g" /etc/apt/preferences + sed -i -e 's|^deb http://backports.debian.org/debian-backports|#deb http://backports.debian.org/debian-backports|' /etc/apt/sources.list -# These will be generated by puppet and can be safely removed -rm -f /etc/apt/sources.list.d/* -rm -f /etc/apt/preferences.d/* + # These will be generated by puppet and can be safely removed + rm -f /etc/apt/sources.list.d/* + rm -f /etc/apt/preferences.d/* +} # Update package listing and download new packages -echo "" -echo "Updating package listing..." -apt-get update -echo "" -echo "Downloading packages..." -apt-get dist-upgrade -d -y +function hydra_system_upgrade_download { + echo "" + echo "Updating package listing..." + apt-get update + echo "" + echo "Downloading packages..." + apt-get dist-upgrade -d -y +} + +# Prepare for the upgrade +hydra_system_upgrade_prepare $* +hydra_system_upgrade_download # Upgrade the system echo "" @@ -102,5 +110,4 @@ fi # Enable puppet again echo "" echo "Starting puppet again..." -sed -i -e 's/START=no/START=yes/' /etc/default/puppet -service puppet start +hydractl puppet-enable |