]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
dracut.sh: Add --version
authorDaniel Molkentin <dmolkentin@suse.com>
Mon, 17 Aug 2020 13:46:17 +0000 (15:46 +0200)
committerDaniel Molkentin <daniel@molkentin.de>
Fri, 28 Aug 2020 21:28:25 +0000 (23:28 +0200)
dracut.sh

index 4d83d3ab6dfe9a001618ed64ec296b72e69e3865..2f2fadd1ba2aa527583788b6ba27fe7a52f62889 100755 (executable)
--- a/dracut.sh
+++ b/dracut.sh
@@ -242,6 +242,7 @@ Creates initial ramdisk images for preloading modules
   --kernel-image [FILE] location of the kernel image
   --regenerate-all      Regenerate all initramfs images at the default location
                         for the kernel versions found on the system
+  --version             Display version
 
 If [LIST] has multiple arguments, then you have to put these in quotes.
 
@@ -252,6 +253,14 @@ For example:
 EOF
 }
 
+long_version() {
+    [[ $dracutbasedir ]] || dracutbasedir=$dracutsysrootdir/usr/lib/dracut
+    if [[ -f $dracutbasedir/dracut-version.sh ]]; then
+        . $dracutbasedir/dracut-version.sh
+    fi
+    echo "dracut $DRACUT_VERSION"
+}
+
 # Fills up host_devs stack variable and makes sure there are no duplicates
 push_host_devs() {
     local _dev
@@ -416,6 +425,7 @@ rearrange_params()
         --long no-hostonly-i18n \
         --long hostonly-i18n \
         --long no-machineid \
+        --long version \
         -- "$@")
 
     if (( $? != 0 )); then
@@ -616,6 +626,7 @@ while :; do
                        kernel_image_l="$2";            PARMS_TO_STORE+=" '$2'"; shift;;
         --no-machineid)
                        machine_id_l="no";;
+        --version)     long_version; exit 1 ;;
         --) shift; break;;
 
         *)  # should not even reach this point