aboutsummaryrefslogtreecommitdiff
path: root/share/hydractl/system-upgrade
diff options
context:
space:
mode:
Diffstat (limited to 'share/hydractl/system-upgrade')
-rwxr-xr-xshare/hydractl/system-upgrade87
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