diff --git a/tinyramfs b/tinyramfs index 3f597fb..e1bcbc2 100755 --- a/tinyramfs +++ b/tinyramfs @@ -21,11 +21,14 @@ msg() { } usage() { + scriptdir=$(readlink -f $(dirname "$0")) + # TODO more options cat << EOF usage: $0 [options] - -o, --output output file. default is $(readlink -f $(dirname "$0"))/initramfs-$(uname -r) - -f, --files files directory. default is $(readlink -f $(dirname "$0")) + -o, --output output file. default is ${scriptdir}/initramfs-$(uname -r) + -c, --config config file. default is ${scriptdir}/config + -f, --files files directory. default is ${scriptdir}/files EOF } @@ -34,11 +37,15 @@ parse_args() { while [ "$1" ]; do case "$1" in -o | --output) - initramfs="$2" + initramfs="${2?}" shift 2 ;; -f | --files) - filesdir="$2" + filesdir="${2?}" + shift 2 + ;; + -c | --config) + config="${2?}" shift 2 ;; -h | --help) @@ -67,7 +74,7 @@ parse_conf() { elif [ ! "$(eval printf "%s" "\"\$${line%%=*}\"")" ]; then eval "$line" 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() { @@ -425,8 +432,8 @@ parse_conf : "${kernel:=$(uname -r)}" : "${moddir:=/lib/modules}" -: "${filesdir:=$(readlink -f $(dirname "$0"))}" -: "${initramfs:=${filesdir}/initramfs-${kernel}}" +: "${filesdir:=$(readlink -f $(dirname "$0"))/files}" +: "${initramfs:=$(readlink -f $(dirname "$0"))/initramfs-${kernel}}" # remove wrkdir on exit or unexpected error trap remove_wrkdir EXIT INT