|
Harald Hoyer |
2d3fda |
From ffa71b4afa3e8865ab4f068f908ff8e05744a6ee Mon Sep 17 00:00:00 2001
|
|
Harald Hoyer |
2d3fda |
From: Harald Hoyer <harald@redhat.com>
|
|
Harald Hoyer |
2d3fda |
Date: Tue, 3 Jul 2012 14:20:51 +0200
|
|
Harald Hoyer |
2d3fda |
Subject: [PATCH] dracut.sh: use getopt to parse arguments
|
|
Harald Hoyer |
2d3fda |
|
|
Harald Hoyer |
2d3fda |
now we can put options and arguments anywhere we like.
|
|
Harald Hoyer |
2d3fda |
|
|
Harald Hoyer |
2d3fda |
e.g.
|
|
Harald Hoyer |
2d3fda |
$ dracut test.img --force
|
|
Harald Hoyer |
2d3fda |
---
|
|
Harald Hoyer |
2d3fda |
dracut.sh | 233 ++++++++++++++++++++++++++++++++++++++++++++-----------------
|
|
Harald Hoyer |
2d3fda |
1 file changed, 169 insertions(+), 64 deletions(-)
|
|
Harald Hoyer |
2d3fda |
|
|
Harald Hoyer |
2d3fda |
diff --git a/dracut.sh b/dracut.sh
|
|
Harald Hoyer |
2d3fda |
index 4a6d5c7..c1be619 100755
|
|
Harald Hoyer |
2d3fda |
--- a/dracut.sh
|
|
Harald Hoyer |
2d3fda |
+++ b/dracut.sh
|
|
Harald Hoyer |
2d3fda |
@@ -24,7 +24,7 @@
|
|
Harald Hoyer |
2d3fda |
#
|
|
Harald Hoyer |
2d3fda |
|
|
Harald Hoyer |
2d3fda |
# store for logging
|
|
Harald Hoyer |
2d3fda |
-dracut_args="$@"
|
|
Harald Hoyer |
2d3fda |
+dracut_args=( "$@" )
|
|
Harald Hoyer |
2d3fda |
|
|
Harald Hoyer |
2d3fda |
set -o pipefail
|
|
Harald Hoyer |
2d3fda |
|
|
Harald Hoyer |
2d3fda |
@@ -36,7 +36,32 @@ usage() {
|
|
Harald Hoyer |
2d3fda |
|
|
Harald Hoyer |
2d3fda |
# 80x25 linebreak here ^
|
|
Harald Hoyer |
2d3fda |
cat << EOF
|
|
Harald Hoyer |
2d3fda |
-Usage: $0 [OPTION]... <initramfs> <kernel-version>
|
|
Harald Hoyer |
2d3fda |
+Usage: $0 [OPTION]... [<initramfs> [<kernel-version>]]
|
|
Harald Hoyer |
2d3fda |
+
|
|
Harald Hoyer |
2d3fda |
+Version: $DRACUT_VERSION
|
|
Harald Hoyer |
2d3fda |
+
|
|
Harald Hoyer |
2d3fda |
+Creates initial ramdisk images for preloading modules
|
|
Harald Hoyer |
2d3fda |
+
|
|
Harald Hoyer |
2d3fda |
+ -h, --help Display all options
|
|
Harald Hoyer |
2d3fda |
+
|
|
Harald Hoyer |
2d3fda |
+If a [LIST] has multiple arguments, then you have to put these in quotes.
|
|
Harald Hoyer |
2d3fda |
+
|
|
Harald Hoyer |
2d3fda |
+For example:
|
|
Harald Hoyer |
2d3fda |
+
|
|
Harald Hoyer |
2d3fda |
+ # dracut --add-drivers "module1 module2" ...
|
|
Harald Hoyer |
2d3fda |
+
|
|
Harald Hoyer |
2d3fda |
+EOF
|
|
Harald Hoyer |
2d3fda |
+}
|
|
Harald Hoyer |
2d3fda |
+
|
|
Harald Hoyer |
2d3fda |
+long_usage() {
|
|
Harald Hoyer |
2d3fda |
+ [[ $dracutbasedir ]] || dracutbasedir=/usr/lib/dracut
|
|
Harald Hoyer |
2d3fda |
+ if [[ -f $dracutbasedir/dracut-version.sh ]]; then
|
|
Harald Hoyer |
2d3fda |
+ . $dracutbasedir/dracut-version.sh
|
|
Harald Hoyer |
2d3fda |
+ fi
|
|
Harald Hoyer |
2d3fda |
+
|
|
Harald Hoyer |
2d3fda |
+# 80x25 linebreak here ^
|
|
Harald Hoyer |
2d3fda |
+ cat << EOF
|
|
Harald Hoyer |
2d3fda |
+Usage: $0 [OPTION]... [<initramfs> [<kernel-version>]]
|
|
Harald Hoyer |
2d3fda |
|
|
Harald Hoyer |
2d3fda |
Version: $DRACUT_VERSION
|
|
Harald Hoyer |
2d3fda |
|
|
Harald Hoyer |
2d3fda |
@@ -139,8 +164,11 @@ Creates initial ramdisk images for preloading modules
|
|
Harald Hoyer |
2d3fda |
--sshkey [SSHKEY] Add ssh key to initramfs (use with ssh-client module)
|
|
Harald Hoyer |
2d3fda |
|
|
Harald Hoyer |
2d3fda |
If [LIST] has multiple arguments, then you have to put these in quotes.
|
|
Harald Hoyer |
2d3fda |
+
|
|
Harald Hoyer |
2d3fda |
For example:
|
|
Harald Hoyer |
2d3fda |
-# dracut --add-drivers "module1 module2" ...
|
|
Harald Hoyer |
2d3fda |
+
|
|
Harald Hoyer |
2d3fda |
+ # dracut --add-drivers "module1 module2" ...
|
|
Harald Hoyer |
2d3fda |
+
|
|
Harald Hoyer |
2d3fda |
EOF
|
|
Harald Hoyer |
2d3fda |
}
|
|
Harald Hoyer |
2d3fda |
|
|
Harald Hoyer |
2d3fda |
@@ -151,9 +179,10 @@ EOF
|
|
Harald Hoyer |
2d3fda |
# example:
|
|
Harald Hoyer |
2d3fda |
# push stack 1 2 "3 4"
|
|
Harald Hoyer |
2d3fda |
push() {
|
|
Harald Hoyer |
2d3fda |
+ local _i
|
|
Harald Hoyer |
2d3fda |
local __stack=$1; shift
|
|
Harald Hoyer |
2d3fda |
- for i in "$@"; do
|
|
Harald Hoyer |
2d3fda |
- eval ${__stack}'[${#'${__stack}'[@]}]="$i"'
|
|
Harald Hoyer |
2d3fda |
+ for _i in "$@"; do
|
|
Harald Hoyer |
2d3fda |
+ eval ${__stack}'[${#'${__stack}'[@]}]="$_i"'
|
|
Harald Hoyer |
2d3fda |
done
|
|
Harald Hoyer |
2d3fda |
}
|
|
Harald Hoyer |
2d3fda |
|
|
Harald Hoyer |
2d3fda |
@@ -169,16 +198,16 @@ push() {
|
|
Harald Hoyer |
2d3fda |
pop() {
|
|
Harald Hoyer |
2d3fda |
local __stack=$1; shift
|
|
Harald Hoyer |
2d3fda |
local __resultvar=$1
|
|
Harald Hoyer |
2d3fda |
- local myresult;
|
|
Harald Hoyer |
2d3fda |
+ local _value;
|
|
Harald Hoyer |
2d3fda |
# check for empty stack
|
|
Harald Hoyer |
2d3fda |
eval '[[ ${#'${__stack}'[@]} -eq 0 ]] && return 1'
|
|
Harald Hoyer |
2d3fda |
|
|
Harald Hoyer |
2d3fda |
- eval myresult='${'${__stack}'[${#'${__stack}'[@]}-1]}'
|
|
Harald Hoyer |
2d3fda |
+ eval _value='${'${__stack}'[${#'${__stack}'[@]}-1]}'
|
|
Harald Hoyer |
2d3fda |
|
|
Harald Hoyer |
2d3fda |
if [[ "$__resultvar" ]]; then
|
|
Harald Hoyer |
2d3fda |
- eval $__resultvar="'$myresult'"
|
|
Harald Hoyer |
2d3fda |
+ eval $__resultvar="'$_value'"
|
|
Harald Hoyer |
2d3fda |
else
|
|
Harald Hoyer |
2d3fda |
- echo "$myresult"
|
|
Harald Hoyer |
2d3fda |
+ echo "$_value"
|
|
Harald Hoyer |
2d3fda |
fi
|
|
Harald Hoyer |
2d3fda |
eval unset ${__stack}'[${#'${__stack}'[@]}-1]'
|
|
Harald Hoyer |
2d3fda |
return 0
|
|
Harald Hoyer |
2d3fda |
@@ -202,52 +231,105 @@ read_arg() {
|
|
Harald Hoyer |
2d3fda |
fi
|
|
Harald Hoyer |
2d3fda |
}
|
|
Harald Hoyer |
2d3fda |
|
|
Harald Hoyer |
2d3fda |
-# Little helper function for reading args from the commandline to a stack.
|
|
Harald Hoyer |
2d3fda |
-# it automatically handles -a b and -a=b variants, and returns 1 if
|
|
Harald Hoyer |
2d3fda |
-# we need to shift $3.
|
|
Harald Hoyer |
2d3fda |
-push_arg() {
|
|
Harald Hoyer |
2d3fda |
- # $1 = arg name
|
|
Harald Hoyer |
2d3fda |
- # $2 = arg value
|
|
Harald Hoyer |
2d3fda |
- # $3 = arg parameter
|
|
Harald Hoyer |
2d3fda |
- local rematch='^[^=]*=(.*)$'
|
|
Harald Hoyer |
2d3fda |
- if [[ $2 =~ $rematch ]]; then
|
|
Harald Hoyer |
2d3fda |
- push "$1" "${BASH_REMATCH[1]}"
|
|
Harald Hoyer |
2d3fda |
- else
|
|
Harald Hoyer |
2d3fda |
- push "$1" "$3"
|
|
Harald Hoyer |
2d3fda |
- # There is no way to shift our callers args, so
|
|
Harald Hoyer |
2d3fda |
- # return 1 to indicate they should do it instead.
|
|
Harald Hoyer |
2d3fda |
- return 1
|
|
Harald Hoyer |
2d3fda |
- fi
|
|
Harald Hoyer |
2d3fda |
-}
|
|
Harald Hoyer |
2d3fda |
-
|
|
Harald Hoyer |
2d3fda |
verbosity_mod_l=0
|
|
Harald Hoyer |
2d3fda |
unset kernel
|
|
Harald Hoyer |
2d3fda |
unset outfile
|
|
Harald Hoyer |
2d3fda |
|
|
Harald Hoyer |
2d3fda |
-while (($# > 0)); do
|
|
Harald Hoyer |
2d3fda |
- case ${1%%=*} in
|
|
Harald Hoyer |
2d3fda |
- -a|--add) push_arg add_dracutmodules_l "$@" || shift;;
|
|
Harald Hoyer |
2d3fda |
- --force-add) push_arg force_add_dracutmodules_l "$@" || shift;;
|
|
Harald Hoyer |
2d3fda |
- --add-drivers) push_arg add_drivers_l "$@" || shift;;
|
|
Harald Hoyer |
2d3fda |
- --omit-drivers) push_arg omit_drivers_l "$@" || shift;;
|
|
Harald Hoyer |
2d3fda |
- -m|--modules) push_arg dracutmodules_l "$@" || shift;;
|
|
Harald Hoyer |
2d3fda |
- -o|--omit) push_arg omit_dracutmodules_l "$@" || shift;;
|
|
Harald Hoyer |
2d3fda |
- -d|--drivers) push_arg drivers_l "$@" || shift;;
|
|
Harald Hoyer |
2d3fda |
- --filesystems) push_arg filesystems_l "$@" || shift;;
|
|
Harald Hoyer |
2d3fda |
- -I|--install) push_arg install_items_l "$@" || shift;;
|
|
Harald Hoyer |
2d3fda |
- --fwdir) push_arg fw_dir_l "$@" || shift;;
|
|
Harald Hoyer |
2d3fda |
- --libdirs) push_arg libdirs_l "$@" || shift;;
|
|
Harald Hoyer |
2d3fda |
- --fscks) push_arg fscks_l "$@" || shift;;
|
|
Harald Hoyer |
2d3fda |
- --add-fstab) push_arg add_fstab_l "$@" || shift;;
|
|
Harald Hoyer |
2d3fda |
- --mount) push_arg fstab_lines "$@" || shift;;
|
|
Harald Hoyer |
2d3fda |
+# Workaround -i, --include taking 2 arguments
|
|
Harald Hoyer |
2d3fda |
+set -- "${@/--include/++include}"
|
|
Harald Hoyer |
2d3fda |
+
|
|
Harald Hoyer |
2d3fda |
+# This prevents any long argument ending with "-i"
|
|
Harald Hoyer |
2d3fda |
+# -i, like --opt-i but I think we can just prevent that
|
|
Harald Hoyer |
2d3fda |
+set -- "${@/%-i/++include}"
|
|
Harald Hoyer |
2d3fda |
+
|
|
Harald Hoyer |
2d3fda |
+TEMP=$(unset POSIXLY_CORRECT; getopt \
|
|
Harald Hoyer |
2d3fda |
+ -o "a:m:o:d:I:k:c:L:fvqlHhM" \
|
|
Harald Hoyer |
2d3fda |
+ --long add: \
|
|
Harald Hoyer |
2d3fda |
+ --long force-add: \
|
|
Harald Hoyer |
2d3fda |
+ --long add-drivers: \
|
|
Harald Hoyer |
2d3fda |
+ --long omit-drivers: \
|
|
Harald Hoyer |
2d3fda |
+ --long modules: \
|
|
Harald Hoyer |
2d3fda |
+ --long omit: \
|
|
Harald Hoyer |
2d3fda |
+ --long drivers: \
|
|
Harald Hoyer |
2d3fda |
+ --long filesystems: \
|
|
Harald Hoyer |
2d3fda |
+ --long install: \
|
|
Harald Hoyer |
2d3fda |
+ --long fwdir: \
|
|
Harald Hoyer |
2d3fda |
+ --long libdirs: \
|
|
Harald Hoyer |
2d3fda |
+ --long fscks: \
|
|
Harald Hoyer |
2d3fda |
+ --long add-fstab: \
|
|
Harald Hoyer |
2d3fda |
+ --long mount: \
|
|
Harald Hoyer |
2d3fda |
+ --long nofscks: \
|
|
Harald Hoyer |
2d3fda |
+ --long kmoddir: \
|
|
Harald Hoyer |
2d3fda |
+ --long conf: \
|
|
Harald Hoyer |
2d3fda |
+ --long confdir: \
|
|
Harald Hoyer |
2d3fda |
+ --long tmpdir: \
|
|
Harald Hoyer |
2d3fda |
+ --long stdlog: \
|
|
Harald Hoyer |
2d3fda |
+ --long compress: \
|
|
Harald Hoyer |
2d3fda |
+ --long prefix: \
|
|
Harald Hoyer |
2d3fda |
+ --long force \
|
|
Harald Hoyer |
2d3fda |
+ --long kernel-only \
|
|
Harald Hoyer |
2d3fda |
+ --long no-kernel \
|
|
Harald Hoyer |
2d3fda |
+ --long strip \
|
|
Harald Hoyer |
2d3fda |
+ --long nostrip \
|
|
Harald Hoyer |
2d3fda |
+ --long hardlink \
|
|
Harald Hoyer |
2d3fda |
+ --long nohardlink \
|
|
Harald Hoyer |
2d3fda |
+ --long noprefix \
|
|
Harald Hoyer |
2d3fda |
+ --long mdadmconf \
|
|
Harald Hoyer |
2d3fda |
+ --long nomdadmconf \
|
|
Harald Hoyer |
2d3fda |
+ --long lvmconf \
|
|
Harald Hoyer |
2d3fda |
+ --long nolvmconf \
|
|
Harald Hoyer |
2d3fda |
+ --long debug \
|
|
Harald Hoyer |
2d3fda |
+ --long profile \
|
|
Harald Hoyer |
2d3fda |
+ --long sshkey: \
|
|
Harald Hoyer |
2d3fda |
+ --long verbose \
|
|
Harald Hoyer |
2d3fda |
+ --long quiet \
|
|
Harald Hoyer |
2d3fda |
+ --long local \
|
|
Harald Hoyer |
2d3fda |
+ --long hostonly \
|
|
Harald Hoyer |
2d3fda |
+ --long no-hostonly \
|
|
Harald Hoyer |
2d3fda |
+ --long fstab \
|
|
Harald Hoyer |
2d3fda |
+ --long help \
|
|
Harald Hoyer |
2d3fda |
+ --long bzip2 \
|
|
Harald Hoyer |
2d3fda |
+ --long lzma \
|
|
Harald Hoyer |
2d3fda |
+ --long xz \
|
|
Harald Hoyer |
2d3fda |
+ --long no-compress \
|
|
Harald Hoyer |
2d3fda |
+ --long gzip \
|
|
Harald Hoyer |
2d3fda |
+ --long list-modules \
|
|
Harald Hoyer |
2d3fda |
+ --long show-modules \
|
|
Harald Hoyer |
2d3fda |
+ --long keep \
|
|
Harald Hoyer |
2d3fda |
+ --long printsize \
|
|
Harald Hoyer |
2d3fda |
+ -- "$@")
|
|
Harald Hoyer |
2d3fda |
+
|
|
Harald Hoyer |
2d3fda |
+if (( $? != 0 )); then
|
|
Harald Hoyer |
2d3fda |
+ usage
|
|
Harald Hoyer |
2d3fda |
+ exit 1
|
|
Harald Hoyer |
2d3fda |
+fi
|
|
Harald Hoyer |
2d3fda |
+
|
|
Harald Hoyer |
2d3fda |
+eval set -- "$TEMP"
|
|
Harald Hoyer |
2d3fda |
+
|
|
Harald Hoyer |
2d3fda |
+while :; do
|
|
Harald Hoyer |
2d3fda |
+ case $1 in
|
|
Harald Hoyer |
2d3fda |
+ -a|--add) push add_dracutmodules_l "$2"; shift;;
|
|
Harald Hoyer |
2d3fda |
+ --force-add) push force_add_dracutmodules_l "$2"; shift;;
|
|
Harald Hoyer |
2d3fda |
+ --add-drivers) push add_drivers_l "$2"; shift;;
|
|
Harald Hoyer |
2d3fda |
+ --omit-drivers) push omit_drivers_l "$2"; shift;;
|
|
Harald Hoyer |
2d3fda |
+ -m|--modules) push dracutmodules_l "$2"; shift;;
|
|
Harald Hoyer |
2d3fda |
+ -o|--omit) push omit_dracutmodules_l "$2"; shift;;
|
|
Harald Hoyer |
2d3fda |
+ -d|--drivers) push drivers_l "$2"; shift;;
|
|
Harald Hoyer |
2d3fda |
+ --filesystems) push filesystems_l "$2"; shift;;
|
|
Harald Hoyer |
2d3fda |
+ -I|--install) push install_items_l "$2"; shift;;
|
|
Harald Hoyer |
2d3fda |
+ --fwdir) push fw_dir_l "$2"; shift;;
|
|
Harald Hoyer |
2d3fda |
+ --libdirs) push libdirs_l "$2"; shift;;
|
|
Harald Hoyer |
2d3fda |
+ --fscks) push fscks_l "$2"; shift;;
|
|
Harald Hoyer |
2d3fda |
+ --add-fstab) push add_fstab_l "$2"; shift;;
|
|
Harald Hoyer |
2d3fda |
+ --mount) push fstab_lines "$2"; shift;;
|
|
Harald Hoyer |
2d3fda |
--nofscks) nofscks_l="yes";;
|
|
Harald Hoyer |
2d3fda |
- -k|--kmoddir) read_arg drivers_dir_l "$@" || shift;;
|
|
Harald Hoyer |
2d3fda |
- -c|--conf) read_arg conffile "$@" || shift;;
|
|
Harald Hoyer |
2d3fda |
- --confdir) read_arg confdir "$@" || shift;;
|
|
Harald Hoyer |
2d3fda |
- --tmpdir) read_arg tmpdir_l "$@" || shift;;
|
|
Harald Hoyer |
2d3fda |
- -L|--stdlog) read_arg stdloglvl_l "$@" || shift;;
|
|
Harald Hoyer |
2d3fda |
- --compress) read_arg compress_l "$@" || shift;;
|
|
Harald Hoyer |
2d3fda |
- --prefix) read_arg prefix_l "$@" || shift;;
|
|
Harald Hoyer |
2d3fda |
+ -k|--kmoddir) drivers_dir_l="$2"; shift;;
|
|
Harald Hoyer |
2d3fda |
+ -c|--conf) conffile="$2"; shift;;
|
|
Harald Hoyer |
2d3fda |
+ --confdir) confdir="$2"; shift;;
|
|
Harald Hoyer |
2d3fda |
+ --tmpdir) tmpdir_l="$2"; shift;;
|
|
Harald Hoyer |
2d3fda |
+ -L|--stdlog) stdloglvl_l="$2"; shift;;
|
|
Harald Hoyer |
2d3fda |
+ --compress) compress_l="$2"; shift;;
|
|
Harald Hoyer |
2d3fda |
+ --prefix) prefix_l="$2"; shift;;
|
|
Harald Hoyer |
2d3fda |
-f|--force) force=yes;;
|
|
Harald Hoyer |
2d3fda |
--kernel-only) kernel_only="yes"; no_kernel="no";;
|
|
Harald Hoyer |
2d3fda |
--no-kernel) kernel_only="no"; no_kernel="yes";;
|
|
Harald Hoyer |
2d3fda |
@@ -262,7 +344,7 @@ while (($# > 0)); do
|
|
Harald Hoyer |
2d3fda |
--nolvmconf) lvmconf_l="no";;
|
|
Harald Hoyer |
2d3fda |
--debug) debug="yes";;
|
|
Harald Hoyer |
2d3fda |
--profile) profile="yes";;
|
|
Harald Hoyer |
2d3fda |
- --sshkey) read_arg sshkey "$@" || shift;;
|
|
Harald Hoyer |
2d3fda |
+ --sshkey) sshkey="$2"; shift;;
|
|
Harald Hoyer |
2d3fda |
-v|--verbose) ((verbosity_mod_l++));;
|
|
Harald Hoyer |
2d3fda |
-q|--quiet) ((verbosity_mod_l--));;
|
|
Harald Hoyer |
2d3fda |
-l|--local)
|
|
Harald Hoyer |
2d3fda |
@@ -273,48 +355,67 @@ while (($# > 0)); do
|
|
Harald Hoyer |
2d3fda |
-H|--hostonly) hostonly_l="yes" ;;
|
|
Harald Hoyer |
2d3fda |
--no-hostonly) hostonly_l="no" ;;
|
|
Harald Hoyer |
2d3fda |
--fstab) use_fstab_l="yes" ;;
|
|
Harald Hoyer |
2d3fda |
- -h|--help) usage; exit 1 ;;
|
|
Harald Hoyer |
2d3fda |
+ -h|--help) long_usage; exit 1 ;;
|
|
Harald Hoyer |
2d3fda |
-i|--include) push include_src "$2"
|
|
Harald Hoyer |
2d3fda |
- push include_target "$3"
|
|
Harald Hoyer |
2d3fda |
- shift 2;;
|
|
Harald Hoyer |
2d3fda |
+ shift;;
|
|
Harald Hoyer |
2d3fda |
--bzip2) compress_l="bzip2";;
|
|
Harald Hoyer |
2d3fda |
--lzma) compress_l="lzma";;
|
|
Harald Hoyer |
2d3fda |
--xz) compress_l="xz";;
|
|
Harald Hoyer |
2d3fda |
--no-compress) _no_compress_l="cat";;
|
|
Harald Hoyer |
2d3fda |
--gzip) compress_l="gzip";;
|
|
Harald Hoyer |
2d3fda |
- --list-modules)
|
|
Harald Hoyer |
2d3fda |
- do_list="yes";
|
|
Harald Hoyer |
2d3fda |
- ;;
|
|
Harald Hoyer |
2d3fda |
+ --list-modules) do_list="yes";;
|
|
Harald Hoyer |
2d3fda |
-M|--show-modules)
|
|
Harald Hoyer |
2d3fda |
show_modules_l="yes"
|
|
Harald Hoyer |
2d3fda |
;;
|
|
Harald Hoyer |
2d3fda |
--keep) keep="yes";;
|
|
Harald Hoyer |
2d3fda |
--printsize) printsize="yes";;
|
|
Harald Hoyer |
2d3fda |
- -*) printf "\nUnknown option: %s\n\n" "$1" >&2; usage; exit 1;;
|
|
Harald Hoyer |
2d3fda |
+
|
|
Harald Hoyer |
2d3fda |
+ --) shift; break;;
|
|
Harald Hoyer |
2d3fda |
+
|
|
Harald Hoyer |
2d3fda |
+ *) # should not even reach this point
|
|
Harald Hoyer |
2d3fda |
+ printf "\n!Unknown option: '%s'\n\n" "$1" >&2; usage; exit 1;;
|
|
Harald Hoyer |
2d3fda |
+ esac
|
|
Harald Hoyer |
2d3fda |
+ shift
|
|
Harald Hoyer |
2d3fda |
+done
|
|
Harald Hoyer |
2d3fda |
+
|
|
Harald Hoyer |
2d3fda |
+# getopt cannot handle multiple arguments, so just handle "-I,--include"
|
|
Harald Hoyer |
2d3fda |
+# the old fashioned way
|
|
Harald Hoyer |
2d3fda |
+
|
|
Harald Hoyer |
2d3fda |
+while (($# > 0)); do
|
|
Harald Hoyer |
2d3fda |
+ case ${1%%=*} in
|
|
Harald Hoyer |
2d3fda |
+ ++include) push include_src "$2"
|
|
Harald Hoyer |
2d3fda |
+ push include_target "$3"
|
|
Harald Hoyer |
2d3fda |
+ shift 2;;
|
|
Harald Hoyer |
2d3fda |
*)
|
|
Harald Hoyer |
2d3fda |
if ! [[ ${outfile+x} ]]; then
|
|
Harald Hoyer |
2d3fda |
outfile=$1
|
|
Harald Hoyer |
2d3fda |
elif ! [[ ${kernel+x} ]]; then
|
|
Harald Hoyer |
2d3fda |
kernel=$1
|
|
Harald Hoyer |
2d3fda |
else
|
|
Harald Hoyer |
2d3fda |
- echo "Unknown argument: $1"
|
|
Harald Hoyer |
2d3fda |
+ printf "\nUnknown arguments: %s\n\n" "$*" >&2
|
|
Harald Hoyer |
2d3fda |
usage; exit 1;
|
|
Harald Hoyer |
2d3fda |
fi
|
|
Harald Hoyer |
2d3fda |
;;
|
|
Harald Hoyer |
2d3fda |
esac
|
|
Harald Hoyer |
2d3fda |
shift
|
|
Harald Hoyer |
2d3fda |
done
|
|
Harald Hoyer |
2d3fda |
+
|
|
Harald Hoyer |
2d3fda |
if ! [[ $kernel ]]; then
|
|
Harald Hoyer |
2d3fda |
kernel=$(uname -r)
|
|
Harald Hoyer |
2d3fda |
fi
|
|
Harald Hoyer |
2d3fda |
-[[ $outfile ]] || outfile="/boot/initramfs-$kernel.img"
|
|
Harald Hoyer |
2d3fda |
+
|
|
Harald Hoyer |
2d3fda |
+if ! [[ $outfile ]]; then
|
|
Harald Hoyer |
2d3fda |
+ outfile="/boot/initramfs-$kernel.img"
|
|
Harald Hoyer |
2d3fda |
+fi
|
|
Harald Hoyer |
2d3fda |
|
|
Harald Hoyer |
2d3fda |
for i in /usr/sbin /sbin /usr/bin /bin; do
|
|
Harald Hoyer |
2d3fda |
rl=$i
|
|
Harald Hoyer |
2d3fda |
if [ -L "$i" ]; then
|
|
Harald Hoyer |
2d3fda |
rl=$(readlink -f $i)
|
|
Harald Hoyer |
2d3fda |
fi
|
|
Harald Hoyer |
2d3fda |
- NPATH+=":$rl"
|
|
Harald Hoyer |
2d3fda |
+ if [[ "$NPATH" != "*:$rl*" ]] ; then
|
|
Harald Hoyer |
2d3fda |
+ NPATH+=":$rl"
|
|
Harald Hoyer |
2d3fda |
+ fi
|
|
Harald Hoyer |
2d3fda |
done
|
|
Harald Hoyer |
2d3fda |
export PATH="${NPATH#:}"
|
|
Harald Hoyer |
2d3fda |
unset NPATH
|
|
Harald Hoyer |
2d3fda |
@@ -536,8 +637,12 @@ done
|
|
Harald Hoyer |
2d3fda |
omit_drivers="${omit_drivers_corrected%|}"
|
|
Harald Hoyer |
2d3fda |
unset omit_drivers_corrected
|
|
Harald Hoyer |
2d3fda |
|
|
Harald Hoyer |
2d3fda |
-
|
|
Harald Hoyer |
2d3fda |
-ddebug "Executing $0 $dracut_args"
|
|
Harald Hoyer |
2d3fda |
+# prepare args for logging
|
|
Harald Hoyer |
2d3fda |
+for ((i=0; i < ${#dracut_args[@]}; i++)); do
|
|
Harald Hoyer |
2d3fda |
+ strstr "${dracut_args[$i]}" " " && \
|
|
Harald Hoyer |
2d3fda |
+ dracut_args[$i]="\"${dracut_args[$i]}\""
|
|
Harald Hoyer |
2d3fda |
+done
|
|
Harald Hoyer |
2d3fda |
+ddebug "Executing: $0 ${dracut_args[@]}"
|
|
Harald Hoyer |
2d3fda |
|
|
Harald Hoyer |
2d3fda |
[[ $do_list = yes ]] && {
|
|
Harald Hoyer |
2d3fda |
for mod in $dracutbasedir/modules.d/*; do
|
|
Harald Hoyer |
2d3fda |
@@ -573,7 +678,7 @@ if [[ ! -d "$outdir" ]]; then
|
|
Harald Hoyer |
2d3fda |
dfatal "Can't write $outfile: Directory $outdir does not exist."
|
|
Harald Hoyer |
2d3fda |
exit 1
|
|
Harald Hoyer |
2d3fda |
elif [[ ! -w "$outdir" ]]; then
|
|
Harald Hoyer |
2d3fda |
- dfatal "No permission to write $outdir."
|
|
Harald Hoyer |
2d3fda |
+ dfatal "No permission to write to $outdir."
|
|
Harald Hoyer |
2d3fda |
exit 1
|
|
Harald Hoyer |
2d3fda |
elif [[ -f "$outfile" && ! -w "$outfile" ]]; then
|
|
Harald Hoyer |
2d3fda |
dfatal "No permission to write $outfile."
|