From c296c073736bf71c7a14386fd5ba596e9bd8c7e6 Mon Sep 17 00:00:00 2001 From: Martin Winkler Date: Tue, 11 Jan 2022 21:42:26 +0100 Subject: [PATCH] Update step configuration handling Reverse logic for supervisor configuration update --- seqs/mayan-edms.cfg.example | 5 ++++ seqs/mayan-edms.sh | 52 +++++++++++++++++++++++++++---------- 2 files changed, 44 insertions(+), 13 deletions(-) create mode 100644 seqs/mayan-edms.cfg.example diff --git a/seqs/mayan-edms.cfg.example b/seqs/mayan-edms.cfg.example new file mode 100644 index 0000000..2f9a200 --- /dev/null +++ b/seqs/mayan-edms.cfg.example @@ -0,0 +1,5 @@ +#!/bin/bash + +MAYAN_DB= +MAYAN_DBUSER= +MAYAN_DBPASS= diff --git a/seqs/mayan-edms.sh b/seqs/mayan-edms.sh index 7d2353a..fd9fef9 100755 --- a/seqs/mayan-edms.sh +++ b/seqs/mayan-edms.sh @@ -1,7 +1,7 @@ #!/bin/bash toolName="Mayan EDMS" -toolVersion="3.5.7" +toolVersion="4.1.4" toolRoot="/opt/mayan-edms" toolMediaFolder="/opt/mayan-edms/media" @@ -10,6 +10,35 @@ postgresDb="" postgresUser="" postgresPass="" +# Get script working directory +# (when called from a different directory) +WDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >>/dev/null 2>&1 && pwd)" +APTOPT= +CONFIG=0 +SCRIPT_FILE=$(basename -- $0) +SCRIPT_NAME=${SCRIPT_FILE%%.*} +CONFIG_FILE_NAME="${SCRIPT_NAME}.cfg" +CONFIG_FILE_TEMPLATE="$WDIR/${CONFIG_FILE_NAME}.example" + +step_config() { + ## or to use sequencer api with global config file: + initSeqConfig "$CONFIG_FILE_NAME" "$CONFIG_FILE_TEMPLATE" + if [ $? -eq 0 ] ; then + CONFIG=1 + postgresDb="$MAYAN_DB" + postgresUser="$MAYAN_DBUSER" + postgresPass="$MAYAN_DBPASS" + else + # End if no configuration file exists + [ $DRY -eq 0 ] && return -1 + fi + + ## Apt cmdline option to suppress user interaction + [ $QUIET -ne 0 ] && APTOPT="-y" + + ## Return of non zero value will abort the sequence + return 0 +} step_1_info() { echo "Install libreoffice without gui"; } step_1_alias() { ALIAS="install"; } @@ -93,7 +122,8 @@ databases 2" step_10_info() { echo "Upgrade $toolName to $toolVersion [OPTIONS]" echoinfo " [OPTIONS]" - echoinfo " nosuper : skip supervisor configuration generation" + echoinfo " super : update also supervisor configuration" + echoinfo " (manual redis password update may be needed)" } step_10_alias() { ALIAS="upgrade"; } step_10() { @@ -108,13 +138,9 @@ step_10() { toolScript performupgrade #toolScript preparestatic --noinput # only < 3.4 case $1 in - "nosuper") - echo " [I] Skipping supervisor configuration update" - ;; - *) + "super") # Generating new supervisor file - step supervisorconf - ;; + step supervisorconf ;; esac exe systemctl start supervisor } @@ -179,19 +205,19 @@ step_22() { # Read postgres database information dbname/user/pass if empty readDatabaseInfos() { - if [ "$postgresDb" == "" ] ; then + if [ -z "$postgresDb" ] ; then read -p "Enter postgres database name: " postgresDb endCheckEmpty postgresDb "database" fi - if [ "$postgresUser" == "" ] ; then + if [ -z "$postgresUser" ] ; then read -p "Enter postgres user name: " postgresUser endCheckEmpty postgresUser "user name" fi - if [ "$postgresPass" == "" ] ; then + if [ -z "$postgresPass" ] ; then read -s -p "Enter postgres password: " postgresPass endCheckEmpty postgresPass "password" fi - echo + echoseq } # Needs readDatabaseInfos() to execute some commands @@ -206,5 +232,5 @@ toolScript() { ${toolRoot}/bin/mayan-edms.py $*" } -VERSION_SEQREV=10 +VERSION_SEQREV=13 . /usr/local/bin/sequencer.sh