Bump sequencer revision to 9

New API function echoinfo

New option -s to execute only one step

Step argruments are also passed to step info function
This commit is contained in:
2019-12-23 23:13:11 +01:00
parent f90e95461e
commit ef572f9d7e

View File

@@ -2,11 +2,12 @@
## Sequencer script is doing nothing on its own. It is included by a squence script ## Sequencer script is doing nothing on its own. It is included by a squence script
## which uses the sequencer.sh to provide sequencial operations with or without ## which uses the sequencer.sh to provide sequencial operations with or without
## user interaction (see seqTemplate.sh) ## user interaction (see generated template which can be generated by calling this
## script directly)
## Version information ## Version information
VERSION_REV=8 VERSION_REV=9
VERSION_MAJOR=0 VERSION_MAJOR=0
VERSION_MINOR=0 VERSION_MINOR=0
@@ -15,6 +16,7 @@ VERSION_MINOR=0
QUIET=0 QUIET=0
DRY=0 DRY=0
VERBOSE=0 VERBOSE=0
SINGLE=0
ERNO=0 ERNO=0
STEP_ARGS= STEP_ARGS=
MAX_STEP=512 MAX_STEP=512
@@ -34,6 +36,8 @@ helpSequencer() {
echo " (e.g. exe,addconf,echerr,...)" echo " (e.g. exe,addconf,echerr,...)"
echo " --quiet, -q : Don't ask for permission to execute steps" echo " --quiet, -q : Don't ask for permission to execute steps"
echo " If called without starting step number, only this help is shown" echo " If called without starting step number, only this help is shown"
echo " --single, -s : Execute only one step"
echo " If more than one step is requested, only the first will be executed"
echo " --verbose, -v : Verbose output (use exe() function to call shell commands in seqs)" echo " --verbose, -v : Verbose output (use exe() function to call shell commands in seqs)"
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"
@@ -42,11 +46,10 @@ helpSequencer() {
echo " No STEP or ALIAS : assume 1 as starting point" echo " No STEP or ALIAS : assume 1 as starting point"
echo " Single STEP or ALIAS : starting point of sequential process" echo " Single STEP or ALIAS : starting point of sequential 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 " (e.g. $0 \"2 4 12\")"
echo " ( e.g. only execute step 4: $0 \"4 0\" )"
echo " multiple steps need to be given as string" echo " multiple steps need to be given as string"
echo " [STEP ARGUMENTS]" echo " [STEP ARGUMENTS]"
echo " * : Arguments will be passed to selected steps as:" echo " * : Arguments will be passed to selected steps and step infos as:"
echo " \$2 ..." echo " \$2 ..."
echo " \$1 is always the step number" echo " \$1 is always the step number"
} }
@@ -88,10 +91,10 @@ helpApi() {
echo " -f : <SOURCE> is a file" echo " -f : <SOURCE> is a file"
echo " <SOURCE>" echo " <SOURCE>"
echo " Text or file (-f) to create or added to <DESTINATION FILE>" echo " Text or file (-f) to create or added to <DESTINATION FILE>"
echo " <CONFIGFILE>" echo " <DESTINATION FILE>"
echo " Target file to be created or modified." echo " Target file to be created or modified."
echo echo
echo " step <Step number or alias>" echo " step <STEP NUMBER OR ALIAS>"
echo " Executes a single step also by alias. Useful if step numbers get reorganized." echo " Executes a single step also by alias. Useful if step numbers get reorganized."
echo " dry-run is not applied in this function! The executed step is responsible." echo " dry-run is not applied in this function! The executed step is responsible."
echo echo
@@ -99,6 +102,10 @@ helpApi() {
echo " echo to stderr" echo " echo to stderr"
echo " [...] : all parameter are forwarded to echo" echo " [...] : all parameter are forwarded to echo"
echo echo
echo " echoinfo [...]"
echo " echo additional correctly indented line to step info"
echo " [...] : all parrameter are forwared to echo"
echo
echo " endCheckEmpty <VARIABLENAME> [DESCRIPTION]" echo " endCheckEmpty <VARIABLENAME> [DESCRIPTION]"
echo " exit 666 if variable is empty" echo " exit 666 if variable is empty"
echo " <VARIABLENAME> : Name used within eval" echo " <VARIABLENAME> : Name used within eval"
@@ -125,6 +132,11 @@ helpApi() {
# Echo to stderr # Echo to stderr
echoerr() { >&2 echo "$@"; } echoerr() { >&2 echo "$@"; }
# Echo additional line to info correctly indented
HELPINDENT=' : '
HELPINDENTAPPEND=' '
echoinfo() { printf '%s' "$HELPINDENTAPPEND"; echo "$@"; }
# endCheckEmpty <VariableName> [DESCRIPTION] # endCheckEmpty <VariableName> [DESCRIPTION]
# DESCRIPTION : Optional text for error # DESCRIPTION : Optional text for error
endCheckEmpty() { endCheckEmpty() {
@@ -367,7 +379,7 @@ execute() {
echo -en "\n [STEP $1] " echo -en "\n [STEP $1] "
existsFunction step_${1}_info existsFunction step_${1}_info
if [ $? -eq 0 ] ; then if [ $? -eq 0 ] ; then
step_${1}_info $1 step_${1}_info $1 "${STEP_ARGS[@]}"
else else
# Add newline if no info is given # Add newline if no info is given
echo echo
@@ -468,9 +480,9 @@ continous() {
done done
} }
# selection <Step Number List (separated by space)> # selection <STEP ARRAY>
# execute given step list # execute given step list
# e.g.: selection -q 1 4 12 # e.g.: selection -q (1, 4, 12)
selection() { selection() {
local step=0 local step=0
local array=("$@") local array=("$@")
@@ -598,7 +610,7 @@ displayHelp() {
if [ $? -eq 0 ] ; then if [ $? -eq 0 ] ; then
step_${i}_alias step_${i}_alias
echo " = $ALIAS" echo " = $ALIAS"
printf ' : ' printf '%s' "$HELPINDENT"
else else
echo -n " : " echo -n " : "
fi fi
@@ -676,6 +688,10 @@ main() {
QUIET=1 QUIET=1
shift shift
;; ;;
--single|-s) # execute only one step and stop
SINGLE=1
shift
;;
--verbose|-v) # set verbose flag --verbose|-v) # set verbose flag
VERBOSE=1 VERBOSE=1
shift shift
@@ -715,20 +731,17 @@ main() {
echoerr -e " [W] No sequence revision found. Trying anyway...\n"; echoerr -e " [W] No sequence revision found. Trying anyway...\n";
fi fi
# check for starting step
if [ $EMPTYCALL -ne 0 ] ; then
# 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 [ $EMPTYCALL -ne 0 ] && [ $QUIET -eq 1 ] ; then
exit 1; exit 1;
fi fi
fi
if [ $DRY -ne 0 ] && [ $QUIET -eq 0 ] ; then if [ $DRY -ne 0 ] && [ $QUIET -eq 0 ] ; then
echo echo
echo " [W] Dry run active." echo " [W] Dry run active."
echo " Printed commands may not be accurate (e.g. quotation incorrect)" echo " - Printed commands may not be accurate (e.g. quotation incorrect)"
echo " Sequence may ignore dry run" echo " - Sequence may ignore dry run"
read -p "Press enter to continue or Ctrl + c to abort" read -p "Press enter to continue or Ctrl + C to abort"
fi fi
parseAlias parseAlias
@@ -741,7 +754,9 @@ main() {
fi fi
# 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 [ "${#START[@]}" -gt "1" ]; then if [ $SINGLE -ne 0 ] ; then
selection "${START[0]}"
elif [ "${#START[@]}" -gt "1" ]; then
selection "${START[@]}" selection "${START[@]}"
else else
continous $START continous $START