Improve help output with latest changes from sequencer

This commit is contained in:
2022-01-23 23:06:46 +01:00
parent e641373a57
commit 6dd40bc6c2
12 changed files with 80 additions and 83 deletions

View File

@@ -78,8 +78,8 @@ step_4() {
} }
step_6_info() { step_6_info() {
echo "Create postfixadmin fetchmail systemd timer and reduce syslos entries" echo "Create postfixadmin fetchmail systemd timer and reduce syslog entries"
echoinfo "Needed to started after mysql service" echoinfo "Needs to start after the mysql service"
} }
step_6_alias() { ALIAS="timer"; } step_6_alias() { ALIAS="timer"; }
step_6() { step_6() {
@@ -143,7 +143,7 @@ fetchmailRsyslogLoc="/etc/rsyslog.d/30-fetchmail.conf"
fetchmailRsyslog="if \$programname == 'fetchmail' or \$programname == 'fetchmail-all' then $fetchmailLogLoc fetchmailRsyslog="if \$programname == 'fetchmail' or \$programname == 'fetchmail-all' then $fetchmailLogLoc
& stop" & stop"
step_18_info() { echo "Check for updates"; } step_18_info() { echoinfoArgs "[NEW VERSION]"; echo "Check for updates"; }
step_18_alias() { ALIAS="updatecheck"; } step_18_alias() { ALIAS="updatecheck"; }
step_18() { step_18() {
shift shift
@@ -167,7 +167,8 @@ step_18() {
step_20_info() { step_20_info() {
echo -n "Create a backup [POSTFIXADMIN SRV ROOT]" echoinfoArgs "[POSTFIXADMIN SRV ROOT]"
echo -n "Create a backup"
if [ $CONFIG -ne 0 ] ; then if [ $CONFIG -ne 0 ] ; then
echo " at $PFA_BACKUP" echo " at $PFA_BACKUP"
else else
@@ -200,16 +201,18 @@ step_20() {
} }
step_22_info() { step_22_info() {
echoinfoArgs "[CUSTOM VERSION]"
shift shift
if [ -z $1 ] ; then if [ $CONTEXT_EXE -ne 0 ]; then
echo -n "Get latest version from github" echoinfo -n "Upgrade to version "
if [ $CONTEXT_HELP -eq 0 ] ; then if [ -z "$1" ]; then
echo ": $(curl --silent "$latestUrl" | grep -Po '"tag_name": "postfixadmin-\K.*?(?=")')" echo -n "$(curl --silent "$latestUrl" | grep -Po '"tag_name": "postfixadmin-\K.*?(?=")')"
else else
echo " [CUSTOM VERSION]" echo -n "$1"
fi fi
echo " from github"
else else
echo "Get version $1 from github" echo "Upgrade to latest or a custom version from github"
fi fi
} }
step_22_alias() { ALIAS="upgrade"; } step_22_alias() { ALIAS="upgrade"; }
@@ -311,7 +314,8 @@ step_23() {
} }
step_100_info() { step_100_info() {
echo "$toolName client script [OPTIONS]" echoinfoArgs "[OPTIONS]"
echo "Execute $toolName client script"
echoinfo "[OPTIONS] are passed on to $toolName-cli unmodified" echoinfo "[OPTIONS] are passed on to $toolName-cli unmodified"
} }
step_100_alias() { ALIAS="cli"; } step_100_alias() { ALIAS="cli"; }
@@ -320,5 +324,5 @@ step_100() {
exe ${PFA_SRV_LOC}/scripts/$toolName-cli $@ exe ${PFA_SRV_LOC}/scripts/$toolName-cli $@
} }
VERSION_SEQREV=11 VERSION_SEQREV=14
. /usr/local/bin/sequencer.sh . /usr/local/bin/sequencer.sh

View File

@@ -51,7 +51,7 @@ step_2() {
exe su ${toolUser} -c "psql -c \"GRANT ALL PRIVILEGES ON DATABASE \"${postgresDb}\" to ${postgresUser};\"" exe su ${toolUser} -c "psql -c \"GRANT ALL PRIVILEGES ON DATABASE \"${postgresDb}\" to ${postgresUser};\""
} }
step_4_info() { echo "Drop postgres [DATABASE]"; } step_4_info() { echoinfoArgs "[DATABASE]"; echo "Drop a postgres database"; }
step_4_alias() { ALIAS="dropdb"; } step_4_alias() { ALIAS="dropdb"; }
step_4() { step_4() {
shift shift
@@ -64,7 +64,7 @@ step_4() {
exe su ${toolUser} -c "psql -c \"DROP DATABASE ${dbname};\"" exe su ${toolUser} -c "psql -c \"DROP DATABASE ${dbname};\""
} }
step_6_info() { echo "Size of postgres [DATABASE]"; } step_6_info() { echoinfoArgs "[DATABASE]"; echo "Size of a postgres database"; }
step_6_alias() { ALIAS="sizedb"; } step_6_alias() { ALIAS="sizedb"; }
step_6() { step_6() {
shift shift
@@ -84,7 +84,7 @@ step_8() {
exe su ${toolUser} -c "psql -c '\l'" exe su ${toolUser} -c "psql -c '\l'"
} }
step_10_info() { echo "List all tables of postgres [DATABASE]"; } step_10_info() { echoinfoArgs "[DATABASE]"; echo "List all tables of a postgres database"; }
step_10_alias() { ALIAS="listtables"; } step_10_alias() { ALIAS="listtables"; }
step_10() { step_10() {
shift shift
@@ -97,7 +97,7 @@ step_10() {
exe su ${toolUser} -c "psql -d $dbname -c \"\\dt\"" exe su ${toolUser} -c "psql -d $dbname -c \"\\dt\""
} }
step_20_info() { echo "Backup ${toolName} [DATABASE]"; } step_20_info() { echoinfoArgs "[DATABASE]"; echo "Backup ${toolName} database"; }
step_20_alias() { ALIAS="backupdb"; } step_20_alias() { ALIAS="backupdb"; }
step_20() { step_20() {
shift shift
@@ -137,7 +137,8 @@ step_22() {
step_24_info() { step_24_info() {
local DELYEAR=$(($(date +%Y)-2)) local DELYEAR=$(($(date +%Y)-2))
echo "Clean all ${DELYEAR} backups of [DATABASE]"; echoinfoArgs "[DATABASE]"
echo "Clean all ${DELYEAR} backups of a database";
} }
step_24_alias() { ALIAS="backupclean"; } step_24_alias() { ALIAS="backupclean"; }
step_24() { step_24() {
@@ -168,5 +169,5 @@ readDatabaseInfos() {
echo echo
} }
VERSION_SEQREV=11 VERSION_SEQREV=14
. /usr/local/bin/sequencer.sh . /usr/local/bin/sequencer.sh

View File

@@ -51,7 +51,8 @@ step_2() {
} }
step_3_info() { step_3_info() {
echo "Install dependencies for [TARGET]" echoinfoArgs "[TARGET]"
echo "Install dependencies"
echoinfo " [TARGET] (default: raspi)" echoinfo " [TARGET] (default: raspi)"
echoinfo " raspi: Raspberry Pi OS" echoinfo " raspi: Raspberry Pi OS"
echoinfo " debian: Debian" echoinfo " debian: Debian"
@@ -133,5 +134,5 @@ step_10() {
echo " Do so manually with: service $toolName start" echo " Do so manually with: service $toolName start"
} }
VERSION_SEQREV=12 VERSION_SEQREV=14
. /usr/local/bin/sequencer.sh . /usr/local/bin/sequencer.sh

View File

@@ -65,7 +65,8 @@ NOTES_EOF
} }
step_10_info() { step_10_info() {
echo "Execute redis-cli commands [CLI COMMAND]" echoinfoArgs "[CLI COMMAND]"
echo "Execute redis-cli commands"
echoinfo " [CLI COMMAND]" echoinfo " [CLI COMMAND]"
echoinfo " e.g. info" echoinfo " e.g. info"
} }
@@ -81,5 +82,5 @@ step_10() {
fi fi
} }
VERSION_SEQREV=12 VERSION_SEQREV=14
. /usr/local/bin/sequencer.sh . /usr/local/bin/sequencer.sh

View File

@@ -74,10 +74,10 @@ step_3() {
exe read -p "Copy the lines above and press Enter to continue." exe read -p "Copy the lines above and press Enter to continue."
exe vi "$RC_LOC/composer.json" exe vi "$RC_LOC/composer.json"
step postupgrade step postupgrade
exit 0
echo " [I] Generating mysql database $RC_DATABASE" echo " [I] Generating mysql database $RC_DATABASE"
echo echo
exe $WDIR/mysql.sh createdb_utf8mb4 exe $WDIR/mysql.sh createdb -c utf8mb4
echo echo
echo " [I] Now visit: http://url-to-roundcube/installer/" echo " [I] Now visit: http://url-to-roundcube/installer/"
@@ -165,12 +165,8 @@ step_20() {
} }
step_22_info() { step_22_info() {
shift echoinfoArgs "[CUSTOM VERSION]"
if [ -z $1 ] ; then echo "Upgrade installation to \"latest\" from github if [CUSTOM_VERSION] is empty"
echo "Upgrade installation to latest version from github [CUSTOM VERSION]"
else
echo "Upgrade installation to $1 from github"
fi
} }
step_22_alias() { ALIAS="upgrade"; } step_22_alias() { ALIAS="upgrade"; }
step_22() { step_22() {
@@ -258,5 +254,5 @@ downloadLatest() {
tempDown="/tmp/roundcube" tempDown="/tmp/roundcube"
tempLoc="$tempDown/rc.tar.gz" tempLoc="$tempDown/rc.tar.gz"
VERSION_SEQREV=10 VERSION_SEQREV=14
. /usr/local/bin/sequencer.sh . /usr/local/bin/sequencer.sh

View File

@@ -63,7 +63,10 @@ step_14() {
} }
CONFIG_RNGD_DEST="/etc/rsyslog.d/$(basename $CONFIG_RNGD)" CONFIG_RNGD_DEST="/etc/rsyslog.d/$(basename $CONFIG_RNGD)"
step_16_info() { echo "Send syslog messages to remote syslog server <REMOTE_IP:PORT>"; } step_16_info() {
echoinfoArgs "<REMOTE_IP:PORT>"
echo "Send syslog messages to remote syslog server"
}
step_16_alias() { ALIAS="remote"; } step_16_alias() { ALIAS="remote"; }
step_16() { step_16() {
local rex='^[0-9\.]+\:[0-9]+$' local rex='^[0-9\.]+\:[0-9]+$'
@@ -94,6 +97,7 @@ step_17() {
step_30_info() { echo "Activating syslog server"; } step_30_info() { echo "Activating syslog server"; }
step_30_alias() { ALIAS="server"; } step_30_alias() { ALIAS="server"; }
step_30() { step_30() {
outColor green
cat << SERVER_EOF cat << SERVER_EOF
# Uncomment the chapter # Uncomment the chapter
@@ -102,5 +106,5 @@ step_30() {
SERVER_EOF SERVER_EOF
} }
VERSION_SEQREV=12 VERSION_SEQREV=14
. /usr/local/bin/sequencer.sh . /usr/local/bin/sequencer.sh

View File

@@ -20,9 +20,11 @@ step_1() {
} }
step_2_info() { step_2_info() {
echo "Setup snmp v3 access [-s]" echoinfoArgs "[-s]"
echo "Setup snmp v3 access"
echoinfo " -s : Stop after creating authentication entry" echoinfo " -s : Stop after creating authentication entry"
} }
step_2_alias() { ALIAS="v3access"; }
step_2() { step_2() {
# #
## Create authentication entry ## Create authentication entry
@@ -91,7 +93,8 @@ step_2() {
v3AuthLoc="/var/lib/snmp/snmpd.conf" v3AuthLoc="/var/lib/snmp/snmpd.conf"
step_5_info() { step_5_info() {
echo "Add ufw rules for port 161 udp [INTERFACE]" echoinfoArgs "[INTERFACE]"
echo "Add ufw rules for port 161 udp"
echoinfo " [INTERFACE] (default: eth0)" echoinfo " [INTERFACE] (default: eth0)"
} }
step_5_alias() { ALIAS="ufw"; } step_5_alias() { ALIAS="ufw"; }
@@ -425,9 +428,7 @@ dhcpExtendConfigLoc="${toolConfigLoc}/dhcp.json"
dhcpExtendConfig="{\"leasefile\": \"/var/lib/dhcp/dhcpd.leases\" dhcpExtendConfig="{\"leasefile\": \"/var/lib/dhcp/dhcpd.leases\"
}" }"
step_44_info() { step_44_info() { echo "Extend unbound stats"; }
echo "Extend unbound stats"
}
step_44_alias() { ALIAS="unbound"; } step_44_alias() { ALIAS="unbound"; }
step_44() { step_44() {
local locExtName="unbound" local locExtName="unbound"
@@ -486,5 +487,5 @@ checkExtend() {
return 0 return 0
} }
VERSION_SEQREV=12 VERSION_SEQREV=14
. /usr/local/bin/sequencer.sh . /usr/local/bin/sequencer.sh

View File

@@ -46,6 +46,7 @@ SA_BAYES_DBNAME='spambayes_db'
step_50_info() { echo "Notes"; } step_50_info() { echo "Notes"; }
step_50_alias() { ALIAS="notes"; } step_50_alias() { ALIAS="notes"; }
step_50() { step_50() {
outColor green
echo "$notes" echo "$notes"
} }
notes=' notes='
@@ -149,5 +150,5 @@ notes='
saNewHam=$(cat);( echo "$saNewHam" | /usr/bin/sa-learn -u ${1} --ham ) & saNewHam=$(cat);( echo "$saNewHam" | /usr/bin/sa-learn -u ${1} --ham ) &
' '
VERSION_SEQREV=11 VERSION_SEQREV=14
. /usr/local/bin/sequencer.sh . /usr/local/bin/sequencer.sh

View File

@@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
toolName="ssh" toolName="ssh"
toolIdentity=~/.ssh/id_rsa toolIdentity=~/".ssh/id_rsa"
aList="" aList=""
aHost="" aHost=""
@@ -27,27 +27,8 @@ step_3() {
} }
step_5_info() { step_5_info() {
shift echoinfoArgs "[OPTIONS] <USER@HOST> [PORT]"
local arg echo "Send key to remote host"
local sshOption="[OPTIONS] "
local userHost="<USER@HOST>"
local userPort=" [PORT]"
for arg in "$@" ; do
case "$1" in
-4)
sshOption="-o Addressfamily=inet "
shift
;;
*)
break
;;
esac
done
if [ ! -z $1 ] ; then userHost="$1"; userPort=":22"; fi
if [ ! -z $2 ] ; then userPort=":$2"; fi
echo "Send key to remote host ${sshOption}${userHost}$userPort"
echoinfo "[OPTIONS]" echoinfo "[OPTIONS]"
echoinfo " -4 : Force Ipv4" echoinfo " -4 : Force Ipv4"
} }
@@ -89,14 +70,19 @@ step_5() {
exe ssh-copy-id -p ${sshPort} ${sshOption} ${sshHost} exe ssh-copy-id -p ${sshPort} ${sshOption} ${sshHost}
} }
step_10_info() { echo "Send command(ssh)/file(scp) list to remote(s) <CMDLIST> [USER:HOST]"; } 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_alias() { ALIAS="sendlist"; } step_10_alias() { ALIAS="sendlist"; }
step_10() { step_10() {
aList=$2 shift
aHost=$3 aList=$1
aHost=$2
# Set port only if not empty # Set port only if not empty
if [ ! -z "$4" ] || [ "$4" != "" ]; then if [ ! -z "$3" ]; then
aPort=$4 aPort=$3
fi fi
parseList $aList parseList $aList
saveReturn $? saveReturn $?
@@ -128,7 +114,7 @@ parseList() {
local errorMsg="" local errorMsg=""
if [ -z "$1" ] || [ ! -f "$1" ]; then if [ -z "$1" ] || [ ! -f "$1" ]; then
if [ -z "$1" ] || [ "$1" == "" ] ; then if [ -z "$1" ]; then
echoerr " [E] No Command list found" echoerr " [E] No Command list found"
else else
echoerr " [E] Command list not found: $1" echoerr " [E] Command list not found: $1"
@@ -146,21 +132,21 @@ parseList() {
return 1 return 1
fi fi
echo " [I] Parsing $(realpath $1) ..." echoseq " [I] Parsing $(realpath $1) ..."
local line=1 local line=1
# Working loop without ssh "stealing standard input" by # Working loop without ssh "stealing standard input" by
# https://unix.stackexchange.com/questions/24260/reading-lines-from-a-file-with-bash-for-vs-while # https://unix.stackexchange.com/questions/24260/reading-lines-from-a-file-with-bash-for-vs-while
while IFS='|' read -r lcmd lsrc ldst lopt<&3; do while IFS='|' read -r lcmd lsrc ldst lopt<&3; do
case "$lcmd" in case "$lcmd" in
h|H|host) h|H|host)
if [ -z "$lsrc" ] || [ "$lsrc" == "" ]; then if [ -z "$lsrc" ]; then
errorMsg="No host found" errorMsg="No host found"
#Prevent unwanted actions if parsing is continued #Prevent unwanted actions if parsing is continued
aHost="" aHost=""
saveReturn 1 saveReturn 1
else else
aHost="$lsrc" aHost="$lsrc"
if [ ! -z "$ldst" ] || [ "$ldst" != "" ]; then if [ ! -z "$ldst" ]; then
aPort=$ldst aPort=$ldst
else else
# Set port (back) to default in case no port is given # Set port (back) to default in case no port is given
@@ -171,7 +157,7 @@ parseList() {
fi fi
;; ;;
f|F|file) f|F|file)
if [ -z "$aHost" ] || [ "$aHost" == "" ]; then if [ -z "$aHost" ]; then
errorMsg="No host found" errorMsg="No host found"
saveReturn 1 saveReturn 1
else else
@@ -181,7 +167,7 @@ parseList() {
fi fi
;; ;;
c|C|command) c|C|command)
if [ -z "$aHost" ] || [ "$aHost" == "" ]; then if [ -z "$aHost" ]; then
errorMsg="No host found" errorMsg="No host found"
saveReturn 1 saveReturn 1
else else
@@ -206,7 +192,7 @@ parseList() {
((line++)) ((line++))
done 3<"$1" done 3<"$1"
echo " [I] Parsed $((--line)) lines" echoseq " [I] Parsed $((--line)) lines"
} }
listFileTemplate="# following files are send to host given on command line listFileTemplate="# following files are send to host given on command line
@@ -224,5 +210,5 @@ f|/sourcedir/sourcefile|/destdir/destfile
f|/sourcedir/sourcefile|/destdir/destfile f|/sourcedir/sourcefile|/destdir/destfile
c|/destdir2/update.sh" c|/destdir2/update.sh"
VERSION_SEQREV=10 VERSION_SEQREV=14
. sequencer.sh . sequencer.sh

View File

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

View File

@@ -44,7 +44,7 @@ step_20() {
exe ufw allow 4190/tcp comment 'Managesieve' exe ufw allow 4190/tcp comment 'Managesieve'
} }
step_22_info() { echo "Deny multicast from gateway [IP]"; } step_22_info() { echoinfoArgs "[IP]"; echo "Deny multicast from gateway"; }
step_22_alias() { ALIAS="multicast"; } step_22_alias() { ALIAS="multicast"; }
step_22() { step_22() {
shift shift
@@ -58,7 +58,8 @@ step_22() {
} }
step_24_info() { step_24_info() {
echo "Allow cifs mounts on eth0 to <FILE SERVER IP|RANGE> [PORT]" echoinfoArgs "<FILE SERVER IP|RANGE> [PORT]"
echo "Allow cifs mounts on eth0"
echoinfo " [PORT] (default 445)" echoinfo " [PORT] (default 445)"
echoinfo " 139 : Cifs version 1.0" echoinfo " 139 : Cifs version 1.0"
echoinfo " 445 : Cifs version 2.0+" echoinfo " 445 : Cifs version 2.0+"
@@ -106,5 +107,5 @@ step_26() {
exe ufw status verbose exe ufw status verbose
} }
VERSION_SEQREV=12 VERSION_SEQREV=14
. /usr/local/bin/sequencer.sh . /usr/local/bin/sequencer.sh

View File

@@ -3,7 +3,7 @@
serverName="nginx" serverName="nginx"
serverPackages="nginx" serverPackages="nginx"
serverSourceUrl="https://nginx.org/packages/debian/" serverSourceUrl="https://nginx.org/packages/debian/"
phpVersion="7.3" phpVersion="7.4"
phpName="php${phpVersion}" phpName="php${phpVersion}"
phpPackages="${phpName}-fpm ${phpName}-json ${phpName}-mysql ${phpName}-curl ${phpName}-intl ${phpName}-gd ${phpName}-zip ${phpName}-xml ${phpName}-mbstring php-imagick php-apcu php-redis" phpPackages="${phpName}-fpm ${phpName}-json ${phpName}-mysql ${phpName}-curl ${phpName}-intl ${phpName}-gd ${phpName}-zip ${phpName}-xml ${phpName}-mbstring php-imagick php-apcu php-redis"
@@ -15,6 +15,7 @@ step_config() {
} }
step_1_info() { step_1_info() {
echoinfoArgs "[DEBIAN RELEASE]"
echo "Setup latest apt source list for $serverName" echo "Setup latest apt source list for $serverName"
echoinfo "$serverSourceUrl" echoinfo "$serverSourceUrl"
} }
@@ -133,5 +134,5 @@ events {
NOTES_EOF NOTES_EOF
} }
VERSION_SEQREV=12 VERSION_SEQREV=14
. /usr/local/bin/sequencer.sh . /usr/local/bin/sequencer.sh