aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2013-12-25 09:59:19 -0200
committerSilvio Rhatto <rhatto@riseup.net>2013-12-25 09:59:19 -0200
commite487acb65d59b3062cd11a1e738d0174ffa98fbd (patch)
tree29c0829ee13d9bf0f5f65fa038ebb682a8d912bb
parent37c02fa955615afe2dfc932402c939274879bcd8 (diff)
downloadhydra-e487acb65d59b3062cd11a1e738d0174ffa98fbd.tar.gz
hydra-e487acb65d59b3062cd11a1e738d0174ffa98fbd.tar.bz2
Always initialize environment on system-upgrade
-rwxr-xr-xshare/hydractl/system-upgrade32
1 files changed, 27 insertions, 5 deletions
diff --git a/share/hydractl/system-upgrade b/share/hydractl/system-upgrade
index fdfaceb..4f3e4ec 100755
--- a/share/hydractl/system-upgrade
+++ b/share/hydractl/system-upgrade
@@ -23,6 +23,7 @@ hydra_config_load
# Parameters
TMP="/tmp"
STATE="$TMP/system-upgrade"
+ENV="$TMP/system-upgrade-env"
# Command line arguments
BASENAME="`basename $0`"
@@ -34,10 +35,10 @@ function hydra_system_upgrade_stage {
echo $STAGE > $STATE
}
-# Prepare the environment for a system upgrade
-function hydra_system_upgrade_prepare {
+# Set and check upgrade environment
+function hydra_system_upgrade_env {
# Set initial state
- hydra_system_upgrade_stage prepare
+ hydra_system_upgrade_stage env
# Available releases
#release="`facter lsbdistcodename`" # this doesn't work on squeeze
@@ -47,6 +48,12 @@ function hydra_system_upgrade_prepare {
# Is a virtual machine?
virtual="`facter 2> /dev/null | grep virtual | sed -e 's/virtual => //'`"
+ # Save environment
+ echo "release=$release" > $ENV
+ echo "nextrelease=$nextrelease" >> $ENV
+ echo "nextrelease=$nextrelease" >> $ENV
+ echo "virtual=$virtual" >> $ENV
+
# Check release
if [ "$?" != "0" ]; then
echo "Unsupported release"
@@ -66,6 +73,12 @@ function hydra_system_upgrade_prepare {
fi
fi
+ # Set next state
+ hydra_system_upgrade_stage prepare
+}
+
+# Prepare the environment for a system upgrade
+function hydra_system_upgrade_prepare {
# Ensure puppet is stopped during the process
echo "Disabling puppet during the upgrade..."
hydractl puppet-disable
@@ -87,6 +100,7 @@ function hydra_system_upgrade_prepare {
apt-get remove colord -y
fi
+ # Set next state
hydra_system_upgrade_stage download
}
@@ -101,12 +115,19 @@ function hydra_system_upgrade_download {
hydra_system_upgrade_stage upgrade
}
-# Prepare for the upgrade
+# Initialize
if [ ! -e "$STATE" ]; then
- hydra_system_upgrade_prepare $*
+ hydra_system_upgrade_env
else
# Resume from the previous state
STAGE="`cat $STATE`"
+ source $ENV
+ hydra_system_upgrade_$STATE
+fi
+
+# Prepare
+if [ "$STAGE" == "env" ]; then
+ hydra_system_upgrade_prepare
fi
# Download packages
@@ -160,3 +181,4 @@ fi
# Teardown
rm -f $STATE
+rm -f $ENV