From c44072f905c884eeee2d5abecb0b7728fcc538be Mon Sep 17 00:00:00 2001 From: Bob Gilligan Date: Wed, 19 Oct 2011 17:54:23 -0700 Subject: Bugfix 7502: Get "set system image default-boot" to work on Xen. --- scripts/vyatta-boot-image.pl | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/scripts/vyatta-boot-image.pl b/scripts/vyatta-boot-image.pl index 448192d..7c80da7 100755 --- a/scripts/vyatta-boot-image.pl +++ b/scripts/vyatta-boot-image.pl @@ -26,6 +26,7 @@ use strict; use warnings; use Getopt::Long; use File::Temp qw/ :mktemp /; +use File::Copy; # # Constants @@ -311,6 +312,24 @@ sub doSelect { print "Failed to set the default boot image. Exiting...\n"; exit 1; } + + if (-l $XEN_DEFAULT_IMAGE) { + my $backup_symlink = $XEN_DEFAULT_IMAGE . ".orig"; + if (!move($XEN_DEFAULT_IMAGE, $backup_symlink)) { + printf("Unable to back up Xen default image symlink: $XEN_DEFAULT_IMAGE\n"); + printf("Default boot image has not been changed.\n"); + system("logger -p local3.warning -t 'SystemImage' 'Default boot image attempt to change from $def_ver to $new_ver failed: cant back up symlink'"); + exit 1; + } + if (!symlink ($new_ver, $XEN_DEFAULT_IMAGE)) { + move($backup_symlink, $XEN_DEFAULT_IMAGE); + printf("Unable to update Xen default image symlink: $XEN_DEFAULT_IMAGE.\n"); + printf("Default boot image has not been changed.\n"); + system("logger -p local3.warning -t 'SystemImage' 'Default boot image attempt to change from $def_ver to $new_ver failed: cant update symlink'"); + exit 1; + } + } + print <