mirror of
https://github.com/YunoHost-Apps/mattermost_ynh.git
synced 2024-09-03 19:36:29 +02:00
scripts: use ynh_replace_string
instead of sed -i
This commit is contained in:
parent
642aad9594
commit
66d31e3171
2 changed files with 16 additions and 16 deletions
|
@ -125,28 +125,28 @@ mkdir -p "$logs_path"
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Configure Service Settings
|
# Configure Service Settings
|
||||||
sed -i "s|\"SiteURL\": \"\"|\"SiteURL\": \"https://${domain}${path_url}\"|g" $final_path/config/config.json
|
ynh_replace_string --match "\"SiteURL\": \"\"" --replace "\"SiteURL\": \"https://${domain}${path_url}\"" --target $final_path/config/config.json
|
||||||
sed -i "s|\"ListenAddress\": \".*\"|\"ListenAddress\": \"127.0.0.1:${port}\"|g" $final_path/config/config.json
|
ynh_replace_string --match "\"ListenAddress\": \".*\"" --replace "\"ListenAddress\": \"127.0.0.1:${port}\"" --target $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"
|
||||||
sed -i "s|\"DataSource\": \".*\"|\"DataSource\": \"${db_connection_url}\"|g" $final_path/config/config.json
|
ynh_replace_string --match "\"DataSource\": \".*\"" --replace "\"DataSource\": \"${db_connection_url}\"" --target $final_path/config/config.json
|
||||||
# Configure uploaded files directory
|
# Configure uploaded files directory
|
||||||
sed -i "s|\"Directory\": \"./data/\"|\"Directory\": \"${data_path}/\"|g" $final_path/config/config.json
|
ynh_replace_string --match "\"Directory\": \"./data/\"" --replace "\"Directory\": \"${data_path}/\"" --target $final_path/config/config.json
|
||||||
# Configure SMTP account for sending email notifications
|
# Configure SMTP account for sending email notifications
|
||||||
sed -i "s|\"SendEmailNotifications\": false|\"SendEmailNotifications\": true|g" $final_path/config/config.json
|
ynh_replace_string --match "\"SendEmailNotifications\": false" --replace "\"SendEmailNotifications\": true" --target $final_path/config/config.json
|
||||||
sed -i "s|\"FeedbackName\": \"\"|\"FeedbackName\": \"Mattermost notification\"|g" $final_path/config/config.json
|
ynh_replace_string --match "\"FeedbackName\": \"\"" --replace "\"FeedbackName\": \"Mattermost notification\"" --target $final_path/config/config.json
|
||||||
sed -i "s|\"FeedbackEmail\": \"\"|\"FeedbackEmail\": \"no-reply@${domain}\"|g" $final_path/config/config.json
|
ynh_replace_string --match "\"FeedbackEmail\": \"\"" --replace "\"FeedbackEmail\": \"no-reply@${domain}\"" --target $final_path/config/config.json
|
||||||
sed -i "s|\"SMTPUsername\": \"\"|\"SMTPUsername\": \"${mattermost_user}\"|g" $final_path/config/config.json
|
ynh_replace_string --match "\"SMTPUsername\": \"\"" --replace "\"SMTPUsername\": \"${mattermost_user}\"" --target $final_path/config/config.json
|
||||||
sed -i "s|\"SMTPPassword\": \"\"|\"SMTPPassword\": \"${mattermost_user_password}\"|g" $final_path/config/config.json
|
ynh_replace_string --match "\"SMTPPassword\": \"\"" --replace "\"SMTPPassword\": \"${mattermost_user_password}\"" --target $final_path/config/config.json
|
||||||
sed -i "s|\"SMTPServer\": \"\"|\"SMTPServer\": \"localhost\"|g" $final_path/config/config.json
|
ynh_replace_string --match "\"SMTPServer\": \"\"" --replace "\"SMTPServer\": \"localhost\"" --target $final_path/config/config.json
|
||||||
sed -i "s|\"SMTPPort\": \"\"|\"SMTPPort\": \"25\"|g" $final_path/config/config.json
|
ynh_replace_string --match "\"SMTPPort\": \"\"" --replace "\"SMTPPort\": \"25\"" --target $final_path/config/config.json
|
||||||
# Disable Mattermost debug console by default
|
# Disable Mattermost debug console by default
|
||||||
sed -i "s|\"EnableConsole\": true|\"EnableConsole\": false|g" $final_path/config/config.json
|
ynh_replace_string --match "\"EnableConsole\": true" --replace "\"EnableConsole\": false" --target $final_path/config/config.json
|
||||||
# Configure log file location
|
# Configure log file location
|
||||||
sed -i "s|\"FileLocation\": \"\"|\"FileLocation\": \"$logs_path\"|g" $final_path/config/config.json
|
ynh_replace_string --match "\"FileLocation\": \"\"" --replace "\"FileLocation\": \"$logs_path\"" --target $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
|
||||||
sed -i "s|\"EnableDiagnostics\": true|\"EnableDiagnostics\": false|g" $final_path/config/config.json
|
ynh_replace_string --match "\"EnableDiagnostics\": true" --replace "\"EnableDiagnostics\": false" --target $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
|
||||||
sed -i "s|\"FileLocation\": \"/var/log/mattermost.log\"|\"FileLocation\": \"/var/log\"|g" "$config_file"
|
ynh_replace_string --match "\"FileLocation\": \"/var/log/mattermost.log\"" --replace "\"FileLocation\": \"/var/log\"" --target "$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"
|
||||||
sed -i "s|\"FileLocation\": \"/var/log\"|\"FileLocation\": \"$logs_path\"|g" "$config_file"
|
ynh_replace_string --match "\"FileLocation\": \"/var/log\"" --replace "\"FileLocation\": \"$logs_path\"" --target "$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…
Add table
Reference in a new issue