Fix Mattermost Team Edition setup and database password
This commit is contained in:
+57
-4
@@ -210,14 +210,14 @@ DEFAULT_DB_TYPE="pgsql"
|
|||||||
|
|
||||||
# generate random password
|
# generate random password
|
||||||
regexp_digit="([23456789].*){2}"
|
regexp_digit="([23456789].*){2}"
|
||||||
regexp_special_char="([-_%].*){2}"
|
regexp_special_char="([-_.].*){2}"
|
||||||
|
|
||||||
regexp_not_alowed="([0ODl18B])"
|
regexp_not_alowed="([0ODl18B])"
|
||||||
LENGTH=16
|
LENGTH=16
|
||||||
|
|
||||||
while [ 1 ] ; do
|
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
|
# - Check Password
|
||||||
# -
|
# -
|
||||||
@@ -538,9 +538,9 @@ while true ; do
|
|||||||
continue
|
continue
|
||||||
fi
|
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 "\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"
|
echo -e "\tPlease enter the password again.\033[m\n"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
@@ -1255,6 +1255,59 @@ else
|
|||||||
echo_skipped
|
echo_skipped
|
||||||
fi
|
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'.."
|
echononl "Reset ownership of '/opt/mattermost/config/config.json'.."
|
||||||
chown ${MATTERMOST_USER}:${MATTERMOST_GROUP} /opt/mattermost/config/config.json > "$log_file" 2>&1
|
chown ${MATTERMOST_USER}:${MATTERMOST_GROUP} /opt/mattermost/config/config.json > "$log_file" 2>&1
|
||||||
if [[ $? -ne 0 ]]; then
|
if [[ $? -ne 0 ]]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user