mirror of
https://github.com/YunoHost-Apps/mattermost_ynh.git
synced 2024-09-03 19:36:29 +02:00
scripts: disable questionnable password complexity rules
Enforcing password complexity rules is usually useless, and encourages bad security. However, this is not our main issue. The problem is that when installing Mattermost on Yunohost, if the user chooses a password that doesn't fullfil all these requirements, the installation will fail with a hard- to-spot error message. We don't want this to happen, so we relax the rules a little. Fix #159
This commit is contained in:
parent
66d31e3171
commit
d460d7f2bd
4 changed files with 25 additions and 19 deletions
|
@ -3,7 +3,7 @@
|
||||||
domain="ynhtests.local" (DOMAIN)
|
domain="ynhtests.local" (DOMAIN)
|
||||||
path="/path" (PATH)
|
path="/path" (PATH)
|
||||||
admin_email="john@gmail.com"
|
admin_email="john@gmail.com"
|
||||||
admin_password="MattermostPassword!42"
|
admin_password="admin!42"
|
||||||
admin_locale="fr"
|
admin_locale="fr"
|
||||||
team_display_name="Mon équipe"
|
team_display_name="Mon équipe"
|
||||||
is_public=1 (PUBLIC|public=1|private=0)
|
is_public=1 (PUBLIC|public=1|private=0)
|
||||||
|
|
|
@ -64,8 +64,8 @@
|
||||||
"name": "admin_password",
|
"name": "admin_password",
|
||||||
"type": "password",
|
"type": "password",
|
||||||
"ask": {
|
"ask": {
|
||||||
"en": "Password for the chat admin. Must contain at least 10 characters, one lowercase letter, one uppercase letter, one number, and one symbol (e.g. '~!@#$%^&*()').",
|
"en": "Password for the chat admin. At least 8 characters.",
|
||||||
"fr": "Mot de passe pour l’administrateur du chat. Doit contenir au moins 10 caractères, une majuscule, une minuscule, un chiffre, et une ponctuation (ex. '~!@#$%^&*()')."
|
"fr": "Mot de passe pour l’administrateur du chat. Minimum 8 caractères."
|
||||||
},
|
},
|
||||||
"optional": false
|
"optional": false
|
||||||
},
|
},
|
||||||
|
|
|
@ -125,28 +125,34 @@ mkdir -p "$logs_path"
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Configure Service Settings
|
# Configure Service Settings
|
||||||
ynh_replace_string --match "\"SiteURL\": \"\"" --replace "\"SiteURL\": \"https://${domain}${path_url}\"" --target $final_path/config/config.json
|
ynh_replace_string --match_string "\"SiteURL\": \"\"" --replace_string "\"SiteURL\": \"https://${domain}${path_url}\"" --target_file $final_path/config/config.json
|
||||||
ynh_replace_string --match "\"ListenAddress\": \".*\"" --replace "\"ListenAddress\": \"127.0.0.1:${port}\"" --target $final_path/config/config.json
|
ynh_replace_string --match_string "\"ListenAddress\": \".*\"" --replace_string "\"ListenAddress\": \"127.0.0.1:${port}\"" --target_file $final_path/config/config.json
|
||||||
# Configure the database connection
|
# Configure the database connection
|
||||||
db_connection_url="${db_user}:${db_password}@tcp(127.0.0.1:3306)/${db_name}?charset=utf8mb4,utf8"
|
db_connection_url="${db_user}:${db_password}@tcp(127.0.0.1:3306)/${db_name}?charset=utf8mb4,utf8"
|
||||||
ynh_replace_string --match "\"DataSource\": \".*\"" --replace "\"DataSource\": \"${db_connection_url}\"" --target $final_path/config/config.json
|
ynh_replace_string --match_string "\"DataSource\": \".*\"" --replace_string "\"DataSource\": \"${db_connection_url}\"" --target_file $final_path/config/config.json
|
||||||
# Configure uploaded files directory
|
# Configure uploaded files directory
|
||||||
ynh_replace_string --match "\"Directory\": \"./data/\"" --replace "\"Directory\": \"${data_path}/\"" --target $final_path/config/config.json
|
ynh_replace_string --match_string "\"Directory\": \"./data/\"" --replace_string "\"Directory\": \"${data_path}/\"" --target_file $final_path/config/config.json
|
||||||
# Configure SMTP account for sending email notifications
|
# Configure SMTP account for sending email notifications
|
||||||
ynh_replace_string --match "\"SendEmailNotifications\": false" --replace "\"SendEmailNotifications\": true" --target $final_path/config/config.json
|
ynh_replace_string --match_string "\"SendEmailNotifications\": false" --replace_string "\"SendEmailNotifications\": true" --target_file $final_path/config/config.json
|
||||||
ynh_replace_string --match "\"FeedbackName\": \"\"" --replace "\"FeedbackName\": \"Mattermost notification\"" --target $final_path/config/config.json
|
ynh_replace_string --match_string "\"FeedbackName\": \"\"" --replace_string "\"FeedbackName\": \"Mattermost notification\"" --target_file $final_path/config/config.json
|
||||||
ynh_replace_string --match "\"FeedbackEmail\": \"\"" --replace "\"FeedbackEmail\": \"no-reply@${domain}\"" --target $final_path/config/config.json
|
ynh_replace_string --match_string "\"FeedbackEmail\": \"\"" --replace_string "\"FeedbackEmail\": \"no-reply@${domain}\"" --target_file $final_path/config/config.json
|
||||||
ynh_replace_string --match "\"SMTPUsername\": \"\"" --replace "\"SMTPUsername\": \"${mattermost_user}\"" --target $final_path/config/config.json
|
ynh_replace_string --match_string "\"SMTPUsername\": \"\"" --replace_string "\"SMTPUsername\": \"${mattermost_user}\"" --target_file $final_path/config/config.json
|
||||||
ynh_replace_string --match "\"SMTPPassword\": \"\"" --replace "\"SMTPPassword\": \"${mattermost_user_password}\"" --target $final_path/config/config.json
|
ynh_replace_string --match_string "\"SMTPPassword\": \"\"" --replace_string "\"SMTPPassword\": \"${mattermost_user_password}\"" --target_file $final_path/config/config.json
|
||||||
ynh_replace_string --match "\"SMTPServer\": \"\"" --replace "\"SMTPServer\": \"localhost\"" --target $final_path/config/config.json
|
ynh_replace_string --match_string "\"SMTPServer\": \"\"" --replace_string "\"SMTPServer\": \"localhost\"" --target_file $final_path/config/config.json
|
||||||
ynh_replace_string --match "\"SMTPPort\": \"\"" --replace "\"SMTPPort\": \"25\"" --target $final_path/config/config.json
|
ynh_replace_string --match_string "\"SMTPPort\": \"\"" --replace_string "\"SMTPPort\": \"25\"" --target_file $final_path/config/config.json
|
||||||
# Disable Mattermost debug console by default
|
# Disable Mattermost debug console by default
|
||||||
ynh_replace_string --match "\"EnableConsole\": true" --replace "\"EnableConsole\": false" --target $final_path/config/config.json
|
ynh_replace_string --match_string "\"EnableConsole\": true" --replace_string "\"EnableConsole\": false" --target_file $final_path/config/config.json
|
||||||
# Configure log file location
|
# Configure log file location
|
||||||
ynh_replace_string --match "\"FileLocation\": \"\"" --replace "\"FileLocation\": \"$logs_path\"" --target $final_path/config/config.json
|
ynh_replace_string --match_string "\"FileLocation\": \"\"" --replace_string "\"FileLocation\": \"$logs_path\"" --target_file $final_path/config/config.json
|
||||||
|
# Disable questionable password complexity rules
|
||||||
|
ynh_replace_string --match_string "\"MinimumLength\": 10" --replace_string "\"MinimumLength\": 8" --target_file $final_path/config/config.json
|
||||||
|
ynh_replace_string --match_string "\"Lowercase\": true" --replace_string "\"Lowercase\": false" --target_file $final_path/config/config.json
|
||||||
|
ynh_replace_string --match_string "\"Number\": true" --replace_string "\"Number\": false" --target_file $final_path/config/config.json
|
||||||
|
ynh_replace_string --match_string "\"Uppercase\": true" --replace_string "\"Uppercase\": false" --target_file $final_path/config/config.json
|
||||||
|
ynh_replace_string --match_string "\"Symbol\": true" --replace_string "\"Symbol\": false" --target_file $final_path/config/config.json
|
||||||
# Configure analytics according to user choice
|
# Configure analytics according to user choice
|
||||||
if [ $analytics -eq 0 ]; then
|
if [ $analytics -eq 0 ]; then
|
||||||
ynh_replace_string --match "\"EnableDiagnostics\": true" --replace "\"EnableDiagnostics\": false" --target $final_path/config/config.json
|
ynh_replace_string --match_string "\"EnableDiagnostics\": true" --replace_string "\"EnableDiagnostics\": false" --target_file $final_path/config/config.json
|
||||||
fi
|
fi
|
||||||
ynh_app_setting_set "$app" analytics "$analytics"
|
ynh_app_setting_set "$app" analytics "$analytics"
|
||||||
|
|
||||||
|
|
|
@ -146,12 +146,12 @@ yunohost service add "$app" --log "$logs_path/mattermost.log"
|
||||||
|
|
||||||
# Fix log FileLocation path (changed in Mattermost 3.8, makes Mattermost >= 4.2 crash)
|
# Fix log FileLocation path (changed in Mattermost 3.8, makes Mattermost >= 4.2 crash)
|
||||||
# https://docs.mattermost.com/administration/changelog.html#release-v3-8-3
|
# https://docs.mattermost.com/administration/changelog.html#release-v3-8-3
|
||||||
ynh_replace_string --match "\"FileLocation\": \"/var/log/mattermost.log\"" --replace "\"FileLocation\": \"/var/log\"" --target "$config_file"
|
ynh_replace_string --match_string "\"FileLocation\": \"/var/log/mattermost.log\"" --replace_string "\"FileLocation\": \"/var/log\"" --target_file "$config_file"
|
||||||
|
|
||||||
# Move log files to a directory (rather than directly in /var/log)
|
# Move log files to a directory (rather than directly in /var/log)
|
||||||
# See https://github.com/YunoHost-Apps/mattermost_ynh/issues/61
|
# See https://github.com/YunoHost-Apps/mattermost_ynh/issues/61
|
||||||
mkdir -p "$logs_path"
|
mkdir -p "$logs_path"
|
||||||
ynh_replace_string --match "\"FileLocation\": \"/var/log\"" --replace "\"FileLocation\": \"$logs_path\"" --target "$config_file"
|
ynh_replace_string --match_string "\"FileLocation\": \"/var/log\"" --replace_string "\"FileLocation\": \"$logs_path\"" --target_file "$config_file"
|
||||||
if [ -f "/var/log/${app}.log" ]; then
|
if [ -f "/var/log/${app}.log" ]; then
|
||||||
mv "/var/log/${app}.log" "$logs_path/"
|
mv "/var/log/${app}.log" "$logs_path/"
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue