sequencer - possiblity to skip seq_config for a single step (step_xx_noconf=)
This commit is contained in:
100
sequencer.sh
100
sequencer.sh
@@ -41,6 +41,7 @@ set -o pipefail
|
||||
readonly seq_template="seqTemplate.sh"
|
||||
|
||||
readonly _seq_configDirName=".seqs"
|
||||
_seq_configured=0
|
||||
_seq_configEdit=0
|
||||
_seq_profileList=
|
||||
_seq_stepReturn=255
|
||||
@@ -154,6 +155,8 @@ The sequencer.sh build-in functions are available in all sequence functions:
|
||||
If optional seq_config is defined in the sequence, it will be called once before execution of steps.
|
||||
- step_[1-${_sqr_stepMax}]_info
|
||||
- step_[1-${_sqr_stepMax}]_alias
|
||||
- step_[1-${_sqr_stepMax}]_noconf=
|
||||
No need to call seq_config for this step.
|
||||
- step_[1-${_sqr_stepMax}]
|
||||
|
||||
sequencer.sh global variables:
|
||||
@@ -960,7 +963,8 @@ sqr::createTemplate() {
|
||||
|
||||
# sqr::stepOptions <STEP NUMBER> [PREFIX]
|
||||
sqr::stepOptions() {
|
||||
exists -f "step_${1:?}_options" && echo -n "${2:-}$(step_${1:?}_options)"
|
||||
exists -f "step_${1:?}_options" && echo -n "${2:-}$(step_"${1:?}"_options)"
|
||||
true
|
||||
}
|
||||
|
||||
# displayHelp [OPTIONS] [STEP NUMBER OR ALIAS]
|
||||
@@ -1188,8 +1192,8 @@ initSeqConfig() {
|
||||
|
||||
# Ask for config creation if not existent
|
||||
if ! quiet && ! dry ; then
|
||||
sqr::echo " [i] Configuration $configLoc missing"
|
||||
confirm "Create it now?" || return 3
|
||||
sqr::echo " [i] Configuration missing"
|
||||
confirm "Create ${configLoc} now?" || return 3
|
||||
fi
|
||||
|
||||
# Create config subdir in users home
|
||||
@@ -1276,16 +1280,16 @@ execute() {
|
||||
|
||||
# check if step function exists
|
||||
exists -f "step_${1:?}" || notFound=1
|
||||
if [ ${notFound} -eq 1 ] && [ ${noReport} -ne 1 ] ; then
|
||||
if (( notFound )) && (( ! noReport )) ; then
|
||||
error "Step ${1:-"-"} not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
# don't execute step functions which are not available
|
||||
if (( notFound )) ; then
|
||||
return 1
|
||||
fi
|
||||
(( notFound )) && return 1
|
||||
|
||||
# stop if seq_config fails
|
||||
sqr::seqConfig "${1}" || return $?
|
||||
|
||||
if ! quiet ; then
|
||||
exists -f "step_${1}_alias" && stepAlias=$("step_${1}_alias")
|
||||
@@ -1379,6 +1383,55 @@ selection() {
|
||||
return ${_seq_stepReturn}
|
||||
}
|
||||
|
||||
# sqr::seqConfigEdit
|
||||
sqr::seqConfigEdit() {
|
||||
# Suppress seq_config output for editing and allow it to fail
|
||||
local quietSave=${LOG_LEVEL}
|
||||
|
||||
exists -f seq_config || return 0
|
||||
|
||||
LOG_LEVEL=0
|
||||
seq_config "${seq_args[@]}" || true
|
||||
LOG_LEVEL=${quietSave}
|
||||
if [ -w "$seq_configFile" ]; then
|
||||
editor "$seq_configFile" || true
|
||||
else
|
||||
error "No configuration file available"
|
||||
fi
|
||||
}
|
||||
|
||||
# sqr::seqConfig [STEP NUMBER]
|
||||
# Handle calling of the seq_config() function
|
||||
sqr::seqConfig() {
|
||||
# Check existens
|
||||
if ! exists -f seq_config ; then
|
||||
if (( _seq_configEdit )) ; then
|
||||
error "Sequence does not have a configuration file"
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Create/edit configuration file
|
||||
(( _seq_configEdit )) && sqr::seqConfigEdit
|
||||
|
||||
# Stop here without step number
|
||||
[ -z "${1:-}" ] && return 1
|
||||
|
||||
# Only call once
|
||||
(( _seq_configured )) && return 0
|
||||
|
||||
local -n noconf="step_${1}_noconf"
|
||||
if checkStep "${1:-}" >/dev/null 2>&1 && [ -z "${noconf+x}" ] ; then
|
||||
_seq_configured=1
|
||||
if ! seq_config "${seq_args[@]}" ; then
|
||||
error "Configuring sequence failed"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
# exe <COMMAND>
|
||||
# Handle dry run and verbose output for commands without pipe and/or redirects
|
||||
exe() {
|
||||
@@ -1585,33 +1638,10 @@ sqr::main() {
|
||||
|
||||
sqr::parseAlias
|
||||
|
||||
# run configuration for sequence only if available and if first step is valid
|
||||
if exists -f seq_config ; then
|
||||
|
||||
# Create/edit configuration file
|
||||
if (( _seq_configEdit )) ; then
|
||||
# Suppress seq_config output for editing and allow it to fail
|
||||
quietSave=${LOG_LEVEL}
|
||||
LOG_LEVEL=0
|
||||
seq_config "${seq_args[@]}" || true
|
||||
LOG_LEVEL=${quietSave}
|
||||
if [ -w "$seq_configFile" ]; then
|
||||
exe editor "$seq_configFile"
|
||||
else
|
||||
error "No configuration file available"
|
||||
fi
|
||||
(( emptyCall )) && exit 0
|
||||
fi
|
||||
|
||||
if checkStep "${toStart[0]}" >/dev/null 2>&1 ; then
|
||||
if ! seq_config "${seq_args[@]}" ; then
|
||||
error "Configuring sequence failed"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
elif (( _seq_configEdit )) ; then
|
||||
error "Sequence does not have a configuration file"
|
||||
return 1
|
||||
# # Create/edit configuration file
|
||||
if (( emptyCall )) && (( _seq_configEdit )) ; then
|
||||
sqr::seqConfigEdit || true
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Check for profile support
|
||||
|
Reference in New Issue
Block a user