Add possibility to pass arguments to selected steps (syntax change)

Bump sequencer revision to 5.0.0
This commit is contained in:
2019-10-09 12:06:35 +02:00
parent 9a6901ee95
commit c8922f6c6d

View File

@@ -6,7 +6,7 @@
## Version information
VERSION_REV=4
VERSION_REV=5
VERSION_MAJOR=0
VERSION_MINOR=0
@@ -16,6 +16,7 @@ QUIET=0
DRY=0
VERBOSE=0
ERNO=0
STEP_ARGS=
MAX_STEP=255
ALIAS=
TEMPLATE_NAME=seqTemplateExample.sh
@@ -23,7 +24,7 @@ MISSING_CONF=missingConf.log
VERSION_STRING="${VERSION_REV}.${VERSION_MAJOR}.${VERSION_MINOR}"
helpSequencer() {
echo "Usage: ${0##*/} [OPTIONS] [STEP NUMBER(s) or ALIAS]"
echo "Usage: ${0##*/} [OPTIONS] [STEP NUMBER(s) or ALIAS] [STEP ARGUMENTS]"
echo
echo " [OPTIONS]"
echo " --dry-run, -d : Only print to console what would be done"
@@ -35,11 +36,17 @@ helpSequencer() {
echo " ( e.g.: exe apt update )"
echo " --version : Display version of sequencer and revision of sequence"
echo
echo " [STEP NUMBER(s) 1-${MAX_STEP} or ALIAS]"
echo " [STEP NUMBER\"(s)\" 1-${MAX_STEP} or ALIAS]"
echo " Single STEP or ALIAS : starting point of process"
echo " Multiple STEPS or ALIAS : execute only given steps"
echo " execute only one step with using special step 0"
echo " ( e.g. only execute step 4: $0 4 0 )"
echo " ( e.g. only execute step 4: $0 \"4 0\" )"
echo " multiple steps need to be given as string"
echo
echo " [STEP ARGUMENTS]"
echo " * : Arguments will be passed to selected steps as:"
echo " \$2 ..."
echo " \$1 is always the step number"
}
# endCheckEmpty [VariableName] [DESCRIPTION]
@@ -205,12 +212,15 @@ execute() {
existsFunction step_${1}_info
if [ $? -eq 0 ] ; then
step_${1}_info $1
else
# Add newline if no info is given
echo
fi
if [ $QUIET -ne 1 ] ; then
read -p "Start: y/n(default)? " answer
case $answer in
[yY])
step_$1 $1
step_$1 $1 "$STEP_ARGS"
;;
*)
echo Aborting installation at step $1
@@ -218,7 +228,7 @@ execute() {
;;
esac
else
step_$1 $1
step_$1 $1 "$STEP_ARGS"
fi
}
@@ -265,7 +275,8 @@ continous() {
# e.g.: selection -q 1 4 12
selection() {
local step=0
for i in $@ ; do
local array=("$@")
for i in ${array[@]} ; do
checkStep $i
step=$?
# stop on step 0
@@ -409,13 +420,12 @@ exep() {
fi
}
main() {
local START=0
# options check
for arg in "$@" ; do
case "$arg" in
case "$1" in
--dry-run|-d) # shows what would be done
DRY=1
QUIET=1
@@ -440,11 +450,15 @@ main() {
esac
done
if [ -z $1 ] || [ "$1" == "" ] ; then
if [ -z "$1" ] || [ "$1" == "" ] ; then
# Empty -> show help
displayHelp
# Assume starting at one for interactive mode
START=1
else
read -r -a START <<< "$1"
shift
STEP_ARGS="$@"
fi
# compatibility check of sequence
@@ -464,9 +478,7 @@ main() {
fi
# check for starting step
if [ ! -z "$1" ] ; then
START=$1
else
if [ -z "$1" ] ; then
# End here on quiet mode and no step was given
if [ $QUIET -eq 1 ] ; then
exit 1;
@@ -484,8 +496,8 @@ main() {
parseAlias
# check if more than one step is given and select execution mode
if [ ! -z $2 ] ; then
selection $@
if [ "${#START[@]}" -gt "1" ]; then
selection "${START[@]}"
else
continous $START
fi