diff options
author | Bob Gilligan <gilligan@vyatta.com> | 2011-10-19 17:14:00 -0700 |
---|---|---|
committer | Bob Gilligan <gilligan@vyatta.com> | 2011-10-19 17:14:00 -0700 |
commit | 75b64105fafd33c96a53e37222af8b4d4ed9d393 (patch) | |
tree | e73f9dd064025c8dfa30a83d71a4ffce5518cc3a /scripts | |
parent | 47ccd29aae50f7d1f326b9a452709aeb641356c3 (diff) | |
download | vyatta-op-75b64105fafd33c96a53e37222af8b4d4ed9d393.tar.gz vyatta-op-75b64105fafd33c96a53e37222af8b4d4ed9d393.zip |
Bugfix 7502: Make "rename system image" work correctly on Xen.
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/rename-image.pl | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/scripts/rename-image.pl b/scripts/rename-image.pl index 837a3ad..fcdf624 100644 --- a/scripts/rename-image.pl +++ b/scripts/rename-image.pl @@ -25,6 +25,9 @@ use warnings; use Getopt::Long; use File::Temp qw/ tempfile tempdir /; +my $UNION_BOOT = '/live/image/boot'; +my $XEN_DEFAULT_IMAGE = "$UNION_BOOT/%%default_image"; + my $old_name; my $new_name; @@ -55,7 +58,8 @@ if (("$new_name" eq "Old-non-image-installation") || ("$new_name" =~ /^initrd/) || ("$new_name" =~ /^vmlinuz/) || ("$new_name" =~ /^System\.map/) || - ("$new_name" =~ /^config-/)) { + ("$new_name" =~ /^config-/) || + ("$new_name" =~ /^%%/)) { printf("Can't use reserved image name.\n"); exit 1; } @@ -63,8 +67,13 @@ if (("$new_name" eq "Old-non-image-installation") || my $cmdline=`cat /proc/cmdline`; my $cur_name; ($cur_name, undef) = split(' ', $cmdline); -$cur_name =~ s/BOOT_IMAGE=\/boot\///; -$cur_name =~ s/\/vmlinuz.*//; +if ($cur_name =~ s/BOOT_IMAGE=\/boot\///) { + $cur_name =~ s/\/vmlinuz.*//; +} else { + if (-l $XEN_DEFAULT_IMAGE) { + $cur_name = readlink($XEN_DEFAULT_IMAGE); + } +} if ($old_name eq $cur_name) { printf("Can't re-name the running image.\n"); @@ -105,6 +114,7 @@ close(GRUBFH); system("mv $image_path/$old_name $image_path/$new_name"); system("cp $tmpfilename $image_path/grub/grub.cfg"); + system("logger -p local3.warning -t 'SystemImage' 'System image $old_name has been renamed $new_name'"); printf("Done.\n"); |