From 26965815c75f2f8d0ccd535a2f6fce40cb24e0ec Mon Sep 17 00:00:00 2001 From: Christoph Date: Sun, 27 Sep 2026 12:07:02 +0200 Subject: [PATCH] Fix Mattermost Team Edition setup and database password --- install-mattermost.sh | 61 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 57 insertions(+), 4 deletions(-) diff --git a/install-mattermost.sh b/install-mattermost.sh index 464b89b..d9740f2 100755 --- a/install-mattermost.sh +++ b/install-mattermost.sh @@ -210,14 +210,14 @@ DEFAULT_DB_TYPE="pgsql" # generate random password regexp_digit="([23456789].*){2}" -regexp_special_char="([-_%].*){2}" +regexp_special_char="([-_.].*){2}" regexp_not_alowed="([0ODl18B])" LENGTH=16 while [ 1 ] ; do - DEFAULT_DB_PASS="$(head -c 300 /dev/urandom | tr -cd 'a-zA-Z1-9\-_%' | head -c ${LENGTH})" + DEFAULT_DB_PASS="$(head -c 300 /dev/urandom | tr -cd 'a-zA-Z1-9\-_.' | head -c ${LENGTH})" # - Check Password # - @@ -538,9 +538,9 @@ while true ; do continue fi - if [[ ! "$DB_PASS" =~ ^[a-zA-Z1-9_%-]+$ ]] ; then + if [[ ! "$DB_PASS" =~ ^[a-zA-Z1-9_.-]+$ ]] ; then echo -e "\n\t\033[33m\033[1mDatabase Password contains unsupported characters." - echo -e "\tAllowed characters are: a-z A-Z 1-9 - _ %" + echo -e "\tAllowed characters are: a-z A-Z 1-9 - _ ." echo -e "\tPlease enter the password again.\033[m\n" continue fi @@ -1255,6 +1255,59 @@ else echo_skipped fi + +if [[ "$MATTERMOST_EDITION" == "team" ]] ; then + + echononl "Adjust plugin configuration for Mattermost Team Edition.." + + :> ${LOCK_DIR}/config.json + + _skip_nps=false + _in_playbooks=false + + while IFS='' read -r _line || [[ -n "$_line" ]] ; do + + if echo "$_line" | grep -q '"com\.mattermost\.nps": {' ; then + _skip_nps=true + continue + fi + + if $_skip_nps ; then + if echo "$_line" | grep -q '^[[:space:]]*},[[:space:]]*$' ; then + _skip_nps=false + fi + continue + fi + + if echo "$_line" | grep -q '"playbooks": {' ; then + _in_playbooks=true + echo "$_line" >> ${LOCK_DIR}/config.json + continue + fi + + if $_in_playbooks && echo "$_line" | grep -q '"Enable":[[:space:]]*true' ; then + echo "$_line" | sed 's/"Enable":[[:space:]]*true/"Enable": false/' >> ${LOCK_DIR}/config.json + _in_playbooks=false + continue + fi + + echo "$_line" >> ${LOCK_DIR}/config.json + + done < "/opt/mattermost/config/config.json" + + cp -a "${LOCK_DIR}/config.json" /opt/mattermost/config/config.json >> "$log_file" 2>&1 + + if [[ -s "$log_file" ]] ; then + echo_failed + error "$(cat "$log_file")" + else + echo_ok + fi + +fi + + + echononl "Reset ownership of '/opt/mattermost/config/config.json'.." chown ${MATTERMOST_USER}:${MATTERMOST_GROUP} /opt/mattermost/config/config.json > "$log_file" 2>&1 if [[ $? -ne 0 ]]; then