implement config option
This commit is contained in:
parent
8a0be0d67b
commit
b093c7a45c
21
tinyramfs
21
tinyramfs
@ -21,11 +21,14 @@ msg() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
|
scriptdir=$(readlink -f $(dirname "$0"))
|
||||||
|
|
||||||
# TODO more options
|
# TODO more options
|
||||||
cat << EOF
|
cat << EOF
|
||||||
usage: $0 [options]
|
usage: $0 [options]
|
||||||
-o, --output <file> output file. default is $(readlink -f $(dirname "$0"))/initramfs-$(uname -r)
|
-o, --output <file> output file. default is ${scriptdir}/initramfs-$(uname -r)
|
||||||
-f, --files <dir> files directory. default is $(readlink -f $(dirname "$0"))
|
-c, --config <file> config file. default is ${scriptdir}/config
|
||||||
|
-f, --files <dir> files directory. default is ${scriptdir}/files
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
@ -34,11 +37,15 @@ parse_args() {
|
|||||||
while [ "$1" ]; do
|
while [ "$1" ]; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
-o | --output)
|
-o | --output)
|
||||||
initramfs="$2"
|
initramfs="${2?}"
|
||||||
shift 2
|
shift 2
|
||||||
;;
|
;;
|
||||||
-f | --files)
|
-f | --files)
|
||||||
filesdir="$2"
|
filesdir="${2?}"
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
|
-c | --config)
|
||||||
|
config="${2?}"
|
||||||
shift 2
|
shift 2
|
||||||
;;
|
;;
|
||||||
-h | --help)
|
-h | --help)
|
||||||
@ -67,7 +74,7 @@ parse_conf() {
|
|||||||
elif [ ! "$(eval printf "%s" "\"\$${line%%=*}\"")" ]; then
|
elif [ ! "$(eval printf "%s" "\"\$${line%%=*}\"")" ]; then
|
||||||
eval "$line"
|
eval "$line"
|
||||||
fi
|
fi
|
||||||
done < "${filesdir:-$(readlink -f $(dirname "$0"))}/config" || msg panic "failed to parse config"
|
done < "${config:-$(readlink -f $(dirname "$0"))/config}" || msg panic "failed to parse config"
|
||||||
}
|
}
|
||||||
|
|
||||||
create_wrkdir() {
|
create_wrkdir() {
|
||||||
@ -425,8 +432,8 @@ parse_conf
|
|||||||
|
|
||||||
: "${kernel:=$(uname -r)}"
|
: "${kernel:=$(uname -r)}"
|
||||||
: "${moddir:=/lib/modules}"
|
: "${moddir:=/lib/modules}"
|
||||||
: "${filesdir:=$(readlink -f $(dirname "$0"))}"
|
: "${filesdir:=$(readlink -f $(dirname "$0"))/files}"
|
||||||
: "${initramfs:=${filesdir}/initramfs-${kernel}}"
|
: "${initramfs:=$(readlink -f $(dirname "$0"))/initramfs-${kernel}}"
|
||||||
|
|
||||||
# remove wrkdir on exit or unexpected error
|
# remove wrkdir on exit or unexpected error
|
||||||
trap remove_wrkdir EXIT INT
|
trap remove_wrkdir EXIT INT
|
||||||
|
Loading…
x
Reference in New Issue
Block a user