summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohit Mehta <mohit.mehta@vyatta.com>2010-02-12 11:19:57 -0800
committerMohit Mehta <mohit.mehta@vyatta.com>2010-02-12 11:19:57 -0800
commitd17941a5b7ff128ce895ce166f4d14724773ec01 (patch)
tree5b4dc9cebb7a07d728f08768f8f7de7ff1de58d6
parent2c73a40d7c0bbccc2b60592d4df922f3222b40d3 (diff)
parent883c529765562ce2bb1e3ae61627f8e1b0a7595e (diff)
downloadvyatta-cfg-system-d17941a5b7ff128ce895ce166f4d14724773ec01.tar.gz
vyatta-cfg-system-d17941a5b7ff128ce895ce166f4d14724773ec01.zip
Merge branch 'kenwood' of mohit@git.vyatta.com:/git/vyatta-cfg-system into kenwood
-rw-r--r--debian/changelog7
-rwxr-xr-xscripts/install-system106
2 files changed, 113 insertions, 0 deletions
diff --git a/debian/changelog b/debian/changelog
index c21669d3..ae1b7395 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+vyatta-cfg-system (0.16.42) unstable; urgency=low
+
+ * Bugfix 5117: Preserve config files from previous image
+ installation.
+
+ -- Bob Gilligan <gilligan@vyatta.com> Thu, 11 Feb 2010 16:06:16 -0800
+
vyatta-cfg-system (0.16.41) unstable; urgency=low
* Fix bug 5325 vyatta-cfg-system fails to upgrade during full-upgrade
diff --git a/scripts/install-system b/scripts/install-system
index bc2277fd..68584445 100755
--- a/scripts/install-system
+++ b/scripts/install-system
@@ -656,11 +656,65 @@ save_old_keys() {
fi
}
+save_image_config() {
+ image_name=$1
+
+ # Cleanup from possible partial last run
+ rm -fr /mnt/config
+ mkdir /mnt/config
+
+ output=$(cp -pR /mnt/tmp/boot/$image_name/live-rw/config/* /mnt/config)
+
+ if [ -n "$output" ]; then
+ echo -e "Warning: error in copying the old config partition.\nSee $INSTALL_LOG for more details."
+ lecho "Warning: error in copying the old config partition.\ncp -pR /mnt/tmp/* /mnt/config\n$output\n"
+ fi
+ rename_old_config
+}
+
+save_image_keys() {
+ image_name=$1
+
+ if [ ! -d /mnt/tmp/boot/$image_name/live-rw/etc/ssh ]; then
+ echo "No SSH keys found on $image_name, so none can be saved."
+ return;
+ fi
+
+ echo -n "Would you like to save SSH keys from $image_name too? (Yes/No) [Yes] "
+
+ response=$(get_response "Yes" "Yes No Y N")
+ if [ "$response" != "yes" ] && [ "$response" != "y" ]; then
+ echo "OK. SSH keys not saved."
+ return
+ fi
+
+ mkdir -p /mnt/ssh
+ output=$(cp -p /mnt/tmp/boot/$image_name/live-rw/etc/ssh/ssh_host_* /mnt/ssh)
+
+ if [ -n "$output" ]; then
+ echo -e "Warning: error in copying the old ssh keys."
+ echo -e "See $INSTALL_LOG for more details."
+ echo "Warning: error in copying the old ssh keys." >> $INSTALL_LOG
+ echo "cp -pR /mnt/tmp/etc/ssh/ssh_host_* /mnt/ssh" >> $INSTALL_LOG
+ echo "$output\n">> $INSTALL_LOG
+ return
+ fi
+
+ # reset modes on keys (should already be set)
+ chmod 600 /mnt/ssh/*_key 2>&1
+ chmod 644 /mnt/ssh/*.pub 2>&1
+
+ echo "SSH keys have been saved."
+}
+
+
+
## check_config_partition
# look to see if this partition contains a config file
# and back it up
check_config_partition() {
lpart=$1
+ copied=0
# Cleanup from possible partial last run
rm -fr /mnt/config
@@ -678,13 +732,65 @@ check_config_partition() {
if [ -f /mnt/tmp/opt/vyatta/etc/config/.vyatta_config ] ||
[ -f /mnt/tmp/.vyatta_config ]; then
save_old_config
+ copied=1
fi
# Look to see if there are SSH host keys
if [ -d /mnt/tmp/etc/ssh ]; then
save_old_keys
+ copied=1
fi
+ if [ $copied -eq 0 ]; then
+ # Check for images
+ images=()
+ image_dirs=/mnt/tmp/boot/*
+
+ for dir in $image_dirs; do
+ if [ -f $dir/live-rw/config/.vyatta_config ]; then
+ item=${dir##/mnt/tmp/boot/}
+ images=($item ${images[@]})
+ fi
+ done
+
+ num_images=${#images[@]}
+
+ if [ $num_images -gt 0 ]; then
+ echo "I found the following installed system image(s) with config files on $part:"
+ for (( i = 0; i < $num_images; i++ )); do
+ echo " $((i + 1)): ${images[$i]}"
+ done
+
+ if [ $num_images -eq 1 ]; then
+ echo -n "Would you like to save config information from it? (Yes/No) [Yes] "
+ else
+ echo -n "Would you like to save config information from one? (Yes/No) [Yes] "
+ fi
+
+ response=$(get_response "Yes" "Yes No Y N")
+ if [ "$response" != "yes" ] && [ "$response" != "y" ]; then
+ echo "OK. Config information not saved."
+ return
+ fi
+
+ if [ $num_images -gt 1 ]; then
+ image_index=-1
+ while [ $image_index -lt 0 -o $image_index -ge $num_images ]; do
+ echo -n "Which image would you like to use? (1 .. $num_images): "
+ read num
+ image_index=$((num - 1))
+ done
+ else
+ image_index=0
+ fi
+
+ image_name=${images[$image_index]}
+ echo "Saving config information from image $image_name."
+ save_image_config $image_name
+ echo "Done."
+ save_image_keys $image_name
+ fi
+ fi
umount /mnt/tmp
}