summaryrefslogtreecommitdiff
path: root/scripts/install
diff options
context:
space:
mode:
authorBob Gilligan <gilligan@vyatta.com>2010-01-25 17:10:04 -0800
committerBob Gilligan <gilligan@vyatta.com>2010-01-25 17:10:04 -0800
commit092fea186dee158c9b6545e8d1ee69945d998e8d (patch)
tree96d9cf918c6a57c7040f1d811bfa11b579fcff3f /scripts/install
parentc7899fccec1f6fec63d342d908aad8973ea0f91c (diff)
downloadvyatta-cfg-quagga-092fea186dee158c9b6545e8d1ee69945d998e8d.tar.gz
vyatta-cfg-quagga-092fea186dee158c9b6545e8d1ee69945d998e8d.zip
Bugfix 5240: Prevent re-installation of same version on running systems
Previously, it was possible in some cases to "add" a system image that would over-write the running image. This change fixes that by getting the version string of the running system from the kernel command line instead of the Vyatta version file. This string represents the actual directory name that holds the image, so is more reliable. Also previously, an attempt to "add" a system image that had the same version string as another image installed on the system (but was not the running image) would always succeed. This would completely over-write that image. Because of this destructive behavior, it deserves a confirmation question. This change prompts the user to see if they really want to do that before proceeding.
Diffstat (limited to 'scripts/install')
-rwxr-xr-xscripts/install/install-image-existing32
1 files changed, 27 insertions, 5 deletions
diff --git a/scripts/install/install-image-existing b/scripts/install/install-image-existing
index 214fd2c8..b566c1e9 100755
--- a/scripts/install/install-image-existing
+++ b/scripts/install/install-image-existing
@@ -19,8 +19,14 @@ if [ `whoami` != 'root' ] ; then
failure_exit 'This script must be run with root privileges.'
fi
-CURVER=$(sed -n 's/^Version \+: \+\([^ ]\+\)$/\1/p' \
- ${vyatta_sysconfdir}/version 2>/dev/null)
+# On image-installed systems, the image name can be found as the
+# directory under "/boot" on the path to the running kernel on the
+# boot line. On non-image-installed systems, this yelds the
+# name of the kernel image file.
+CURVER=`awk '{print $1}' /proc/cmdline`
+CURVER=${CURVER#BOOT_IMAGE=/boot/}
+CURVER=${CURVER%/vmlinuz*}
+
if [ -z "$CURVER" ]; then
failure_exit 'Cannot find current version.'
fi
@@ -32,11 +38,11 @@ if [ -z "$NEWVER" ]; then
failure_exit 'Cannot find new release version.'
fi
if [ "$CURVER" == "$NEWVER" ]; then
- failure_exit "Cannot install the same release version \"$NEWVER\"."
+ echo "Image version $NEWVER is the same as the running system."
+ echo "Cannot install the same release version as the running system."
+ exit 1
fi
-# start the install
-echo "Installing \"$NEWVER\" release."
# this is the default if current install is union
BOOT_DIR=/live/image/boot
@@ -47,6 +53,22 @@ elif [ "$CUR_INSTALL" != 'union' ]; then
exit 1
fi
+if [ -d $BOOT_DIR/$NEWVER ]; then
+ echo "Version $NEWVER is already installed on this system."
+ echo "Proceeding with this installation will delete this copy of"
+ echo "$NEWVER and replace it with a new copy."
+ echo -n "Do you want to replace it? (Yes/No) [No]: "
+ resp=$(get_response "No" "Yes No Y N")
+ if [ "$resp" != 'yes' ] && [ "$resp" != 'y' ]; then
+ echo "OK. Will not replace $NEWVER"
+ echo "Exiting..."
+ exit 1
+ fi
+fi
+
+# start the install
+echo "Installing \"$NEWVER\" release."
+
# create the new release directories
REL_ROOT=$BOOT_DIR/$NEWVER
RW_DIR="$REL_ROOT/live-rw"