From 653d233586b7478639484025e8f14b51af759455 Mon Sep 17 00:00:00 2001 From: Martin Winkler Date: Tue, 15 Feb 2022 14:01:52 +0100 Subject: [PATCH] Enhanced output with new features of sequencer --- seqs/matrix.sh | 34 ++++++++++++++++++------------ seqs/mayan-edms.sh | 3 ++- seqs/nextcloud.sh | 52 +++++++++++++++++++++++++++++++++------------- seqs/onlyoffice.sh | 4 ++-- seqs/openvpn.sh | 2 +- seqs/piwigo.sh | 7 +++++-- 6 files changed, 69 insertions(+), 33 deletions(-) diff --git a/seqs/matrix.sh b/seqs/matrix.sh index a72b606..2975de4 100755 --- a/seqs/matrix.sh +++ b/seqs/matrix.sh @@ -182,7 +182,10 @@ step_12() { exe service ${toolServiceName} restart } -step_14_info() { echo "Show $toolName version running at [IP]:8008"; } +step_14_info() { + echoinfoArgs "[IP]:8008" + echo "Show $toolName version" +} step_14_alias() { ALIAS="version"; } step_14() { local synapseIP=localhost @@ -196,8 +199,9 @@ step_14() { exep "curl -sS \"$apiCall\" | python -m json.tool | grep _version" } -step_16_info() { - echo "List all registered users [OPTION] [IP]:8008" +step_16_info() { + echoinfoArgs "[OPTION] [IP]:8008" + echo "List all registered users" echoinfo "[OPTION]" echoinfo " -r : Raw json output" } @@ -238,12 +242,9 @@ step_18() { step_20_info() { shift + echoinfoArgs "[USER NAME]" echo -n "Reset user password" - if [ -z $1 ]; then - echo " [USER NAME]" - else - echo " for $1" - fi + [ $CONTEXT_EXE -ne 0 ] && echoinfo " for $1" || echo } step_20_alias() { ALIAS="resetpw"; } step_20() { @@ -268,7 +269,8 @@ step_20() { } step_22_info() { - echo "List all rooms [OPTION] [IP]:8008" + echoinfoArgs "[OPTION] [IP]:8008" + echo "List all rooms" echoinfo "[OPTION]" echoinfo " -r : Raw json output" } @@ -303,7 +305,8 @@ step_22() { } step_24_info() { - echo "List all room members [OPTION] [ROOM ID] [IP]:8008" + echoinfoArgs "[OPTION] [ROOM ID] [IP]:8008" + echo "List all room members" echoinfo "[OPTION]" echoinfo " -r : Raw json output" } @@ -342,7 +345,11 @@ step_24() { exep "curl -sS --header \"Authorization: Bearer $MATRIX_ACCESS\" \"$apiCall\" | python -m json.tool $grepOut" } -step_26_info() { echo "Delete rooms without local users [IP]:8008"; } +step_26_info() { + echoinfoArgs "[IP]:8008" + echo "Delete rooms without local users" + echoinfo " [IP] : default is localhost" +} step_26_alias() { ALIAS="purge"; } step_26() { adminTokenCheck @@ -371,7 +378,8 @@ step_26() { step_28_info() { - echo "Delete room [OPTION] [IP]:8008" + echoinfoArgs " [IP]:8008" + echo "Delete room" } step_28_alias() { ALIAS="deleteroom"; } step_28() { @@ -418,7 +426,7 @@ postDataDeleteRoom() EOF } -step_30_info() { echo "Debloat postgres [DATABASE]"; echo; } +step_30_info() { echoinfoArgs "[DATABASE]"; echo "Debloat postgres"; echo; } step_30_alias() { ALIAS="debloat"; } step_30() { shift diff --git a/seqs/mayan-edms.sh b/seqs/mayan-edms.sh index fd9fef9..0ad7865 100755 --- a/seqs/mayan-edms.sh +++ b/seqs/mayan-edms.sh @@ -120,7 +120,8 @@ save \"\" databases 2" step_10_info() { - echo "Upgrade $toolName to $toolVersion [OPTIONS]" + echoinfoArgs "[OPTIONS]" + echo "Upgrade $toolName to $toolVersion" echoinfo " [OPTIONS]" echoinfo " super : update also supervisor configuration" echoinfo " (manual redis password update may be needed)" diff --git a/seqs/nextcloud.sh b/seqs/nextcloud.sh index 527b323..4159ef5 100755 --- a/seqs/nextcloud.sh +++ b/seqs/nextcloud.sh @@ -4,6 +4,7 @@ # - mysql.sh (soft; Missing informational output) toolName="nextcloud" +localOcc=("echo" "occ not found!") # Get script working directory # (when called from a different directory) @@ -18,6 +19,7 @@ step_config() { if [ $? -eq 0 ] ; then CONFIG=1 fi + localOcc=( sudo -u www-data php "$(escpath "$NC_INSTALL_DIR/occ")" ) } step_20_info() { echo "Upgrade $toolName on command line to latest version of selected release channel"; } @@ -32,10 +34,21 @@ step_20() { } ncInstaller="updater/updater.phar" -step_100_info() { echoinfoArgs " "; echo "Delete IP from bruteforce table"; } -step_100_alias() { ALIAS="bruteforceRemoveIP"; } +step_100_info() { + echoinfoArgs "[OCC ARGS]" + echo "Execute occ command" +} +step_100_alias() { ALIAS="occ"; } step_100() { shift + + exe "${localOcc[@]}" "$@" +} + +step_102_info() { echoinfoArgs " "; echo "Delete IP from bruteforce table"; } +step_102_alias() { ALIAS="bruteforceRemoveIP"; } +step_102() { + shift local ncdb= local ip= local ipregex='^[0-2]*[0-9]{1,2}\.[0-2]*[0-9]{1,2}\.[0-2]*[0-9]{1,2}\.[0-2]*[0-9]{1,2}$' @@ -62,33 +75,44 @@ step_100() { endReturn -o $? "Error deleting ip $ip" } -step_102_info() { echoinfoArgs ""; echo "Reset and rescan the music library in the background for one user"; } -step_102_alias() { ALIAS="audioreset"; } -step_102() { +step_104_info() { echoinfoArgs ""; echo "Reset and rescan the music library in the background for one user"; } +step_104_alias() { ALIAS="audioreset"; } +step_104() { shift local ncUser=$1 - local lOcc="sudo -u www-data php $NC_INSTALL_DIR/occ" if [ -z "$ncUser" ] ; then echoerr " [E] Reset only for single user" return 1 fi - exep "sudo -u www-data php \"$NC_INSTALL_DIR/occ\" audioplayer:reset $ncUser > /var/log/ncAudioRescan.log" + exep "${localOcc[@]} audioplayer:reset $ncUser > /var/log/ncAudioRescan.log" echoseq " [I] Rescan audioplayer database for user $ncUser" - exep "sudo -u www-data php \"$NC_INSTALL_DIR/occ\" audioplayer:scan -vvvv $ncUser >> /var/log/ncAudioRescan.log &" + exep "${localOcc[@]} audioplayer:scan -vvvv $ncUser >> /var/log/ncAudioRescan.log &" } -step_104_info() { echo "Reset picture preview folder"; } -step_104_alias() { ALIAS="resetpreview"; } -step_104() { - local lOcc="sudo -u www-data php \"$NC_INSTALL_DIR/occ\"" +step_106_info() { echoinfoArgs ""; echo "Scan the music library"; } +step_106_alias() { ALIAS="audioscan"; } +step_106() { + shift + local ncUser=$1 + + if [ -z "$ncUser" ] ; then + echoerr " [E] Reset only for single user" + return 1 + fi + exe "${localOcc[@]}" audioplayer:scan -vvvv $ncUser +} + +step_110_info() { echo "Reset picture preview folder"; } +step_110_alias() { ALIAS="resetpreview"; } +step_110() { if [ -e "${NC_DATA_DIR}" ]; then exe rm -rf "${NC_DATA_DIR}/appdata_"*"/preview/"* echoseq " [I] Rescan app data folder" - exep "$lOcc files:scan-app-data &" + exep "${localOcc[@]} files:scan-app-data &" else echoerr " [E] Nextcloud data direcotry $NC_DATA_DIR not found" return 1 @@ -113,5 +137,5 @@ occ config:app:set preview jpeg_quality --value="60" NOTES_END } -VERSION_SEQREV=14 +VERSION_SEQREV=15 . /usr/local/bin/sequencer.sh diff --git a/seqs/onlyoffice.sh b/seqs/onlyoffice.sh index 1c3f94f..c35d989 100755 --- a/seqs/onlyoffice.sh +++ b/seqs/onlyoffice.sh @@ -95,9 +95,9 @@ step_4() { } step_5_info() { - echoinfoArgs "" + echoinfoArgs "[SECRET]" echo "Install/start onlyoffice docker container" - echoinfo "If is empty, user input will be available if not run --quiet." + 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_alias() { ALIAS="startoo"; } diff --git a/seqs/openvpn.sh b/seqs/openvpn.sh index 390486e..c62524c 100755 --- a/seqs/openvpn.sh +++ b/seqs/openvpn.sh @@ -30,7 +30,7 @@ step_config() { # # End if no configuration file exists # [ $DRY -eq 0 ] && return -1 #fi - #[ $QUIET -ne 0 ] && APTOPT="-y" + [ $QUIET -ne 0 ] && APTOPT="-y" return 0 } diff --git a/seqs/piwigo.sh b/seqs/piwigo.sh index c43b894..0a64312 100755 --- a/seqs/piwigo.sh +++ b/seqs/piwigo.sh @@ -30,7 +30,10 @@ 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() { echo "Backup ${toolName} database [daily|monthly(default)]"; } +step_31_info() { + echoinfoArgs "[daily|monthly(default]" + echo "Backup ${toolName} database" +} step_31_alias() { ALIAS="backupdb"; } step_31() { case "$2" in @@ -45,5 +48,5 @@ step_31() { esac } -VERSION_SEQREV=12 +VERSION_SEQREV=14 . /usr/local/bin/sequencer.sh