WIP some more variable refactoring
This commit is contained in:
39
sequencer.sh
39
sequencer.sh
@@ -30,11 +30,14 @@ set -o pipefail
|
|||||||
readonly seq_invocation="$(printf '%q' "${0}")$( (($#)) && printf ' %q' "$@" || true)"
|
readonly seq_invocation="$(printf '%q' "${0}")$( (($#)) && printf ' %q' "$@" || true)"
|
||||||
readonly seq_template="seqTemplate.sh"
|
readonly seq_template="seqTemplate.sh"
|
||||||
|
|
||||||
|
readonly _seq_configDirName=".seqs"
|
||||||
|
_seq_configEdit=0
|
||||||
|
_seq_profileList=
|
||||||
|
_seq_stepReturn=255
|
||||||
seq_args=
|
seq_args=
|
||||||
seq_configFile= # Filled by initSeqConfig
|
seq_configFile= # Filled by initSeqConfig
|
||||||
seq_profileName=
|
seq_profileName=
|
||||||
_seq_profileList=
|
seq_configRoot="${HOME}/${_seq_configDirName}"
|
||||||
_seq_stepReturn=255
|
|
||||||
|
|
||||||
# May be overwritten by seq
|
# May be overwritten by seq
|
||||||
seq_configName="${seq_fileName}.cfg"
|
seq_configName="${seq_fileName}.cfg"
|
||||||
@@ -49,9 +52,6 @@ set -o pipefail
|
|||||||
sqr_args=
|
sqr_args=
|
||||||
sqr_missingConf=missingConf.log
|
sqr_missingConf=missingConf.log
|
||||||
|
|
||||||
_sqr_configEdit=0
|
|
||||||
readonly _sqr_configDirName=".seqs"
|
|
||||||
_sqr_configRoot="${HOME}/${_sqr_configDirName}"
|
|
||||||
_sqr_contextHelp=0
|
_sqr_contextHelp=0
|
||||||
_sqr_contextExe=0
|
_sqr_contextExe=0
|
||||||
_sqr_debug=0
|
_sqr_debug=0
|
||||||
@@ -244,7 +244,7 @@ USAGE_API
|
|||||||
USAGE_API
|
USAGE_API
|
||||||
echo -e "${col_green} initSeqConfig [OPTION] <NAME> [TEMPLATE]${col_off}"
|
echo -e "${col_green} initSeqConfig [OPTION] <NAME> [TEMPLATE]${col_off}"
|
||||||
cat <<USAGE_API
|
cat <<USAGE_API
|
||||||
Create a configuration file in ${_sqr_configRoot}/ and source it if already existent.
|
Create a configuration file in ${seq_configRoot}/ and source it if already existent.
|
||||||
[OPTION]
|
[OPTION]
|
||||||
-p : Use profiles
|
-p : Use profiles
|
||||||
-t : Source config also if created from template
|
-t : Source config also if created from template
|
||||||
@@ -1133,12 +1133,12 @@ listSteps() {
|
|||||||
# -q : only check for profile support
|
# -q : only check for profile support
|
||||||
listProfiles() {
|
listProfiles() {
|
||||||
local file=
|
local file=
|
||||||
if [[ ${_sqr_configDirName} == $(basename "${_sqr_configRoot}") ]] ; then
|
if [[ ${_seq_configDirName} == $(basename "${seq_configRoot}") ]] ; then
|
||||||
error "${seq_name} does not have configuration profiles"
|
error -e "${seq_name} does not have configuration profiles"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
[[ "${1:-}" == "-q" ]] && return 0
|
[[ "${1:-}" == "-q" ]] && return 0
|
||||||
for file in "${_sqr_configRoot}"/* ; do
|
for file in "${seq_configRoot}"/* ; do
|
||||||
file="$(basename -- "${file}")"
|
file="$(basename -- "${file}")"
|
||||||
[[ ${file%.*} =~ ^${1:-.*} ]] && printf '%s\n' "${file%.*}"
|
[[ ${file%.*} =~ ^${1:-.*} ]] && printf '%s\n' "${file%.*}"
|
||||||
done
|
done
|
||||||
@@ -1186,21 +1186,21 @@ initSeqConfig() {
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
local configLoc="$_sqr_configRoot/$1"
|
local configLoc="$seq_configRoot/$1"
|
||||||
if [[ $seqProfiles -ne 0 ]] ; then
|
if [[ $seqProfiles -ne 0 ]] ; then
|
||||||
[ -z "$seq_profileName" ] && seq_profileName=default
|
[ -z "$seq_profileName" ] && seq_profileName=default
|
||||||
configLoc="$_sqr_configRoot/$1/${seq_profileName}.cfg"
|
configLoc="$seq_configRoot/$1/${seq_profileName}.cfg"
|
||||||
fi
|
fi
|
||||||
configDir="$(dirname -- "$configLoc")"
|
configDir="$(dirname -- "$configLoc")"
|
||||||
local configTemplate="$2"
|
local configTemplate="$2"
|
||||||
|
|
||||||
# Don't create anything if only profiles should be listed
|
# Don't create anything if only profiles should be listed
|
||||||
if [ -n "${_seq_profileList}" ] ; then
|
if [ -n "${_seq_profileList}" ] ; then
|
||||||
_sqr_configRoot="$configDir"
|
seq_configRoot="$configDir"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
_sqr_configRoot="$configDir"
|
seq_configRoot="$configDir"
|
||||||
|
|
||||||
if [ -s "$configLoc" ] ; then
|
if [ -s "$configLoc" ] ; then
|
||||||
info "Using configuration file: $configLoc"
|
info "Using configuration file: $configLoc"
|
||||||
@@ -1241,7 +1241,7 @@ initSeqConfig() {
|
|||||||
endReturn -o $? "Failed to create configuration"
|
endReturn -o $? "Failed to create configuration"
|
||||||
|
|
||||||
if [ $sourceAlways -eq 0 ] ; then
|
if [ $sourceAlways -eq 0 ] ; then
|
||||||
if [ $_sqr_configEdit -eq 0 ] ; then
|
if [ $_seq_configEdit -eq 0 ] ; then
|
||||||
warning "Seq configuration created from template but not used"
|
warning "Seq configuration created from template but not used"
|
||||||
warning -a "Please modify \"$configLoc\" first"
|
warning -a "Please modify \"$configLoc\" first"
|
||||||
fi
|
fi
|
||||||
@@ -1444,7 +1444,7 @@ sqr::compatible() {
|
|||||||
# exclude older versions if needed
|
# exclude older versions if needed
|
||||||
if [ -n "${sqr_minVersion}" ] && [[ ${sqr_minVersion} -le 15 ]] ; then
|
if [ -n "${sqr_minVersion}" ] && [[ ${sqr_minVersion} -le 15 ]] ; then
|
||||||
error "Unsupported sequence revision (major changes in version 16)"
|
error "Unsupported sequence revision (major changes in version 16)"
|
||||||
error -a "(Use 'seqUpgrade.sh $(readlink -f -- $0)' for a basic upgrade)"
|
error -a "(Use 'sequpgrade.sh $(readlink -f -- $0)' for a basic upgrade)"
|
||||||
showVersion
|
showVersion
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
@@ -1478,7 +1478,7 @@ sqr::main() {
|
|||||||
startAll="-a"
|
startAll="-a"
|
||||||
shift ;;
|
shift ;;
|
||||||
--config|-c) # open sequence configuration file
|
--config|-c) # open sequence configuration file
|
||||||
_sqr_configEdit=1
|
_seq_configEdit=1
|
||||||
shift ;;
|
shift ;;
|
||||||
--debug)
|
--debug)
|
||||||
_sqr_debug="1"
|
_sqr_debug="1"
|
||||||
@@ -1531,6 +1531,7 @@ sqr::main() {
|
|||||||
shift ;;
|
shift ;;
|
||||||
--version) # version request
|
--version) # version request
|
||||||
showVersion
|
showVersion
|
||||||
|
LOG_LEVEL=0 # suppress finish message
|
||||||
exit 0 ;;
|
exit 0 ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
@@ -1544,7 +1545,7 @@ sqr::main() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Don't show help if only configuration should be edited
|
# Don't show help if only configuration should be edited
|
||||||
[ ${_sqr_configEdit} -ne 0 ] && [ -z "${1:-}" ] && LOG_LEVEL=1
|
[ ${_seq_configEdit} -ne 0 ] && [ -z "${1:-}" ] && LOG_LEVEL=1
|
||||||
|
|
||||||
if [ -z "${1:-}" ] && [ $quickStartOne -eq 0 ] ; then
|
if [ -z "${1:-}" ] && [ $quickStartOne -eq 0 ] ; then
|
||||||
if ! quiet && [[ ${LOG_LEVEL} -ge $log_info ]] ; then
|
if ! quiet && [[ ${LOG_LEVEL} -ge $log_info ]] ; then
|
||||||
@@ -1594,7 +1595,7 @@ sqr::main() {
|
|||||||
if exists -f seq_config ; then
|
if exists -f seq_config ; then
|
||||||
|
|
||||||
# Create/edit configuration file
|
# Create/edit configuration file
|
||||||
if [ $_sqr_configEdit -ne 0 ] ; then
|
if [ $_seq_configEdit -ne 0 ] ; then
|
||||||
# Suppress seq_config output for editing
|
# Suppress seq_config output for editing
|
||||||
quietSave=${LOG_LEVEL}
|
quietSave=${LOG_LEVEL}
|
||||||
LOG_LEVEL=0
|
LOG_LEVEL=0
|
||||||
@@ -1616,7 +1617,7 @@ sqr::main() {
|
|||||||
else
|
else
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
elif [ ${_sqr_configEdit} -ne 0 ] ; then
|
elif [ ${_seq_configEdit} -ne 0 ] ; then
|
||||||
error "Sequence does not have a configuration file"
|
error "Sequence does not have a configuration file"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
Reference in New Issue
Block a user