diff options
-rwxr-xr-x | scripts/vyatta-boot-image.pl | 26 | ||||
-rw-r--r-- | templates/delete/system/image/node.tag/node.def | 2 |
2 files changed, 13 insertions, 15 deletions
diff --git a/scripts/vyatta-boot-image.pl b/scripts/vyatta-boot-image.pl index c3040b4..127177d 100755 --- a/scripts/vyatta-boot-image.pl +++ b/scripts/vyatta-boot-image.pl @@ -286,21 +286,19 @@ sub select_by_name { # Returns the version string of the currently running system. # sub curVer { - my ($fd, $ver) = (undef, undef); - - my $image_boot = `grep -e '^unionfs / unionfs.*squashfs=ro' /proc/mounts`; - if ($image_boot ne "") { - open($fd, '<', $VER_FILE) or return undef; - while (<$fd>) { - next if (!(/^Version\s+:\s+(\S+)$/)); - $ver = $1; - last; - } - close($fd); - } else { - $ver = $OLD_IMG_VER_STR; + my $vers = `awk '{print \$1}' /proc/cmdline`; + + # In an image-booted system, the image name is the directory name + # directory under "/boot" in the pathname of the kernel we booted. + $vers =~ s/BOOT_IMAGE=\/boot\///; + $vers =~ s/\/?vmlinuz.*\n$//; + + # In a non-image system, the kernel resides directly under "/boot". + # No second-level directory means that $vers will be null. + if ($vers eq "") { + $vers = $OLD_IMG_VER_STR; } - return $ver; + return $vers; } # Deletes all of the files belonging to the disk-based non-image diff --git a/templates/delete/system/image/node.tag/node.def b/templates/delete/system/image/node.tag/node.def index 2c26bf4..403bd80 100644 --- a/templates/delete/system/image/node.tag/node.def +++ b/templates/delete/system/image/node.tag/node.def @@ -1,4 +1,4 @@ -help: Default boot image name +help: Name of image image to delete allowed: local -a images ; |