lsinird: Adding option "-m|--mod" to list dracut modules in the image
This patch adds option "-m|--mod" to lsinitrd to list dracut modules in the image because sometimes having an option to only list the dracut modules in the image could be handy. Sample output: -------------- [hbathini@localhost dracut]$ sudo ./lsinitrd.sh initramfs-3.11.10-100.fc18.x86_64.img -m Image: initramfs-3.11.10-100.fc18.x86_64.img: 33M ======================================================================== Version: dracut-029-1.fc18.2 dracut modules: i18n network ifcfg drm plymouth btrfs crypt dm dmraid kernel-modules lvm mdraid cifs iscsi nfs resume rootfs-block terminfo udev-rules biosdevname systemd usrmount base fs-lib shutdown ======================================================================== Signed-off-by: Hari Bathini <hbathini@linux.vnet.ibm.com>master
parent
773d6a7ded
commit
05d2a14526
22
lsinitrd.sh
22
lsinitrd.sh
|
@ -27,6 +27,7 @@ usage()
|
||||||
echo
|
echo
|
||||||
echo "-h, --help print a help message and exit."
|
echo "-h, --help print a help message and exit."
|
||||||
echo "-s, --size sort the contents of the initramfs by size."
|
echo "-s, --size sort the contents of the initramfs by size."
|
||||||
|
echo "-m, --mod list modules."
|
||||||
echo "-f, --file <filename> print the contents of <filename>."
|
echo "-f, --file <filename> print the contents of <filename>."
|
||||||
echo "-k, --kver <kernel version> inspect the initramfs of <kernel version>."
|
echo "-k, --kver <kernel version> inspect the initramfs of <kernel version>."
|
||||||
echo
|
echo
|
||||||
|
@ -37,13 +38,15 @@ usage()
|
||||||
[[ $dracutbasedir ]] || dracutbasedir=/usr/lib/dracut
|
[[ $dracutbasedir ]] || dracutbasedir=/usr/lib/dracut
|
||||||
|
|
||||||
sorted=0
|
sorted=0
|
||||||
|
modules=0
|
||||||
declare -A filenames
|
declare -A filenames
|
||||||
|
|
||||||
unset POSIXLY_CORRECT
|
unset POSIXLY_CORRECT
|
||||||
TEMP=$(getopt \
|
TEMP=$(getopt \
|
||||||
-o "shf:k:" \
|
-o "shmf:k:" \
|
||||||
--long kver: \
|
--long kver: \
|
||||||
--long file: \
|
--long file: \
|
||||||
|
--long mod \
|
||||||
--long help \
|
--long help \
|
||||||
--long size \
|
--long size \
|
||||||
-- "$@")
|
-- "$@")
|
||||||
|
@ -61,6 +64,7 @@ while (($# > 0)); do
|
||||||
-f|--file) filenames[${2#/}]=1; shift;;
|
-f|--file) filenames[${2#/}]=1; shift;;
|
||||||
-s|--size) sorted=1;;
|
-s|--size) sorted=1;;
|
||||||
-h|--help) usage; exit 0;;
|
-h|--help) usage; exit 0;;
|
||||||
|
-m|--mod) modules=1;;
|
||||||
--) shift;break;;
|
--) shift;break;;
|
||||||
*) usage; exit 1;;
|
*) usage; exit 1;;
|
||||||
esac
|
esac
|
||||||
|
@ -119,6 +123,13 @@ extract_files()
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
list_modules()
|
||||||
|
{
|
||||||
|
echo "dracut modules:"
|
||||||
|
$CAT "$image" | cpio --extract --verbose --quiet --to-stdout -- 'lib/dracut/modules.txt' 'usr/lib/dracut/modules.txt' 2>/dev/null
|
||||||
|
((ret+=$?))
|
||||||
|
}
|
||||||
|
|
||||||
list_files()
|
list_files()
|
||||||
{
|
{
|
||||||
echo "========================================================================"
|
echo "========================================================================"
|
||||||
|
@ -212,13 +223,16 @@ else
|
||||||
((ret+=$?))
|
((ret+=$?))
|
||||||
echo "Version: $version"
|
echo "Version: $version"
|
||||||
echo
|
echo
|
||||||
|
if [ "$modules" -eq 1 ]; then
|
||||||
|
list_modules
|
||||||
|
echo "========================================================================"
|
||||||
|
else
|
||||||
echo -n "Arguments: "
|
echo -n "Arguments: "
|
||||||
$CAT "$image" | cpio --extract --verbose --quiet --to-stdout -- 'lib/dracut/build-parameter.txt' 'usr/lib/dracut/build-parameter.txt' 2>/dev/null
|
$CAT "$image" | cpio --extract --verbose --quiet --to-stdout -- 'lib/dracut/build-parameter.txt' 'usr/lib/dracut/build-parameter.txt' 2>/dev/null
|
||||||
echo
|
echo
|
||||||
echo "dracut modules:"
|
list_modules
|
||||||
$CAT "$image" | cpio --extract --verbose --quiet --to-stdout -- 'lib/dracut/modules.txt' 'usr/lib/dracut/modules.txt' 2>/dev/null
|
|
||||||
((ret+=$?))
|
|
||||||
list_files
|
list_files
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
exit $ret
|
exit $ret
|
||||||
|
|
Loading…
Reference in New Issue