From 80572296522251927bf6c6b64086751c2d74556c Mon Sep 17 00:00:00 2001 From: crims0n Date: Mon, 25 Jan 2021 04:20:32 +0000 Subject: [PATCH] update build_initrd --- build_initrd | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/build_initrd b/build_initrd index e54b57d..bc282d6 100755 --- a/build_initrd +++ b/build_initrd @@ -19,6 +19,8 @@ set -u # don't change! use ./autoinstall instead UNATTENDED="0" +CMD=(build_initrd) + # ============= main ================ BUILD_DIR="" @@ -39,8 +41,33 @@ create_completion create_backup -setup_build_dir +# check number of args +if [[ $# == 0 || $# > 3 ]]; then help; fi + +# loop through args +dash_flag=false +start_index=0 +end_index=${#CMD[*]} +for ii in "$@"; do + if [[ $ii == "-" ]]; then + dash_flag=true + continue + fi + find_index $ii + if [[ $dash_flag == false ]]; then + start_index=$index + else + end_index=$(($index + 1)) + fi +done +if [[ $dash_flag == false ]]; then + end_index=$(($start_index + 1)) +fi -build_initrd +#loop through the commands +for ((ii = $start_index; ii < $end_index; ii++)); do + setup_build_dir + ${CMD[ii]} +done echo -e "${BOLD}${LIGHTYELLOW}$0${ENDCOLOUR} - ${LIGHTGREEN}Command completed successfully!${ENDCOLOUR}"