diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2013-12-24 19:16:45 -0200 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2013-12-24 19:16:45 -0200 |
commit | 170033013f43f6061078308aa6022bcb5a7d39fb (patch) | |
tree | 6be561d1ac61878410886dfb3dfacad933432795 /share/hydractl/system-upgrade | |
parent | 87e269cb62d1d363636a5d26a442fef040e69c05 (diff) | |
download | hydra-170033013f43f6061078308aa6022bcb5a7d39fb.tar.gz hydra-170033013f43f6061078308aa6022bcb5a7d39fb.tar.bz2 |
Implementing run stages to system-upgrade
Diffstat (limited to 'share/hydractl/system-upgrade')
-rwxr-xr-x | share/hydractl/system-upgrade | 85 |
1 files changed, 62 insertions, 23 deletions
diff --git a/share/hydractl/system-upgrade b/share/hydractl/system-upgrade index f7fc851..bd40343 100755 --- a/share/hydractl/system-upgrade +++ b/share/hydractl/system-upgrade @@ -20,12 +20,25 @@ source $APP_BASE/lib/hydra/functions || exit 1 hydra_config_load +# Parameters +TMP="/tmp" +STATE="$TMP/system-upgrade" + # Command line arguments BASENAME="`basename $0`" NEXTRELEASE="$1" +# Record current state of the upgrade +function hydra_system_upgrade_stage { + STAGE="$1" + echo $STAGE > $STATE +} + # Prepare the environment for a system upgrade function hydra_system_upgrade_prepare { + # Set initial state + hydra_system_upgrade_stage prepare + # Available releases #release="`facter lsbdistcodename`" # this doesn't work on squeeze release="`facter 2> /dev/null | grep lsbdistcodename | sed -e 's/lsbdistcodename => //'`" @@ -64,6 +77,8 @@ function hydra_system_upgrade_prepare { # These will be generated by puppet and can be safely removed rm -f /etc/apt/sources.list.d/* rm -f /etc/apt/preferences.d/* + + hydra_system_upgrade_stage download } # Update package listing and download new packages @@ -74,40 +89,64 @@ function hydra_system_upgrade_download { echo "" echo "Downloading packages..." apt-get dist-upgrade -d -y + hydra_system_upgrade_stage upgrade } # Prepare for the upgrade -hydra_system_upgrade_prepare $* -hydra_system_upgrade_download +if [ ! -e "$STATE" ]; then + hydra_system_upgrade_prepare $* +else + # Resume from the previous state + STAGE="`cat $STATE`" +fi + +# Download packages +if [ "$STAGE" == "download" ]; then + hydra_system_upgrade_download +fi # Upgrade the system -echo "" -echo "Upgrading the system..." -DEBIAN_FRONTEND=noninteractive apt-get dist-upgrade +if [ "$STAGE" == "upgrade" ]; then + echo "" + echo "Upgrading the system..." + DEBIAN_FRONTEND=noninteractive apt-get dist-upgrade -if [ "$?" != "0" ]; then - echo "Upgrade failed. Please fix it manually and run this command again." - exit 1 -fi + if [ "$?" != "0" ]; then + echo "Upgrade failed. Please fix it manually and run this command again." + exit 1 + fi -# Remove unused packages -apt-get autoremove + hydra_system_upgrade_stage cleanup +fi -# Cleanup package cache -apt-get clean +# Cleanup +if [ "$STAGE" == "cleanup" ]; then + apt-get autoremove + apt-get clean + hydra_system_upgrade_stage custom +fi # Custom procedures -if [ "$nextrelease" == "wheezy" ]; then - # Old suhosin config - rm -f /etc/php5/conf.d/suhosin.ini - - # This has to be manually installed again - if [ -f "/etc/php5/cli/conf.d/uploadprogress.ini" ]; then - pecl upgrade uploadprogress +if [ "$STAGE" == "custom" ]; then + if [ "$nextrelease" == "wheezy" ]; then + # Old suhosin config + rm -f /etc/php5/conf.d/suhosin.ini + + # This has to be manually installed again + if [ -f "/etc/php5/cli/conf.d/uploadprogress.ini" ]; then + pecl upgrade uploadprogress + fi fi + + hydra_system_upgrade_stage puppet fi # Enable puppet again -echo "" -echo "Starting puppet again..." -hydractl puppet-enable +if [ "$STAGE" == "puppet" ]; then + echo "" + echo "Starting puppet again..." + hydractl puppet-enable +fi + +# Teardown +rm -f $STATE |