Sequencer new option to open sequence config file when initialised using initSeqConfig

Sequences with exit in step_config, changed to return to support opening config file on first run
This commit is contained in:
2021-03-19 01:32:59 +01:00
parent ab1f9f761e
commit 8e63bbe7df
10 changed files with 41 additions and 30 deletions

View File

@@ -27,7 +27,7 @@ step_config() {
CONFIG=1
else
# End if no configuration file exists
[ $DRY -eq 0 ] && exit 1
[ $DRY -eq 0 ] && return 1
fi
[ $QUIET -ne 0 ] && aptOpt="-y"
}

View File

@@ -50,7 +50,7 @@ step_1() {
toolDownUrl="$1"
else
echoerr " [E] No image file provided for download"
exit -1
exit 1
fi
toolDownFile="/tmp/${toolDownUrl//*\//}"
@@ -129,7 +129,7 @@ step_10_alias() { ALIAS="setup"; }
step_10() {
if [ -z "$(ls /etc/default | grep raspi)" ] ; then
echoerr " [E] Not on a Raspberry pi"
return -1
return 1
fi
exe apt update
@@ -143,7 +143,7 @@ step_11() {
local localUsDefault="$localUs UTF-8"
if [ ! -f "$localesConfigLoc" ] ; then
echoerr " [E] Install packages locales first"
exit -1
exit 1
fi
exe sed -i "s/#[[:space:]]*\($localUsDefault\)/\1/" "$localesConfigLoc"

View File

@@ -20,7 +20,7 @@ step_config() {
if [ $? -eq 0 ] ; then
CONFIG=1
else
exit 1
[ $DRY -eq 0 ] && return 1
fi
toolSyslogTag="${SCRIPT_NAME}-$SEQ_PROFILE_NAME"
}
@@ -56,14 +56,14 @@ step_1() {
if [ -z $EBU_TARGET ] || [ -z $EBU_SOURCE ] ; then
echo " [I] Nothing to do. Check $SEQ_CONFIG_FILE"
return -1
return 1
fi
if [ ! -z "$1" ] && ( [ "$1" == "full" ] || [ "$1" == "incremental" ] ) ; then
dupArgs+=("$1")
elif [ ! -z "$1" ] ; then
echo " [W] $toolName command \"$1\" not recognized"
return -1
return 1
fi
echo " [I] Running backup profile [$SEQ_PROFILE_NAME]"
@@ -95,7 +95,7 @@ step_3() {
if [ -z $EBU_TARGET ] || [ -z $EBU_SOURCE ] ; then
echo " [I] Nothing to do. Check $SEQ_CONFIG_FILE"
return -1
return 1
fi
checkInstalled
@@ -135,7 +135,7 @@ step_5() {
if [ -z "$1" ] ; then
echoerr " [E] No target provided"
return -1
return 1
fi
local ebuLocalTarget="$1"
local ebuTarget="$EBU_TARGET"
@@ -167,7 +167,7 @@ step_7() {
dupCommand+="remove-all-inc-of-but-n-full $EBU_MAX_FULLS_WITH_INCRS "
else
if [ $QUIET -eq 0 ] ; then echoerr " [W] No purge option configured" ; fi
return -1
return 1
fi
checkInstalled
@@ -264,12 +264,6 @@ step_72() {
done
}
step_74_info() { echo "Open configuration file"; }
step_74_alias() { ALIAS='config'; }
step_74() {
exe vi "$SEQ_CONFIG_FILE"
}
step_100_info() { echo "Install $toolName $toolPpa"; }
step_100_alias() { ALIAS="install"; }
step_100() {
@@ -296,7 +290,7 @@ checkFileHead() {
local readChar
if [ ! -e "$1" ] ; then
echoerr " [E] File $1 not found"
return -1
return 1
fi
read -r -n ${#2} readChar < "$1"
if [ "$readChar" == "$2" ] ; then

View File

@@ -142,7 +142,7 @@ done"
step_11_info() { echo "Create systemd service for logging to syslog"; }
step_11() {
[ ! -f "$kodiSyslogLoc" ] && return -1
[ ! -f "$kodiSyslogLoc" ] && return 1
addConf -s "$kodiSyslogService" "$kodiSyslogServiceLoc"

View File

@@ -30,7 +30,7 @@ step_config() {
echoseq " Install: $LNMS_DIR"
echoseq " Backup: $LNMS_BU_DIR"
else
[ $DRY -eq 0 ] && exit 1
[ $DRY -eq 0 ] && return 1
fi
}

View File

@@ -34,7 +34,7 @@ step_config() {
echo " Domain: $MAS_DOMAIN"
elif [ $? -eq 1 ] ; then
# Config $CONFIG_FILE_NAME created. Needs modification first
exit 1
[ $DRY -eq 0 ] && return 1
fi
}

View File

@@ -542,8 +542,8 @@ toolScript() {
adminTokenCheck() {
if [ -z "$MATRIX_ACCESS" ] ; then
[ $QUIET -eq 0 ] && read -s -p "Please enter admin access tocken: " MATRIX_ACCESS
# return -1 if it is still empty
[ -z "$MATRIX_ACCESS" ] && return -1
# return 1 if it is still empty
[ -z "$MATRIX_ACCESS" ] && return 1
fi
return 0
}

View File

@@ -20,7 +20,7 @@ step_config() {
if [ $? -eq 0 ] ; then
CONFIG=1
else
exit 1
[ $DRY -eq 0 ] && return 1
fi
}

View File

@@ -23,7 +23,7 @@ step_config() {
if [ $? -eq 0 ] ; then
CONFIG=1
else
exit 1
[ $DRY -eq 0 ] && return 1
fi
toolConfigLoc=`eval echo "$TWXA_CONFIG_LOC"`
toolConfig="$toolConfigLoc/config_cache/$toolConfigName"

View File

@@ -8,7 +8,7 @@
## Version information
VERSION_REV=12
VERSION_MAJOR=1
VERSION_MAJOR=2
VERSION_MINOR=0
## Start of generic script part
@@ -24,6 +24,7 @@ STEP_RETURN=255
MAX_STEP=512
ALIAS=
CONTEXT_HELP=0
SEQ_CONFIG_EDIT=0
SEQ_CONFIG_NAME=".seqs"
SEQ_CONFIG_HOME="$HOME/$SEQ_CONFIG_NAME"
SEQ_CONFIG_FILE=
@@ -56,6 +57,7 @@ helpSequencer() {
Usage: ${0##*/} [OPTIONS] [STEP NUMBER(s) or ALIAS] [STEP ARGUMENTS]
[OPTIONS]
--config, -c : Open sequence configuration file (also sets -qq)
--dry-run, -d : Only print to console what would be done
! Attention - Sequence must support this
--help, -h : Display help
@@ -449,8 +451,8 @@ initSeqConfig() {
# Create config subdir in users home
if [ ! -e "$configDir/" ] ; then
echo -n " [I] Creating $(realpath $configDir)..."
exe mkdir -p "$configDir" && echo "Ok" || echo "Nok"
echoseq -n " [I] Creating $(realpath $configDir)..."
exe mkdir -p "$configDir" && echoseq "Ok" || echoseq "Nok"
exe chmod 700 "$configDir"
fi
@@ -483,8 +485,11 @@ initSeqConfig() {
exe chmod 600 "$configLoc"
if [ $sourceAlways -eq 0 ] ; then
echoerr " [W] Seq configuration created from template but not used"
echoerr " Please modify "$configLoc" first and restart sequence"
if [ $SEQ_CONFIG_EDIT -eq 0 ] ; then
echoerr " [W] Seq configuration created from template but not used"
echoerr " Please modify "$configLoc" first and restart sequence"
fi
SEQ_CONFIG_FILE="$configLoc"
return 1
else
echo " [W] Using seq configuration from template $configTemplate"
@@ -821,7 +826,7 @@ step_config() {
# CONFIG=1
#else
# # End if no configuration file exists
# [ \$DRY -eq 0 ] && exit 1
# [ \$DRY -eq 0 ] && return -1
#fi
}
@@ -1003,6 +1008,11 @@ main() {
# options check
for arg in "$@" ; do
case "$1" in
--config|-c) # open sequence configuration file
QUIET=2
SEQ_CONFIG_EDIT=1
shift
;;
--dry-run|-d) # shows what would be done
DRY=1
SEQUENCER_ARGS+=" $1"
@@ -1091,10 +1101,17 @@ main() {
# run configuration for seq only if available and if first step is valid
existsFunction step_config
if [ $? -eq 0 ] ; then
if [ $SEQ_CONFIG_EDIT -ne 0 ] ; then
step_config "${STEP_ARGS[@]}"
[ -w "$SEQ_CONFIG_FILE" ] && vi "$SEQ_CONFIG_FILE" \
|| echoerr " [E] No configuration file available"
exit 0
fi
checkStep "${START[0]}"
if [ $? -ne 0 ] ; then
if [ $QUIET -ne 2 ] ; then echo " [I] Configuring sequence (step_config) ..." ; fi
step_config "${STEP_ARGS[@]}"
[ $? -ne 0 ] && exit 1
else
return 1
fi