fixed indentation
This commit is contained in:
@@ -16,8 +16,8 @@ read_commandline()
|
||||
{
|
||||
syntax_error()
|
||||
{
|
||||
prnt E "Error while analysing command line parameters."
|
||||
die 1 --force
|
||||
prnt E "Error while analysing command line parameters."
|
||||
die 1 --force
|
||||
}
|
||||
|
||||
# Processing command line options
|
||||
@@ -27,117 +27,117 @@ read_commandline()
|
||||
local want_chroot=false
|
||||
local opt=
|
||||
for opt in $@; do
|
||||
case $opt in
|
||||
"-h"|"--help")
|
||||
disp_help
|
||||
exit 0
|
||||
;;
|
||||
"-v"|"--version")
|
||||
show_version
|
||||
exit 0
|
||||
;;
|
||||
"-m"|"--module")
|
||||
local want_module=true
|
||||
;;
|
||||
"-c"|"--check-only")
|
||||
export CHECK_ONLY=true
|
||||
;;
|
||||
"-j"|"--jump")
|
||||
export JUMP=true
|
||||
;;
|
||||
"-k"|"--keep-going")
|
||||
export KEEPGOING=true
|
||||
;;
|
||||
"-r"|"--resume")
|
||||
if [[ -s $STAGE_FILE ]]; then
|
||||
export RESUME=true
|
||||
else
|
||||
prnt E "The status file doesn't exists or is empty!"
|
||||
prnt E "Without it, resuming is impossible."
|
||||
die 17 --force
|
||||
fi
|
||||
;;
|
||||
"-R"|"--no-root-check")
|
||||
export NO_ROOT_CHECK=true
|
||||
;;
|
||||
"-D"|"--no-deps")
|
||||
export NO_DEPS=true
|
||||
;;
|
||||
"-o"|"--offline")
|
||||
export OFFLINE=true
|
||||
;;
|
||||
"-P"|"--no-proxy")
|
||||
export NO_PROXY=true
|
||||
;;
|
||||
"-l"|"--logfile")
|
||||
local want_logfile=true
|
||||
;;
|
||||
"-f"|"--file")
|
||||
local want_conffile=true
|
||||
;;
|
||||
"-s"|"--shell")
|
||||
export RUN_SHELL=true
|
||||
;;
|
||||
"--chroot")
|
||||
local want_chroot=true
|
||||
;;
|
||||
"--cron")
|
||||
export CRON_MODE=true
|
||||
;;
|
||||
*)
|
||||
if [[ $want_module == true ]]; then
|
||||
[[ $want_logfile == true ]] && synthax_error
|
||||
[[ $want_conffile == true ]] && synthax_error
|
||||
[[ $want_chroot == true ]] && synthax_error
|
||||
if [[ -z $MANUAL_MODULE_LIST ]]; then
|
||||
export MANUAL_MODULE_LIST=$opt
|
||||
want_module=false
|
||||
else
|
||||
prnt E "A module list have already been given!"
|
||||
prnt E "Commande line only tolerate one --module parameter."
|
||||
die 1 --force
|
||||
fi
|
||||
elif [[ $want_logfile == true ]]; then
|
||||
[[ $want_module == true ]] && synthax_error
|
||||
[[ $want_conffile == true ]] && synthax_error
|
||||
[[ $want_chroot == true ]] && synthax_error
|
||||
if [[ -z $NEW_LOGFILE ]]; then
|
||||
export NEW_LOGFILE=$opt
|
||||
want_logfile=false
|
||||
else
|
||||
prnt E "Impossible to specify several log files."
|
||||
die 1 --force
|
||||
fi
|
||||
elif [[ $want_conffile == true ]]; then
|
||||
[[ $want_module == true ]] && synthax_error
|
||||
[[ $want_logfile == true ]] && synthax_error
|
||||
[[ $want_chroot == true ]] && synthax_error
|
||||
export CONFFILES="$CONFFILES $opt"
|
||||
want_logfile=false
|
||||
elif [[ $want_chroot == true ]]; then
|
||||
[[ $want_module == true ]] && synthax_error
|
||||
[[ $want_logfile == true ]] && synthax_error
|
||||
[[ $want_conffile == true ]] && synthax_error
|
||||
if [[ -z $CHROOT_PATH ]]; then
|
||||
export CHROOT_PATH=$opt
|
||||
want_chroot=false
|
||||
else
|
||||
prnt E "A chroot path have already been given."
|
||||
die 1 --force
|
||||
fi
|
||||
else
|
||||
prnt E "Unknow parameter \"$opt\"."
|
||||
die 1 --force
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
case $opt in
|
||||
"-h"|"--help")
|
||||
disp_help
|
||||
exit 0
|
||||
;;
|
||||
"-v"|"--version")
|
||||
show_version
|
||||
exit 0
|
||||
;;
|
||||
"-m"|"--module")
|
||||
local want_module=true
|
||||
;;
|
||||
"-c"|"--check-only")
|
||||
export CHECK_ONLY=true
|
||||
;;
|
||||
"-j"|"--jump")
|
||||
export JUMP=true
|
||||
;;
|
||||
"-k"|"--keep-going")
|
||||
export KEEPGOING=true
|
||||
;;
|
||||
"-r"|"--resume")
|
||||
if [[ -s $STAGE_FILE ]]; then
|
||||
export RESUME=true
|
||||
else
|
||||
prnt E "The status file doesn't exists or is empty!"
|
||||
prnt E "Without it, resuming is impossible."
|
||||
die 17 --force
|
||||
fi
|
||||
;;
|
||||
"-R"|"--no-root-check")
|
||||
export NO_ROOT_CHECK=true
|
||||
;;
|
||||
"-D"|"--no-deps")
|
||||
export NO_DEPS=true
|
||||
;;
|
||||
"-o"|"--offline")
|
||||
export OFFLINE=true
|
||||
;;
|
||||
"-P"|"--no-proxy")
|
||||
export NO_PROXY=true
|
||||
;;
|
||||
"-l"|"--logfile")
|
||||
local want_logfile=true
|
||||
;;
|
||||
"-f"|"--file")
|
||||
local want_conffile=true
|
||||
;;
|
||||
"-s"|"--shell")
|
||||
export RUN_SHELL=true
|
||||
;;
|
||||
"--chroot")
|
||||
local want_chroot=true
|
||||
;;
|
||||
"--cron")
|
||||
export CRON_MODE=true
|
||||
;;
|
||||
*)
|
||||
if [[ $want_module == true ]]; then
|
||||
[[ $want_logfile == true ]] && synthax_error
|
||||
[[ $want_conffile == true ]] && synthax_error
|
||||
[[ $want_chroot == true ]] && synthax_error
|
||||
if [[ -z $MANUAL_MODULE_LIST ]]; then
|
||||
export MANUAL_MODULE_LIST=$opt
|
||||
want_module=false
|
||||
else
|
||||
prnt E "A module list have already been given!"
|
||||
prnt E "Commande line only tolerate one --module parameter."
|
||||
die 1 --force
|
||||
fi
|
||||
elif [[ $want_logfile == true ]]; then
|
||||
[[ $want_module == true ]] && synthax_error
|
||||
[[ $want_conffile == true ]] && synthax_error
|
||||
[[ $want_chroot == true ]] && synthax_error
|
||||
if [[ -z $NEW_LOGFILE ]]; then
|
||||
export NEW_LOGFILE=$opt
|
||||
want_logfile=false
|
||||
else
|
||||
prnt E "Impossible to specify several log files."
|
||||
die 1 --force
|
||||
fi
|
||||
elif [[ $want_conffile == true ]]; then
|
||||
[[ $want_module == true ]] && synthax_error
|
||||
[[ $want_logfile == true ]] && synthax_error
|
||||
[[ $want_chroot == true ]] && synthax_error
|
||||
export CONFFILES="$CONFFILES $opt"
|
||||
want_logfile=false
|
||||
elif [[ $want_chroot == true ]]; then
|
||||
[[ $want_module == true ]] && synthax_error
|
||||
[[ $want_logfile == true ]] && synthax_error
|
||||
[[ $want_conffile == true ]] && synthax_error
|
||||
if [[ -z $CHROOT_PATH ]]; then
|
||||
export CHROOT_PATH=$opt
|
||||
want_chroot=false
|
||||
else
|
||||
prnt E "A chroot path have already been given."
|
||||
die 1 --force
|
||||
fi
|
||||
else
|
||||
prnt E "Unknow parameter \"$opt\"."
|
||||
die 1 --force
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
done
|
||||
unset opt
|
||||
|
||||
# If those var are true at that point, something is wrong
|
||||
if [[ $want_logfile == true ]] || [[ $want_module == true ]] ||
|
||||
[[ $want_conffile == true ]] || [[ $want_chroot == true ]]; then
|
||||
syntax_error
|
||||
[[ $want_conffile == true ]] || [[ $want_chroot == true ]]; then
|
||||
syntax_error
|
||||
fi
|
||||
|
||||
unset want_conffile want_logfile want_module
|
||||
@@ -151,54 +151,54 @@ process_commandline_and_vars()
|
||||
{
|
||||
# Check unconsistant parameters
|
||||
if [[ $CHECK_ONLY == true ]]; then
|
||||
if [[ $JUMP == true ]]; then
|
||||
prnt E "The options --check-only and --jump are mutually exclusive!"
|
||||
die 1 --force
|
||||
fi
|
||||
if [[ $KEEPGOING == true ]]; then
|
||||
prnt E "The options --keep-going and --check-only are not compatible!"
|
||||
die 1 --force
|
||||
fi
|
||||
if [[ $JUMP == true ]]; then
|
||||
prnt E "The options --check-only and --jump are mutually exclusive!"
|
||||
die 1 --force
|
||||
fi
|
||||
if [[ $KEEPGOING == true ]]; then
|
||||
prnt E "The options --keep-going and --check-only are not compatible!"
|
||||
die 1 --force
|
||||
fi
|
||||
fi
|
||||
if [[ $RESUME == true ]]; then
|
||||
if [[ $CHECK_ONLY == true ]]; then
|
||||
prnt E "Resuming doesn't make sense with --check-only."
|
||||
die 1 --force
|
||||
fi
|
||||
if [[ $MANUAL_MODULE_LIST ]]; then
|
||||
prnt E "Recovery mode can't work with a manual module list."
|
||||
die 1 --force
|
||||
fi
|
||||
if [[ $CHECK_ONLY == true ]]; then
|
||||
prnt E "Resuming doesn't make sense with --check-only."
|
||||
die 1 --force
|
||||
fi
|
||||
if [[ $MANUAL_MODULE_LIST ]]; then
|
||||
prnt E "Recovery mode can't work with a manual module list."
|
||||
die 1 --force
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ $CRON_MODE == true ]]; then
|
||||
if [[ $CHECK_ONLY == true || $JUMP == true ]]; then
|
||||
prnt E "Some parameters are incompatible with cron mode."
|
||||
die 16 --force
|
||||
fi
|
||||
if [[ $CHECK_ONLY == true || $JUMP == true ]]; then
|
||||
prnt E "Some parameters are incompatible with cron mode."
|
||||
die 16 --force
|
||||
fi
|
||||
fi
|
||||
|
||||
# Configure module list
|
||||
if [[ -n $MANUAL_MODULE_LIST ]]; then
|
||||
prnt W "A manual module list will be used."
|
||||
export MODULE_LIST=$(echo $MANUAL_MODULE_LIST | sed "s/,/ /g")
|
||||
prnt W "A manual module list will be used."
|
||||
export MODULE_LIST=$(echo $MANUAL_MODULE_LIST | sed "s/,/ /g")
|
||||
fi
|
||||
|
||||
# Check for module list existance and basic syntax
|
||||
if [[ -n $MODULE_LIST ]]; then
|
||||
for mod in $MODULE_LIST; do
|
||||
if [[ $mod =~ ['-!@#$%\&*=+'] ]]; then
|
||||
prnt E "The module \"$mod\" contains a forbidden character in its name."
|
||||
die 5
|
||||
fi
|
||||
if [[ ! -s "modules/$mod.sh" ]]; then
|
||||
prnt E "The asked module \"$mod\", doesn't have any module file or module file is empty."
|
||||
die 18
|
||||
fi
|
||||
done
|
||||
for mod in $MODULE_LIST; do
|
||||
if [[ $mod =~ ['-!@#$%\&*=+'] ]]; then
|
||||
prnt E "The module \"$mod\" contains a forbidden character in its name."
|
||||
die 5
|
||||
fi
|
||||
if [[ ! -s "modules/$mod.sh" ]]; then
|
||||
prnt E "The asked module \"$mod\", doesn't have any module file or module file is empty."
|
||||
die 18
|
||||
fi
|
||||
done
|
||||
else
|
||||
prnt E "No module to execute!"
|
||||
die 5
|
||||
prnt E "No module to execute!"
|
||||
die 5
|
||||
fi
|
||||
}
|
||||
export -f process_commandline_and_vars
|
||||
|
||||
Reference in New Issue
Block a user