summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Gilligan <gilligan@vyatta.com>2009-12-23 10:55:03 -0800
committerBob Gilligan <gilligan@vyatta.com>2009-12-23 10:55:03 -0800
commit3113c2416432467c06af67390bb7acbb774d1e8f (patch)
treef84fd4a4822882201f1e7a8ac050bc22788e6ca1
parentb3ab6606703822c2f0bed7d5194329ada76ed082 (diff)
downloadvyatta-op-3113c2416432467c06af67390bb7acbb774d1e8f.tar.gz
vyatta-op-3113c2416432467c06af67390bb7acbb774d1e8f.zip
Allow displaying and switching to disk-based installations.
-rwxr-xr-xscripts/vyatta-boot-image.pl23
1 files changed, 18 insertions, 5 deletions
diff --git a/scripts/vyatta-boot-image.pl b/scripts/vyatta-boot-image.pl
index 7a4a85d..3c35847 100755
--- a/scripts/vyatta-boot-image.pl
+++ b/scripts/vyatta-boot-image.pl
@@ -9,12 +9,14 @@ my $UNION_BOOT = '/live/image/boot';
my $UNION_GRUB_CFG = "$UNION_BOOT/grub/grub.cfg";
my $VER_FILE = '/opt/vyatta/etc/version';
my $OLD_IMG_VER_STR = 'Old non-image installation';
+my $OLD_GRUB_CFG = '/boot/grub/grub.cfg';
+my $grub_cfg;
# this function parses the grub config file and returns a hash reference
# of the parsed data.
sub parseGrubCfg {
my $fd = undef;
- return undef if (!open($fd, '<', $UNION_GRUB_CFG));
+ return undef if (!open($fd, '<', $grub_cfg));
my %ghash = ();
my @entries = ();
@@ -69,7 +71,7 @@ sub deleteGrubEntries {
my ($del_ver) = @_;
my $rfd = undef;
- return 'Cannot delete GRUB entries' if (!open($rfd, '<', $UNION_GRUB_CFG));
+ return 'Cannot delete GRUB entries' if (!open($rfd, '<', $grub_cfg));
my ($wfd, $tfile) = mkstemp('/tmp/boot-image.XXXXXX');
my @entry = ();
@@ -106,10 +108,10 @@ sub deleteGrubEntries {
close($wfd);
close($rfd);
- my $p = (stat($UNION_GRUB_CFG))[2];
+ my $p = (stat($grub_cfg))[2];
return 'Failed to modify GRUB configuration'
if (!defined($p) || !chmod(($p & 07777), $tfile));
- system("mv $tfile $UNION_GRUB_CFG");
+ system("mv $tfile $grub_cfg");
return 'Failed to delete GRUB entries' if ($? >> 8);
return undef;
}
@@ -158,6 +160,17 @@ GetOptions(
'select' => \$sel
);
+
+if (-e $UNION_GRUB_CFG) {
+ $grub_cfg = $UNION_GRUB_CFG;
+} elsif (-e $OLD_GRUB_CFG) {
+ $grub_cfg = $OLD_GRUB_CFG;
+} else {
+ print "Can not open Grub config file\n";
+ exit 1;
+}
+
+
my $gref = parseGrubCfg();
if (!defined($gref)) {
print "Cannot find GRUB configuration file. Exiting...\n";
@@ -226,7 +239,7 @@ sub doSelect {
my ($bdx) = @_;
my $new_idx = ${$bentries}[$resp]->{'idx'};
my $new_ver = ${$bentries}[$resp]->{'ver'};
- system("sed -i 's/^set default=.*\$/set default=$new_idx/' $UNION_GRUB_CFG");
+ system("sed -i 's/^set default=.*\$/set default=$new_idx/' $grub_cfg");
if ($? >> 8) {
print "Failed to set the default boot image. Exiting...\n";
exit 1;