From 6dd40bc6c27b27110f4df72662bab0f12ac89110 Mon Sep 17 00:00:00 2001 From: Martin Winkler Date: Sun, 23 Jan 2022 23:06:46 +0100 Subject: [PATCH] Improve help output with latest changes from sequencer --- seqs/postfixadmin.sh | 28 ++++++++++++---------- seqs/postgres.sh | 13 +++++----- seqs/pyload.sh | 5 ++-- seqs/redis.sh | 5 ++-- seqs/roundcube.sh | 14 ++++------- seqs/rsyslog.sh | 8 +++++-- seqs/snmp.sh | 15 ++++++------ seqs/spamass.sh | 3 ++- seqs/ssh.sh | 56 +++++++++++++++++--------------------------- seqs/transmission.sh | 2 +- seqs/ufw.sh | 9 +++---- seqs/webserver.sh | 5 ++-- 12 files changed, 80 insertions(+), 83 deletions(-) diff --git a/seqs/postfixadmin.sh b/seqs/postfixadmin.sh index a927bf8..a1ade34 100755 --- a/seqs/postfixadmin.sh +++ b/seqs/postfixadmin.sh @@ -78,8 +78,8 @@ step_4() { } step_6_info() { - echo "Create postfixadmin fetchmail systemd timer and reduce syslos entries" - echoinfo "Needed to started after mysql service" + echo "Create postfixadmin fetchmail systemd timer and reduce syslog entries" + echoinfo "Needs to start after the mysql service" } step_6_alias() { ALIAS="timer"; } step_6() { @@ -143,7 +143,7 @@ fetchmailRsyslogLoc="/etc/rsyslog.d/30-fetchmail.conf" fetchmailRsyslog="if \$programname == 'fetchmail' or \$programname == 'fetchmail-all' then $fetchmailLogLoc & 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() { shift @@ -167,7 +167,8 @@ step_18() { 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 echo " at $PFA_BACKUP" else @@ -200,16 +201,18 @@ step_20() { } step_22_info() { + echoinfoArgs "[CUSTOM VERSION]" shift - if [ -z $1 ] ; then - echo -n "Get latest version from github" - if [ $CONTEXT_HELP -eq 0 ] ; then - echo ": $(curl --silent "$latestUrl" | grep -Po '"tag_name": "postfixadmin-\K.*?(?=")')" + if [ $CONTEXT_EXE -ne 0 ]; then + echoinfo -n "Upgrade to version " + if [ -z "$1" ]; then + echo -n "$(curl --silent "$latestUrl" | grep -Po '"tag_name": "postfixadmin-\K.*?(?=")')" else - echo " [CUSTOM VERSION]" + echo -n "$1" fi + echo " from github" else - echo "Get version $1 from github" + echo "Upgrade to latest or a custom version from github" fi } step_22_alias() { ALIAS="upgrade"; } @@ -311,7 +314,8 @@ step_23() { } step_100_info() { - echo "$toolName client script [OPTIONS]" + echoinfoArgs "[OPTIONS]" + echo "Execute $toolName client script" echoinfo "[OPTIONS] are passed on to $toolName-cli unmodified" } step_100_alias() { ALIAS="cli"; } @@ -320,5 +324,5 @@ step_100() { exe ${PFA_SRV_LOC}/scripts/$toolName-cli $@ } -VERSION_SEQREV=11 +VERSION_SEQREV=14 . /usr/local/bin/sequencer.sh diff --git a/seqs/postgres.sh b/seqs/postgres.sh index 2a8d09e..be5d953 100755 --- a/seqs/postgres.sh +++ b/seqs/postgres.sh @@ -51,7 +51,7 @@ step_2() { 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() { shift @@ -64,7 +64,7 @@ step_4() { 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() { shift @@ -84,7 +84,7 @@ step_8() { 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() { shift @@ -97,7 +97,7 @@ step_10() { 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() { shift @@ -137,7 +137,8 @@ step_22() { step_24_info() { 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() { @@ -168,5 +169,5 @@ readDatabaseInfos() { echo } -VERSION_SEQREV=11 +VERSION_SEQREV=14 . /usr/local/bin/sequencer.sh diff --git a/seqs/pyload.sh b/seqs/pyload.sh index 6c1d150..6864688 100755 --- a/seqs/pyload.sh +++ b/seqs/pyload.sh @@ -51,7 +51,8 @@ step_2() { } step_3_info() { - echo "Install dependencies for [TARGET]" + echoinfoArgs "[TARGET]" + echo "Install dependencies" echoinfo " [TARGET] (default: raspi)" echoinfo " raspi: Raspberry Pi OS" echoinfo " debian: Debian" @@ -133,5 +134,5 @@ step_10() { echo " Do so manually with: service $toolName start" } -VERSION_SEQREV=12 +VERSION_SEQREV=14 . /usr/local/bin/sequencer.sh diff --git a/seqs/redis.sh b/seqs/redis.sh index 447e418..bca50cc 100755 --- a/seqs/redis.sh +++ b/seqs/redis.sh @@ -65,7 +65,8 @@ NOTES_EOF } step_10_info() { - echo "Execute redis-cli commands [CLI COMMAND]" + echoinfoArgs "[CLI COMMAND]" + echo "Execute redis-cli commands" echoinfo " [CLI COMMAND]" echoinfo " e.g. info" } @@ -81,5 +82,5 @@ step_10() { fi } -VERSION_SEQREV=12 +VERSION_SEQREV=14 . /usr/local/bin/sequencer.sh diff --git a/seqs/roundcube.sh b/seqs/roundcube.sh index 9980095..fd6a767 100755 --- a/seqs/roundcube.sh +++ b/seqs/roundcube.sh @@ -74,10 +74,10 @@ step_3() { exe read -p "Copy the lines above and press Enter to continue." exe vi "$RC_LOC/composer.json" step postupgrade -exit 0 + echo " [I] Generating mysql database $RC_DATABASE" echo - exe $WDIR/mysql.sh createdb_utf8mb4 + exe $WDIR/mysql.sh createdb -c utf8mb4 echo echo " [I] Now visit: http://url-to-roundcube/installer/" @@ -165,12 +165,8 @@ step_20() { } step_22_info() { - shift - if [ -z $1 ] ; then - echo "Upgrade installation to latest version from github [CUSTOM VERSION]" - else - echo "Upgrade installation to $1 from github" - fi + echoinfoArgs "[CUSTOM VERSION]" + echo "Upgrade installation to \"latest\" from github if [CUSTOM_VERSION] is empty" } step_22_alias() { ALIAS="upgrade"; } step_22() { @@ -258,5 +254,5 @@ downloadLatest() { tempDown="/tmp/roundcube" tempLoc="$tempDown/rc.tar.gz" -VERSION_SEQREV=10 +VERSION_SEQREV=14 . /usr/local/bin/sequencer.sh diff --git a/seqs/rsyslog.sh b/seqs/rsyslog.sh index d9ebf86..9ff14cc 100755 --- a/seqs/rsyslog.sh +++ b/seqs/rsyslog.sh @@ -63,7 +63,10 @@ step_14() { } CONFIG_RNGD_DEST="/etc/rsyslog.d/$(basename $CONFIG_RNGD)" -step_16_info() { echo "Send syslog messages to remote syslog server "; } +step_16_info() { + echoinfoArgs "" + echo "Send syslog messages to remote syslog server" +} step_16_alias() { ALIAS="remote"; } step_16() { local rex='^[0-9\.]+\:[0-9]+$' @@ -94,6 +97,7 @@ step_17() { step_30_info() { echo "Activating syslog server"; } step_30_alias() { ALIAS="server"; } step_30() { + outColor green cat << SERVER_EOF # Uncomment the chapter @@ -102,5 +106,5 @@ step_30() { SERVER_EOF } -VERSION_SEQREV=12 +VERSION_SEQREV=14 . /usr/local/bin/sequencer.sh diff --git a/seqs/snmp.sh b/seqs/snmp.sh index d74fbac..da1be6f 100755 --- a/seqs/snmp.sh +++ b/seqs/snmp.sh @@ -20,9 +20,11 @@ step_1() { } step_2_info() { - echo "Setup snmp v3 access [-s]" + echoinfoArgs "[-s]" + echo "Setup snmp v3 access" echoinfo " -s : Stop after creating authentication entry" } +step_2_alias() { ALIAS="v3access"; } step_2() { # ## Create authentication entry @@ -90,8 +92,9 @@ step_2() { } v3AuthLoc="/var/lib/snmp/snmpd.conf" -step_5_info() { - echo "Add ufw rules for port 161 udp [INTERFACE]" +step_5_info() { + echoinfoArgs "[INTERFACE]" + echo "Add ufw rules for port 161 udp" echoinfo " [INTERFACE] (default: eth0)" } step_5_alias() { ALIAS="ufw"; } @@ -425,9 +428,7 @@ dhcpExtendConfigLoc="${toolConfigLoc}/dhcp.json" dhcpExtendConfig="{\"leasefile\": \"/var/lib/dhcp/dhcpd.leases\" }" -step_44_info() { - echo "Extend unbound stats" -} +step_44_info() { echo "Extend unbound stats"; } step_44_alias() { ALIAS="unbound"; } step_44() { local locExtName="unbound" @@ -486,5 +487,5 @@ checkExtend() { return 0 } -VERSION_SEQREV=12 +VERSION_SEQREV=14 . /usr/local/bin/sequencer.sh diff --git a/seqs/spamass.sh b/seqs/spamass.sh index e888694..3c975b4 100755 --- a/seqs/spamass.sh +++ b/seqs/spamass.sh @@ -46,6 +46,7 @@ SA_BAYES_DBNAME='spambayes_db' step_50_info() { echo "Notes"; } step_50_alias() { ALIAS="notes"; } step_50() { + outColor green echo "$notes" } notes=' @@ -149,5 +150,5 @@ notes=' saNewHam=$(cat);( echo "$saNewHam" | /usr/bin/sa-learn -u ${1} --ham ) & ' -VERSION_SEQREV=11 +VERSION_SEQREV=14 . /usr/local/bin/sequencer.sh diff --git a/seqs/ssh.sh b/seqs/ssh.sh index f33e15d..6e34626 100755 --- a/seqs/ssh.sh +++ b/seqs/ssh.sh @@ -1,7 +1,7 @@ #!/bin/bash toolName="ssh" -toolIdentity=~/.ssh/id_rsa +toolIdentity=~/".ssh/id_rsa" aList="" aHost="" @@ -27,27 +27,8 @@ step_3() { } step_5_info() { - shift - local arg - local sshOption="[OPTIONS] " - local userHost="" - 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" + echoinfoArgs "[OPTIONS] [PORT]" + echo "Send key to remote host" echoinfo "[OPTIONS]" echoinfo " -4 : Force Ipv4" } @@ -89,14 +70,19 @@ step_5() { exe ssh-copy-id -p ${sshPort} ${sshOption} ${sshHost} } -step_10_info() { echo "Send command(ssh)/file(scp) list to remote(s) [USER:HOST]"; } +step_10_info() { + echoinfoArgs " [USER:HOST] [PORT]" + echo "Send command(ssh)/file(scp) list to remote(s)" + echoinfo "[USER:HOST] and [PORT] are overwritten by \"host\" command from " +} step_10_alias() { ALIAS="sendlist"; } step_10() { - aList=$2 - aHost=$3 + shift + aList=$1 + aHost=$2 # Set port only if not empty - if [ ! -z "$4" ] || [ "$4" != "" ]; then - aPort=$4 + if [ ! -z "$3" ]; then + aPort=$3 fi parseList $aList saveReturn $? @@ -128,7 +114,7 @@ parseList() { local errorMsg="" if [ -z "$1" ] || [ ! -f "$1" ]; then - if [ -z "$1" ] || [ "$1" == "" ] ; then + if [ -z "$1" ]; then echoerr " [E] No Command list found" else echoerr " [E] Command list not found: $1" @@ -146,21 +132,21 @@ parseList() { return 1 fi - echo " [I] Parsing $(realpath $1) ..." + echoseq " [I] Parsing $(realpath $1) ..." local line=1 # Working loop without ssh "stealing standard input" by # 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 case "$lcmd" in h|H|host) - if [ -z "$lsrc" ] || [ "$lsrc" == "" ]; then + if [ -z "$lsrc" ]; then errorMsg="No host found" #Prevent unwanted actions if parsing is continued aHost="" saveReturn 1 else aHost="$lsrc" - if [ ! -z "$ldst" ] || [ "$ldst" != "" ]; then + if [ ! -z "$ldst" ]; then aPort=$ldst else # Set port (back) to default in case no port is given @@ -171,7 +157,7 @@ parseList() { fi ;; f|F|file) - if [ -z "$aHost" ] || [ "$aHost" == "" ]; then + if [ -z "$aHost" ]; then errorMsg="No host found" saveReturn 1 else @@ -181,7 +167,7 @@ parseList() { fi ;; c|C|command) - if [ -z "$aHost" ] || [ "$aHost" == "" ]; then + if [ -z "$aHost" ]; then errorMsg="No host found" saveReturn 1 else @@ -206,7 +192,7 @@ parseList() { ((line++)) done 3<"$1" - echo " [I] Parsed $((--line)) lines" + echoseq " [I] Parsed $((--line)) lines" } 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 c|/destdir2/update.sh" -VERSION_SEQREV=10 +VERSION_SEQREV=14 . sequencer.sh diff --git a/seqs/transmission.sh b/seqs/transmission.sh index d123b4e..8fdb4cd 100755 --- a/seqs/transmission.sh +++ b/seqs/transmission.sh @@ -119,7 +119,7 @@ step_50() { exe "$toolRemote" -l } -step_52_info() { echo "List information about [TORRENT ID]"; } +step_52_info() { echoinfoArgs ""; echo "List information about a torrent"; } step_52_alias() { ALIAS="info"; } step_52() { shift diff --git a/seqs/ufw.sh b/seqs/ufw.sh index c47f638..51b7463 100755 --- a/seqs/ufw.sh +++ b/seqs/ufw.sh @@ -44,7 +44,7 @@ step_20() { 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() { shift @@ -57,8 +57,9 @@ step_22() { exe ufw deny in from $1 to 239.0.0.0/8 comment 'Broadcast Fritzbox' } -step_24_info() { - echo "Allow cifs mounts on eth0 to [PORT]" +step_24_info() { + echoinfoArgs " [PORT]" + echo "Allow cifs mounts on eth0" echoinfo " [PORT] (default 445)" echoinfo " 139 : Cifs version 1.0" echoinfo " 445 : Cifs version 2.0+" @@ -106,5 +107,5 @@ step_26() { exe ufw status verbose } -VERSION_SEQREV=12 +VERSION_SEQREV=14 . /usr/local/bin/sequencer.sh diff --git a/seqs/webserver.sh b/seqs/webserver.sh index 0a0f376..758654b 100755 --- a/seqs/webserver.sh +++ b/seqs/webserver.sh @@ -3,7 +3,7 @@ serverName="nginx" serverPackages="nginx" serverSourceUrl="https://nginx.org/packages/debian/" -phpVersion="7.3" +phpVersion="7.4" 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" @@ -15,6 +15,7 @@ step_config() { } step_1_info() { + echoinfoArgs "[DEBIAN RELEASE]" echo "Setup latest apt source list for $serverName" echoinfo "$serverSourceUrl" } @@ -133,5 +134,5 @@ events { NOTES_EOF } -VERSION_SEQREV=12 +VERSION_SEQREV=14 . /usr/local/bin/sequencer.sh