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