Add unattended mode

This commit is contained in:
LinuxSquare 2023-09-29 21:51:32 +02:00
parent acc20e9927
commit e498ededd3

View file

@ -13,6 +13,7 @@ done
# VARIABLES # VARIABLES
declare debuglevel=3 declare debuglevel=3
declare dryrun=false declare dryrun=false
declare attended=true
declare bedir="$(getValueByKey 'be_env_dir')" declare bedir="$(getValueByKey 'be_env_dir')"
declare grubdir="$(getValueByKey 'grub_conf_dir')" declare grubdir="$(getValueByKey 'grub_conf_dir')"
declare -a bootenvs declare -a bootenvs
@ -23,7 +24,8 @@ operations:
$(basename ${0}) {-h --help} $(basename ${0}) {-h --help}
$(basename ${0}) {-V --version} $(basename ${0}) {-V --version}
$(basename ${0}) {-v --verbose} $(basename ${0}) {-v --verbose}
$(basename ${0}) {-n --dryrun}" $(basename ${0}) {-n --dryrun}
$(basename ${0}) {--noconfirm}"
} }
function version() { function version() {
@ -39,7 +41,7 @@ the terms of the ${LICENSE}"
## ##
OPT_SHORT="hVvn" OPT_SHORT="hVvn"
OPT_LONG="help,version,verbose,dryrun" OPT_LONG="help,version,verbose,dryrun,noconfirm"
TEMP=$(getopt -o ${OPT_SHORT} --long ${OPT_LONG} -n $(basename ${0}) -- "$@") TEMP=$(getopt -o ${OPT_SHORT} --long ${OPT_LONG} -n $(basename ${0}) -- "$@")
if [ "$?" != 0 ]; then if [ "$?" != 0 ]; then
@ -65,6 +67,9 @@ while true; do
-n|--dryrun) -n|--dryrun)
dryrun=true dryrun=true
;; ;;
--noconfirm)
attended=false
;;
--) --)
shift shift
break break
@ -104,7 +109,9 @@ chmod 755 "${grubdir}/$(getValueByKey 'filename')"
grub-mkconfig -o $(getValueByKey 'grub_cfg') grub-mkconfig -o $(getValueByKey 'grub_cfg')
less $(getValueByKey 'grub_cfg') if $attended; then
less $(getValueByKey 'grub_cfg')
fi
## ##
# SCRIPT END # SCRIPT END