Rework step options handling

This commit is contained in:
2022-12-12 11:16:26 +01:00
parent 44ae559918
commit 1f431daa16
30 changed files with 120 additions and 120 deletions

View File

@@ -26,11 +26,11 @@ seq_config() {
}
step_1_info() {
echoinfoArgs "[ADDITIONAL_EXCLUDES...]"
echo "Backup root"
echoinfo "Essential excludes are provided in the configuration template."
echoinfo "($CONFIG_FILE_TEMPLATE)"
}
step_1_options() { echo "[ADDITIONAL_EXCLUDES...]"; }
step_1_alias() { echo "buroot"; }
step_1() {
local buTarget="/backup"

View File

@@ -5,7 +5,7 @@
sc_configLoc="./basics"
step_config() {
seq_config() {
# echo "Called once before executing steps."
# echo "e.g. to source a config file:"
# #. "$CONFIG_FILE"

View File

@@ -63,7 +63,6 @@ step_1() {
}
step_10_info() {
echoinfoArgs "[OPTIONS] [VERSION]"
echo "Install ${toolName}"
echoinfo " [OPTIONS]"
echoinfo " -l: (default) install composer.phar to the current directory"
@@ -71,6 +70,7 @@ step_10_info() {
echoinfo " [VERSION]"
echoinfo " Install this specific ${toolName} version"
}
step_10_options() { echo "[OPTIONS] [VERSION]"; }
step_10_alias() { echo "install"; }
step_10() {
shift

View File

@@ -107,10 +107,8 @@ step_12() {
addConf -s "$ipCron" "$ipCronLoc"
}
step_14_info() {
echoinfoArgs "[SOURCE_IP]"
echo "Setup ufw rules to allow upnp, optionally from a sepcific SOURCE_IP"
}
step_14_info() { echo "Setup ufw rules to allow upnp, optionally from a sepcific SOURCE_IP"; }
step_14_options() { echo "[SOURCE_IP]"; }
step_14_alias() { echo "ufw"; }
step_14() {
shift

View File

@@ -14,7 +14,6 @@ seq_config() {
step_20_info() {
shift
echoinfoArgs "[FRIENDICA ROOT]"
echo -n "Create a backup"
if [ $sq_config -ne 0 ] ; then
echo " at $FR_BACKUP"
@@ -22,6 +21,7 @@ step_20_info() {
echo
fi
}
step_20_options() { echo "[FRIENDICA ROOT]"; }
step_20_alias() { echo "backup"; }
step_20() {
shift

View File

@@ -215,7 +215,8 @@ step_30() {
exep cd "${LNMS_DIR}"/.. "&&" tar czf "${LNMS_BU_DIR}/$(date +%Y%m%d)_${toolName}_web.tar.gz" "$(basename "$LNMS_DIR")"
}
step_31_info() { echoinfoArgs "[daily|monthly(default)]"; echo "Backup ${toolName} database"; }
step_31_info() { echo "Backup ${toolName} database"; }
step_31_options() { echo "[daily|monthly(default)]"; }
step_31_alias() { echo "backupdb"; }
step_31() {
case "${2:-}" in

View File

@@ -46,10 +46,10 @@ step_1() {
}
step_3_info() {
echoinfoArgs "[MESSAGE] [MESSAGE] ..."
echo "Send message"
echoinfo "Each string ([MESSAGE]) is send as separate message"
}
step_3_options() { echo "[MESSAGE] [MESSAGE] ..."; }
step_3_alias() { echo "message"; }
step_3() {
shift

View File

@@ -189,9 +189,9 @@ step_12() {
}
step_14_info() {
echoinfoArgs "[IP]:8008"
echo "Show $toolName version"
}
step_14_options() { echo "[IP]:8008"; }
step_14_alias() { echo "version"; }
step_14() {
local synapseIP=localhost
@@ -204,11 +204,11 @@ step_14() {
}
step_16_info() {
echoinfoArgs "[OPTION] [IP]:8008"
echo "List all registered users"
echoinfo "[OPTION]"
echoinfo " -r : Raw json output"
}
step_16_options() { echo "[OPTION] [IP]:8008"; }
step_16_alias() { echo "listuser"; }
step_16() {
adminTokenCheck
@@ -244,10 +244,10 @@ step_18() {
step_20_info() {
shift
echoinfoArgs "[USER NAME]"
echo -n "Reset user password"
contextExe && echoinfo " for ${1:-}" || echo
}
step_20_options() { echo "[USER NAME]"; }
step_20_alias() { echo "resetpw"; }
step_20() {
shift
@@ -271,11 +271,11 @@ step_20() {
}
step_22_info() {
echoinfoArgs "[OPTION] [IP]:8008"
echo "List all rooms"
echoinfo "[OPTION]"
echoinfo " -r : Raw json output"
}
step_22_options() { echo "[OPTION] [IP]:8008"; }
step_22_alias() { echo "listrooms"; }
step_22() {
adminTokenCheck
@@ -305,11 +305,11 @@ step_22() {
}
step_24_info() {
echoinfoArgs "[OPTION] [ROOM ID] [IP]:8008"
echo "List all room members"
echoinfo "[OPTION]"
echoinfo " -r : Raw json output"
}
step_24_options() { echo "[OPTION] [ROOM ID] [IP]:8008"; }
step_24_alias() { echo "listmember"; }
step_24() {
adminTokenCheck
@@ -344,10 +344,10 @@ step_24() {
}
step_26_info() {
echoinfoArgs "[IP]:8008"
echo "Delete rooms without local users"
echoinfo " [IP] : default is localhost"
}
step_26_options() { echo "[IP]:8008"; }
step_26_alias() { echo "purge"; }
step_26() {
adminTokenCheck
@@ -373,10 +373,8 @@ step_26() {
}
step_28_info() {
echoinfoArgs "<ROOM ID> [IP]:8008"
echo "Delete room"
}
step_28_info() { echo "Delete room"; }
step_28_options() { echo "<ROOM ID> [IP]:8008"; }
step_28_alias() { echo "deleteroom"; }
step_28() {
adminTokenCheck
@@ -420,7 +418,8 @@ postDataDeleteRoom()
EOF
}
step_30_info() { echoinfoArgs "[DATABASE]"; echo "Debloat postgres"; echo; }
step_30_info() { echo "Debloat postgres"; echo; }
step_30_options() { echo "[DATABASE]"; }
step_30_alias() { echo "debloat"; }
step_30() {
shift

View File

@@ -128,12 +128,12 @@ step_12() {
step_30_info() {
echoinfoArgs "[OPTIONS]"
echo "Download go"
echoinfo " [OPTIONS]"
echoinfo " --arch, -a : armhf(default), arm64"
echoinfo " CPU architecture for downloading go sources"
}
step_30_options() { echo "[OPTIONS]"; }
step_30_alias() { echo "build"; }
step_30() {
shift

View File

@@ -121,12 +121,12 @@ save \"\"
databases 2"
step_10_info() {
echoinfoArgs "[OPTIONS]"
echo "Upgrade $toolName to ${toolVersion:-"latest Version"}"
echoinfo " [OPTIONS]"
echoinfo " super : update also supervisor configuration"
echoinfo " (manual redis password update may be needed)"
}
step_10_options() { echo "[OPTIONS]"; }
step_10_alias() { echo "upgrade"; }
step_10() {
shift # don't need the step number

View File

@@ -54,7 +54,6 @@ step_8() {
}
step_10_info() {
echoinfoArgs "[OPTIONS]"
echo "Create mysql database without specific characterset"
echoinfo " [OPTIONS]"
echoinfo " --charset,-c <utf8|utf8mb4> : character set and collate"
@@ -64,6 +63,7 @@ step_10_info() {
echoinfo " Manual password entry for non existing user"
echoinfo " --remote, -r : ip of allowed remote host"
}
step_10_options() { echo "[OPTIONS]"; }
step_10_alias() { echo "createdb"; }
step_10() {
local arg
@@ -110,13 +110,13 @@ step_10() {
}
step_11_info() {
echoinfoArgs "[OPTIONS]"
echo "Create mysql user"
echoinfo " [OPTIONS]"
echoinfo " --user, -u : user name"
echoinfo " with manual password entry for non existing user"
echoinfo " --remote, -r : ip of allowed remote host"
}
step_11_options() { echo "[OPTIONS]"; }
step_11_alias() { echo "createuser"; }
step_11() {
local arg
@@ -162,13 +162,13 @@ step_11() {
}
step_12_info() {
echoinfoArgs "[OPTIONS]"
echo "Grant privileges"
echoinfo " [OPTIONS]"
echoinfo " --database, -d : 'database name'.*"
echoinfo " --user, -u : user name"
echoinfo " --remote, -r : ip of allowed remote host"
}
step_12_options() { echo "[OPTIONS]"; }
step_12_alias() { echo "grant"; }
step_12() {
local arg
@@ -200,12 +200,12 @@ step_12() {
}
step_14_info() {
echoinfoArgs "[OPTIONS]"
echo "Revoke all granted privilegs"
echoinfo " [OPTIONS]"
echoinfo " --user, -u : user name"
echoinfo " --remote, -r : ip of allowed remote host"
}
step_14_options() { echo "[OPTIONS]"; }
step_14_alias() { echo "revokeall"; }
step_14() {
local arg
@@ -245,12 +245,12 @@ step_32() {
}
step_34_info() {
echoinfoArgs "[OPTIONS]"
echo "Show privileges"
echoinfo " [OPTIONS]"
echoinfo " --user, -u : user name"
echoinfo " --remote, -r : ip of allowed remote host"
}
step_34_options() { echo "[OPTIONS]"; }
step_34_alias() { echo "listprivileges"; }
step_34() {
local arg
@@ -272,10 +272,8 @@ step_34() {
exe mysql -u root -e 'SHOW GRANTS FOR '"'"$dbUser"'"'@'"'"$dbRemote"'"';'
}
step_36_info() {
echoinfoArgs "[DATABASE_NAME]"
echo "Size of database"
}
step_36_info() { echo "Size of database"; }
step_36_options() { echo "[DATABASE_NAME]"; }
step_36_alias() { echo "sizedb"; }
step_36() {
if [ -z "${2:-}" ]; then
@@ -289,10 +287,8 @@ step_36() {
fi
}
step_50_info() {
echoinfoArgs "<DATABASE NAME> <TARGET DIR>"
echo "Backup (dump) a mysql database"
}
step_50_info() { echo "Backup (dump) a mysql database"; }
step_50_options() { echo "<DATABASE NAME> <TARGET DIR>"; }
step_50_alias() { echo "backup"; }
step_50() {
shift # step number not used

View File

@@ -22,10 +22,8 @@ seq_config() {
localOcc=( sudo -u $sc_ncServerUser php "$(escpath "$sc_ncInstallDir/occ")" )
}
step_1_info() {
echoinfoArgs "[OCC ARGS]"
echo "Execute occ command"
}
step_1_info() { echo "Execute occ command"; }
step_1_options() { echo "[OCC ARGS]"; }
step_1_alias() { echo "occ"; }
step_1() {
shift
@@ -55,7 +53,8 @@ step_21() {
step occ app:update --all
}
step_102_info() { echoinfoArgs "<NC DATABASE> <IPV4 ADDRESS>"; echo "Delete IP from bruteforce table"; }
step_102_info() { echo "Delete IP from bruteforce table"; }
step_102_options() { echo "<NC DATABASE> <IPV4 ADDRESS>"; }
step_102_alias() { echo "bruteforceRemoveIP"; }
step_102() {
shift
@@ -85,7 +84,8 @@ step_102() {
endReturn -o $? "Error deleting ip $ip"
}
step_104_info() { echoinfoArgs "<USER>"; echo "Reset and rescan the music library in the background for one user"; }
step_104_info() { echo "Reset and rescan the music library in the background for one user"; }
step_104_options() { echo "<USER>"; }
step_104_alias() { echo "audioreset"; }
step_104() {
shift
@@ -101,7 +101,8 @@ step_104() {
exep "${localOcc[@]} audioplayer:scan -vvvv $ncUser >> /var/log/ncAudioRescan.log &"
}
step_106_info() { echoinfoArgs "<USER>"; echo "Scan the music library"; }
step_106_info() { echo "Scan the music library"; }
step_106_options() { echo "<USER>"; }
step_106_alias() { echo "audioscan"; }
step_106() {
shift

View File

@@ -95,11 +95,11 @@ step_4() {
}
step_5_info() {
echoinfoArgs "[SECRET]"
echo "Install/start onlyoffice docker container"
echoinfo "If [SECRET] is empty, user input will be available if not run --quiet."
echoinfo "$toolName will be run unsecured if no secret was provied."
}
step_5_options() { echo "[SECRET]"; }
step_5_alias() { echo "startoo"; }
step_5() {
local options=

View File

@@ -59,7 +59,8 @@ step_1() {
fi
}
step_3_info() { echoinfoArgs "[status|start|stop|restart]"; echo "Manage ${toolName} services"; }
step_3_info() { echo "Manage ${toolName} services"; }
step_3_options() { echo "[status|start|stop|restart]"; }
step_3_alias() { echo "service"; }
step_3() {
shift
@@ -200,12 +201,12 @@ step_18() {
}
step_20_info() {
echoinfoArgs "[reindex|optimize]"
echo "Manage document search index"
echoinfo " reindex - (default) create index from scratch"
echoinfo " optimize - updates index to increase search speed and"
echoinfo " ensures autocompletion"
}
step_20_options() { echo "[reindex|optimize]"; }
step_20_alias() { echo "reindex"; }
step_20() {
shift
@@ -236,7 +237,8 @@ step_22() {
exe sudo -Hu paperless python3 manage.py document_renamer
}
step_30_info() { echoinfoArgs "[--nostart]"; echo "Backup ${toolName}"; }
step_30_info() { echo "Backup ${toolName}"; }
step_30_options() { echo "[--nostart]"; }
step_30_alias() { echo "backup"; }
step_30() {
shift

View File

@@ -72,10 +72,8 @@ step_3(){
echo "$lPhp"
}
step_5_info() {
echoinfoArgs "[PHP_PACKAGE_NAME ...]"
echo "Install ${toolName:-'-'} packages prepending the correct version"
}
step_5_info() { echo "Install ${toolName:-'-'} packages prepending the correct version"; }
step_5_options() { echo "[PHP_PACKAGE_NAME ...]"; }
step_5_alias() { echo "add"; }
step_5() {
shift

View File

@@ -17,10 +17,8 @@ step_30() {
exep "cd \"${PIWI_DIR}\"/.. && tar czf \"${PIWI_BU_DIR}/\`date +%Y%m%d\`_${toolName}_web.tar.gz\" --exclude=\"${toolName}/network/*\" --exclude=\"${toolName}/_data/i/*\" \"$(basename "$PIWI_DIR")\""
}
step_31_info() {
echoinfoArgs "[daily|monthly(default)]"
echo "Backup ${toolName} database"
}
step_31_info() { echo "Backup ${toolName} database"; }
step_31_options() { echo "[daily|monthly(default)]"; }
step_31_alias() { echo "backupdb"; }
step_31() {
case "${2:-}" in

View File

@@ -138,7 +138,8 @@ fetchmailRsyslogLoc="/etc/rsyslog.d/30-fetchmail.conf"
fetchmailRsyslog="if \$programname == 'fetchmail' or \$programname == 'fetchmail-all' then $fetchmailLogLoc
& stop"
step_18_info() { echoinfoArgs "[NEW VERSION]"; echo "Check for updates"; }
step_18_info() { echo "Check for updates"; }
step_18_options() { echo "[NEW VERSION]"; }
step_18_alias() { echo "updatecheck"; }
step_18() {
shift
@@ -162,7 +163,6 @@ step_18() {
step_20_info() {
echoinfoArgs "[POSTFIXADMIN SRV ROOT]"
echo -n "Create a backup"
if [ $sq_config -ne 0 ] ; then
echo " at $PFA_BACKUP"
@@ -170,6 +170,7 @@ step_20_info() {
echo
fi
}
step_20_options() { echo "[POSTFIXADMIN SRV ROOT]"; }
step_20_alias() { echo "backup"; }
step_20() {
shift
@@ -196,7 +197,6 @@ step_20() {
}
step_22_info() {
echoinfoArgs "[CUSTOM VERSION]"
shift
if contextExe; then
echoinfo -n "Upgrade to version "
@@ -210,6 +210,7 @@ step_22_info() {
echo "Upgrade to latest or a custom version from github"
fi
}
step_22_options() { echo "[CUSTOM VERSION]"; }
step_22_alias() { echo "upgrade"; }
step_22() {
shift # don't need step number
@@ -309,10 +310,10 @@ step_23() {
}
step_100_info() {
echoinfoArgs "[OPTIONS]"
echo "Execute $toolName client script"
echoinfo "[OPTIONS] are passed on to $toolName-cli unmodified"
}
step_100_options() { echo "[OPTIONS]"; }
step_100_alias() { echo "cli"; }
step_100() {
shift

View File

@@ -51,7 +51,8 @@ step_2() {
exe su ${toolUser} -c "psql -c \"GRANT ALL PRIVILEGES ON DATABASE \"${postgresDb}\" to ${postgresUser};\""
}
step_4_info() { echoinfoArgs "[DATABASE]"; echo "Drop a postgres database"; }
step_4_info() { echo "Drop a postgres database"; }
step_4_options() { echo "[DATABASE]"; }
step_4_alias() { echo "dropdb"; }
step_4() {
shift
@@ -64,7 +65,8 @@ step_4() {
exe su ${toolUser} -c "psql -c \"DROP DATABASE ${dbname};\""
}
step_6_info() { echoinfoArgs "[DATABASE]"; echo "Size of a postgres database"; }
step_6_info() { echo "Size of a postgres database"; }
step_6_options() { echo "[DATABASE]"; }
step_6_alias() { echo "sizedb"; }
step_6() {
shift
@@ -84,7 +86,8 @@ step_8() {
exe su ${toolUser} -c "psql -c '\l'"
}
step_10_info() { echoinfoArgs "[DATABASE]"; echo "List all tables of a postgres database"; }
step_10_info() { echo "List all tables of a postgres database"; }
step_10_options() { echo "[DATABASE]"; }
step_10_alias() { echo "listtables"; }
step_10() {
shift
@@ -97,7 +100,8 @@ step_10() {
exe su ${toolUser} -c "psql -d $dbname -c \"\\dt\""
}
step_20_info() { echoinfoArgs "[DATABASE]"; echo "Backup ${toolName} database"; }
step_20_info() { echo "Backup ${toolName} database"; }
step_20_options() { echo "[DATABASE]"; }
step_20_alias() { echo "backupdb"; }
step_20() {
shift
@@ -137,9 +141,9 @@ step_22() {
step_24_info() {
local DELYEAR=$(($(date +%Y)-2))
echoinfoArgs "[DATABASE]"
echo "Clean all ${DELYEAR} backups of a database";
}
step_24_options() { echo "[DATABASE]"; }
step_24_alias() { echo "backupclean"; }
step_24() {
shift

View File

@@ -51,12 +51,12 @@ step_2() {
}
step_3_info() {
echoinfoArgs "[TARGET]"
echo "Install dependencies"
echoinfo " [TARGET] (default: raspi)"
echoinfo " raspi: Raspberry Pi OS"
echoinfo " debian: Debian"
}
step_3_options() { echo "[TARGET]"; }
step_3_alias() { echo "deps"; }
step_3() {
shift

View File

@@ -78,7 +78,6 @@ step_1_info() {
# Shift away args
shift; local lArgs=( "$@" ); evalArgs "${lArgs[@]}"; shift $?
echoinfoArgs "[OPTIONS] [SD CARD DEVICE] [HD DEVICE]"
echo "Download latest Raspberry Pi OS lite image $PIARCH"
if contextExe; then
echoinfo "Download URL: $PIDOWNURL"
@@ -87,6 +86,7 @@ step_1_info() {
echoinfo " -a, --arch : armhf (default), arm64"
fi
}
step_1_options() { echo "[OPTIONS] [SD CARD DEVICE] [HD DEVICE]"; }
step_1_alias() { echo "setup"; }
step_1() {
# Shift away args
@@ -112,11 +112,11 @@ step_2_info() {
# Shift away args
shift; local lArgs=( "$@" ); evalArgs "${lArgs[@]}"; shift $?
echoinfoArgs "[OPTIONS] [SD CARD DEVICE]"
echo "Write Raspberry Pi OS image to SD card"
echoinfo "This operation will delete all data previously on the SD card!"
contextExe && [ -n "${1:-}" ] && echoinfo " [SD CARD DEVICE]: $1"
}
step_2_options() { echo "[OPTIONS] [SD CARD DEVICE]"; }
step_2_alias() { echo "writesd"; }
step_2() {
# Shift away args
@@ -155,12 +155,12 @@ step_3_info() {
# Shift away args
shift; local lArgs=( "$@" ); evalArgs "${lArgs[@]}"; shift $?
echoinfoArgs "[SD CARD DEVICE]"
echo "Prepare SD for first run"
if contextExe; then
[ -n "${1:-}" ] && echoinfo " [SD CARD DEVICE]: $1"
fi
}
step_3_options() { echo "[SD CARD DEVICE]"; }
step_3() {
# Shift away args
shift; local lArgs=( "$@" ); evalArgs "${lArgs[@]}"; shift $?
@@ -219,13 +219,13 @@ step_4_info() {
# Shift away args
shift; local lArgs=( "$@" ); evalArgs "${lArgs[@]}"; shift $?
echoinfoArgs "[SD CARD DEVICE] [HD DEVICE]"
echo "Prepare SD card to boot from hard disk"
if contextExe; then
[ -n "${1:-}" ] && echoinfo " [SD CARD DEVICE]: $1"
[ -n "${2:-}" ] && echoinfo " [HD DEVICE]: $2"
fi
}
step_4_options() { echo "[SD CARD DEVICE] [HD DEVICE]"; }
step_4_alias() { echo "hdboot"; }
step_4() {
# Shift away args
@@ -290,7 +290,6 @@ step_5_info() {
# Shift away args
shift; local lArgs=( "$@" ); evalArgs "${lArgs[@]}"; shift $?
echoinfoArgs "[SD CARD DEVICE] [HD DEVICE]"
echo "Prepare HD for boot (TODO)"
if contextExe; then
@@ -298,6 +297,7 @@ step_5_info() {
[ -n "${2:-}" ] && echoinfo " [HD DEVICE]: $2"
fi
}
step_5_options() { echo "[SD CARD DEVICE] [HD DEVICE]"; }
step_5() {
# Shift away args
shift; local lArgs=( "$@" ); evalArgs "${lArgs[@]}"; shift $?
@@ -452,7 +452,8 @@ step_20() {
}
rpiSwapFile="/var/swap"
step_22_info() { echoinfoArgs "[SD CARD DEVICE]"; echo "Resize second SD card partition"; }
step_22_info() { echo "Resize second SD card partition"; }
step_22_options() { echo "[SD CARD DEVICE]"; }
step_22_alias() { echo "resizesd"; }
step_22() {
shift
@@ -481,11 +482,11 @@ step_22() {
}
step_24_info() {
echoinfoArgs "[OPTION]"
echo "Turn off power LED"
echoinfo " [OPTION]"
echoinfo " -p : Turn off permanentely (/etc/rc.local)"
}
step_24_options() { echo "[OPTION]"; }
step_24_alias() { echo "disable_powerled"; }
step_24() {
exep "${ledOffCmd}"

View File

@@ -65,11 +65,11 @@ NOTES_EOF
}
step_10_info() {
echoinfoArgs "[CLI COMMAND]"
echo "Execute redis-cli commands"
echoinfo " [CLI COMMAND]"
echoinfo " e.g. info"
}
step_10_options() { echo "[CLI COMMAND]"; }
step_10_alias() { echo "cli"; }
step_10() {
shift

View File

@@ -156,10 +156,8 @@ step_20() {
exe tar czf "$wwwBackup" $(basename "$RC_LOC")
}
step_22_info() {
echoinfoArgs "[CUSTOM VERSION]"
echo "Upgrade installation to \"latest\" from github if [CUSTOM_VERSION] is empty"
}
step_22_info() { echo "Upgrade installation to \"latest\" from github if [CUSTOM_VERSION] is empty"; }
step_22_options() { echo "[CUSTOM VERSION]"; }
step_22_alias() { echo "upgrade"; }
step_22() {
shift # don't need step number

View File

@@ -239,7 +239,8 @@ step_50() {
NOTES_END
}
step_60_info() { echoinfoArgs "[VERSION]"; echo "Build and install from source"; }
step_60_info() { echo "Build and install from source"; }
step_60_options() { echo "[VERSION]"; }
step_60_alias() { echo "buildlocal"; }
step_60() {
shift
@@ -298,13 +299,15 @@ step_62() {
exe systemctl daemon-reload
}
step_64_info() { echoinfoArgs "[VERSION]"; echo "Install build dependencies for .deb build"; }
step_64_info() { echo "Install build dependencies for .deb build"; }
step_64_options() { echo "[VERSION]"; }
step_64_alias() { echo "builddeb"; }
step_64() {
exe apt install cmake ragel pkg-config libglib2.0-dev libsqlite3-dev libicu-dev libmagic-dev libssl-dev libsodium-dev redis libjemalloc-dev libcurl4-openssl-dev liblua5.1-0-dev libunwind-dev liblua5.1-0-dev
}
step_65_info() { echoinfoArgs "[VERSION]"; echo "Build .deb from source"; }
step_65_info() { echo "Build .deb from source"; }
step_65_options() { echo "[VERSION]"; }
step_65() {
shift
local version="${1:-"${knownVersion}"}"

View File

@@ -63,10 +63,8 @@ step_14() {
}
CONFIG_RNGD_DEST="/etc/rsyslog.d/$(basename $CONFIG_RNGD)"
step_16_info() {
echoinfoArgs "<REMOTE_IP:PORT>"
echo "Send syslog messages to remote syslog server"
}
step_16_info() { echo "Send syslog messages to remote syslog server"; }
step_16_options() { echo "<REMOTE_IP:PORT>"; }
step_16_alias() { echo "remote"; }
step_16() {
local rex='^[0-9\.]+\:[0-9]+$'

View File

@@ -28,10 +28,10 @@ step_1() {
}
step_2_info() {
echoinfoArgs "[-s]"
echo "Setup snmp v3 access"
echoinfo " -s : Stop after creating authentication entry"
}
step_2_options() { echo "[-s]"; }
step_2_alias() { echo "v3access"; }
step_2() {
#
@@ -101,10 +101,10 @@ step_2() {
v3AuthLoc="/var/lib/snmp/snmpd.conf"
step_5_info() {
echoinfoArgs "[INTERFACE]"
echo "Add ufw rules for port 161 udp"
echoinfo " [INTERFACE] (default: eth0)"
}
step_5_options() { echo "[INTERFACE]"; }
step_5_alias() { echo "ufw"; }
step_5() {
shift

View File

@@ -27,11 +27,11 @@ step_3() {
}
step_5_info() {
echoinfoArgs "[OPTIONS] <USER@HOST> [PORT]"
echo "Send key to remote host"
echoinfo "[OPTIONS]"
echoinfo " -4 : Force Ipv4"
}
step_5_options() { echo "[OPTIONS] <USER@HOST> [PORT]"; }
step_5_alias() { echo "sendkey"; }
step_5() {
shift
@@ -71,10 +71,10 @@ step_5() {
}
step_10_info() {
echoinfoArgs "<CMDLIST> [USER:HOST] [PORT]"
echo "Send command(ssh)/file(scp) list to remote(s)"
echoinfo "[USER:HOST] and [PORT] are overwritten by \"host\" command from <CMDLIST>"
}
step_10_options() { echo "<CMDLIST> [USER:HOST] [PORT]"; }
step_10_alias() { echo "sendlist"; }
step_10() {
shift

View File

@@ -119,7 +119,8 @@ step_50() {
exe "$toolRemote" -l
}
step_52_info() { echoinfoArgs "<TORRENT ID>"; echo "List information about a torrent"; }
step_52_info() { echo "List information about a torrent"; }
step_52_options() { echo "<TORRENT ID>"; }
step_52_alias() { echo "info"; }
step_52() {
shift

View File

@@ -6,7 +6,7 @@ toolDeps=$toolName
sq_aptOpt=
#sq_config=0
step_config() {
seq_config() {
#if initSeqConfig "${seq_configName:?}" "${seq_configTemplate:?} ; then
# sq_config=1
#else
@@ -36,6 +36,11 @@ step_2() {
exe ufw enable
}
step_3_info() { echo "Info"; }
#step_3_alias() { echo "alias"; }
step_3_options() { echo "[]"; }
step_3() { : ; }
step_20_info() { echo "Enable mail server essentials"; }
step_20_alias() { echo "mailserver"; }
step_20() {
@@ -47,7 +52,8 @@ step_20() {
exe ufw allow 4190/tcp comment 'Managesieve'
}
step_22_info() { echoinfoArgs "[IP]"; echo "Deny multicast from gateway"; }
step_22_info() { echo "Deny multicast from gateway"; }
step_22_options() { echo "[IP]"; }
step_22_alias() { echo "multicast"; }
step_22() {
shift
@@ -61,12 +67,12 @@ step_22() {
}
step_24_info() {
echoinfoArgs "<FILE SERVER IP|RANGE> [PORT]"
echo "Allow cifs mounts on eth0"
echoinfo " [PORT] (default 445)"
echoinfo " 139 : Cifs version 1.0"
echoinfo " 445 : Cifs version 2.0+"
}
step_24_options() { echo "<FILE SERVER IP|RANGE> [PORT]"; }
step_24_alias() { echo "cifs"; }
step_24() {
shift

View File

@@ -77,12 +77,6 @@ set -o pipefail
readonly _sqr_term
_sqr_colorAlways=0
## Terminal position
_sqr_savePosAlias= ;[ -t 1 ] && _sqr_savePosAlias='\033[1A\033[1C\033[s\033[1B\033[1C'
_sqr_savePosExe= ;[ -t 1 ] && _sqr_savePosExe='\033[s'
_sqr_savePos= ;[ -t 1 ] && _sqr_savePos='\033[3D\033[s\033[3C'
_sqr_restorePos= ;[ -t 1 ] && _sqr_restorePos='\033[u'
## Terminal colors
col_black='\033[0;30m'
col_darkgrey='\033[1;30m'
@@ -157,7 +151,7 @@ sequencer.sh API
The sequencer.sh build-in functions are available in all sequence functions:
- seq_config
If optional step_config is defined in the sequence, it will be called once before execution of steps.
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}]
@@ -526,17 +520,6 @@ USAGE_API
printf '%s' "$_sqr_indentExe"; echo "$@"
fi
}
# Echo info about step arguments
# Needs to be called first in _info() function
echoinfoArgs() {
echo -e "${_sqr_restorePos}$*"
if [ $_sqr_contextExe -ne 0 ]; then
printf '%s' "$_sqr_indentExe"
else
printf '%s' "$_sqr_indentHelp"
fi
}
}
## Traps
@@ -955,7 +938,7 @@ step() {
# Parse alias functions "step_[STEP NUBER]_alias" to create
# back reference variable of schema:
# alias_[ALIAS]=[STEP NUMBER]
parseAlias() {
sqr::parseAlias() {
sqr::debugPause
local i
for ((i=1; i<=_sqr_stepMax; i++)); do
@@ -969,12 +952,17 @@ parseAlias() {
}
# Creating a minimal seq (step definition) template
createTemplate() {
sqr::createTemplate() {
[ -f "${seq_template}" ] && return 1
exe cp "${sqr_origin}/${seq_template}" "${seq_template}"
}
# sqr::stepOptions <STEP NUMBER> [PREFIX]
sqr::stepOptions() {
exists -f "step_${1:?}_options" && echo -n "${2:-}$(step_${1:?}_options)"
}
# displayHelp [OPTIONS] [STEP NUMBER OR ALIAS]
# [OPTIONS]
# -t : Ask for template creation
@@ -1019,7 +1007,7 @@ displayHelp() {
# check if help is requested for a single step
if [ -n "${1:-}" ]; then
parseAlias
sqr::parseAlias
loopStart="$(checkStep "${1}")"
fi
@@ -1036,7 +1024,7 @@ displayHelp() {
printf ' %s\n\n' "Please create a sequence script first."
if (( createTemplate )) ; then
if confirm " Create a template now?" ; then
if createTemplate ; then
if sqr::createTemplate ; then
printf '\n %s\n' "${seq_template} created."
else
printf '\n %s\n' "${seq_template} exists...Nothing to do!"
@@ -1072,11 +1060,12 @@ displayHelp() {
# Display alias if exists
if exists -f "step_${i}_alias" ; then
echo -en " = $(col orange)$("step_${i}_alias")$(col off)${_sqr_savePosAlias}"
echo -en " = $(col orange)$("step_${i}_alias")$(col off)$(sqr::stepOptions "${i}" ' ')"
# Newline only if step info() exists
exists -f "step_${i}_info" && printf '\n%s' "$_sqr_indentHelp"
exists -f "step_${i}_info" && printf '\n%s' "${_sqr_indentHelp}"
else
echo -en " : ${_sqr_savePos}"
echo -en " : $(sqr::stepOptions "${i}")"
exists -f "step_${i}_options" && printf '\n%s' "${_sqr_indentAppendHelp}"
fi
# Display step help only if info function exists
@@ -1302,11 +1291,12 @@ execute() {
exists -f "step_${1}_alias" && stepAlias=$("step_${1}_alias")
printf '\n [%3d] ' "${1}"
if [ -n "${stepAlias}" ]; then
echo -en "$(col orange)${stepAlias}$(col off)${_sqr_savePosAlias}"
echo -en "$(col orange)${stepAlias}$(col off)$(sqr::stepOptions "${1}" ' ')"
# Only add newline if step info() available
exists -f "step_${1}_info" && printf '\n%s' "${_sqr_indentExe}"
else
echo -en "${_sqr_savePosExe}"
echo -en "$(sqr::stepOptions "${1}")"
exists -f "step_${1}_options" && printf '\n%s' "${_sqr_indentExe}"
fi
if exists -f "step_${1}_info" ; then
@@ -1593,7 +1583,7 @@ sqr::main() {
## Fall back to error message
[ -z "${_sqr_editor}" ] && _sqr_editor="sqr::noEditor"
parseAlias
sqr::parseAlias
# run configuration for sequence only if available and if first step is valid
if exists -f seq_config ; then

View File

@@ -82,6 +82,11 @@ makechanges() {
exe sed ${inplace} 's/SEQ_CONFIG_FILE/seq_configFile/'${sedprint} "${file}"
exe sed ${inplace} 's/SEQ_PROFILE_NAME/seq_profileName/'${sedprint} "${file}"
exe sed ${inplace} 's/^VERSION_SEQREV.*/readonly sqr_minVersion=16/'${sedprint} "${file}"
exe sed ${inplace} 's/echoinfoArgs[[:space:]]\+"\([^"]\+\)"\([^;]\|$\)/# todo: manual intervention\nstep_xx_options() { echo "\1"; }/'${sedprint} "${file}"
exe sed ${inplace} \
's/^\(step_\([0-9]\+\)_info().*\)echoinfoArgs[[:space:]]\+"\([^"]\+\)"\;[[:space:]]*\(.*\)/\1\4\nstep_\2_options() { echo "\3"; }/'${sedprint}\
"${file}"
done
}