From 3c9e53fe5713e02ee50d360e3e092a978bed6164 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Tue, 30 Jan 2018 12:19:02 +0530 Subject: [PATCH] scripts: rename `smtp_user` to `mattermost_user` --- scripts/install | 40 ++++++++++++++++++++-------------------- scripts/remove | 4 ++-- scripts/restore | 16 ++++++++-------- scripts/upgrade | 8 ++++---- 4 files changed, 34 insertions(+), 34 deletions(-) diff --git a/scripts/install b/scripts/install index 2c5160f..613e095 100644 --- a/scripts/install +++ b/scripts/install @@ -101,10 +101,10 @@ ynh_app_setting_set "$app" mysqlpwd "$db_password" # CREATE USER FOR EMAIL NOTIFICATIONS #================================================= -smtp_user="$app" -smtp_password=$(dd if=/dev/urandom bs=1 count=200 2> /dev/null | tr -c -d 'A-Za-z0-9' | sed -n 's/\(.\{24\}\).*/\1/p') -sudo useradd -M --shell /bin/false -p $(openssl passwd -1 "$smtp_password") "$smtp_user" -ynh_app_setting_set "$app" smtppwd "$smtp_password" +mattermost_user="$app" +mattermost_user_password=$(dd if=/dev/urandom bs=1 count=200 2> /dev/null | tr -c -d 'A-Za-z0-9' | sed -n 's/\(.\{24\}\).*/\1/p') +sudo useradd -M --shell /bin/false -p $(openssl passwd -1 "$mattermost_user_password") "$mattermost_user" +ynh_app_setting_set "$app" smtppwd "$mattermost_user_password" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -121,25 +121,25 @@ sudo mkdir -p "$logs_path" #================================================= # Configure Service Settings -sudo sed -i "s|\"SiteURL\": \"\"|\"SiteURL\": \"https://${domain}${path_url}\"|g" $final_path/config/config.json -sudo sed -i "s|\"ListenAddress\": \".*\"|\"ListenAddress\": \"127.0.0.1:${port}\"|g" $final_path/config/config.json +sudo sed -i "s|\"SiteURL\": \"\"|\"SiteURL\": \"https://${domain}${path_url}\"|g" $final_path/config/config.json +sudo sed -i "s|\"ListenAddress\": \".*\"|\"ListenAddress\": \"127.0.0.1:${port}\"|g" $final_path/config/config.json # Configure the database connection db_connection_url="${db_user}:${db_password}@tcp(127.0.0.1:3306)/${db_name}?charset=utf8mb4,utf8" -sudo sed -i "s|\"DataSource\": \".*\"|\"DataSource\": \"${db_connection_url}\"|g" $final_path/config/config.json +sudo sed -i "s|\"DataSource\": \".*\"|\"DataSource\": \"${db_connection_url}\"|g" $final_path/config/config.json # Configure uploaded files directory -sudo sed -i "s|\"Directory\": \"./data/\"|\"Directory\": \"${data_path}/\"|g" $final_path/config/config.json +sudo sed -i "s|\"Directory\": \"./data/\"|\"Directory\": \"${data_path}/\"|g" $final_path/config/config.json # Configure SMTP account for sending email notifications -sudo sed -i "s|\"SendEmailNotifications\": false|\"SendEmailNotifications\": true|g" $final_path/config/config.json -sudo sed -i "s|\"FeedbackName\": \"\"|\"FeedbackName\": \"Mattermost notification\"|g" $final_path/config/config.json -sudo sed -i "s|\"FeedbackEmail\": \"\"|\"FeedbackEmail\": \"no-reply@${domain}\"|g" $final_path/config/config.json -sudo sed -i "s|\"SMTPUsername\": \"\"|\"SMTPUsername\": \"${smtp_user}\"|g" $final_path/config/config.json -sudo sed -i "s|\"SMTPPassword\": \"\"|\"SMTPPassword\": \"${smtp_password}\"|g" $final_path/config/config.json -sudo sed -i "s|\"SMTPServer\": \"\"|\"SMTPServer\": \"localhost\"|g" $final_path/config/config.json -sudo sed -i "s|\"SMTPPort\": \"\"|\"SMTPPort\": \"25\"|g" $final_path/config/config.json +sudo sed -i "s|\"SendEmailNotifications\": false|\"SendEmailNotifications\": true|g" $final_path/config/config.json +sudo sed -i "s|\"FeedbackName\": \"\"|\"FeedbackName\": \"Mattermost notification\"|g" $final_path/config/config.json +sudo sed -i "s|\"FeedbackEmail\": \"\"|\"FeedbackEmail\": \"no-reply@${domain}\"|g" $final_path/config/config.json +sudo sed -i "s|\"SMTPUsername\": \"\"|\"SMTPUsername\": \"${mattermost_user}\"|g" $final_path/config/config.json +sudo sed -i "s|\"SMTPPassword\": \"\"|\"SMTPPassword\": \"${mattermost_user_password}\"|g" $final_path/config/config.json +sudo sed -i "s|\"SMTPServer\": \"\"|\"SMTPServer\": \"localhost\"|g" $final_path/config/config.json +sudo sed -i "s|\"SMTPPort\": \"\"|\"SMTPPort\": \"25\"|g" $final_path/config/config.json # Disable Mattermost debug console by default -sudo sed -i "s|\"EnableConsole\": true|\"EnableConsole\": false|g" $final_path/config/config.json +sudo sed -i "s|\"EnableConsole\": true|\"EnableConsole\": false|g" $final_path/config/config.json # Configure log file location -sudo sed -i "s|\"FileLocation\": \"\"|\"FileLocation\": \"$logs_path\"|g" $final_path/config/config.json +sudo sed -i "s|\"FileLocation\": \"\"|\"FileLocation\": \"$logs_path\"|g" $final_path/config/config.json # Configure analytics according to user choice if [ $analytics -eq 0 ]; then sudo sed -i "s|\"EnableDiagnostics\": true|\"EnableDiagnostics\": false|g" $final_path/config/config.json @@ -150,9 +150,9 @@ ynh_app_setting_set "$app" analytics "$analytics" # SECURE FILES AND DIRECTORIES #================================================= -sudo chown -R "$smtp_user:www-data" "$final_path" -sudo chown -R "$smtp_user:www-data" "$data_path" -sudo chown -R "$smtp_user:adm" "$logs_path" +sudo chown -R "$mattermost_user:www-data" "$final_path" +sudo chown -R "$mattermost_user:www-data" "$data_path" +sudo chown -R "$mattermost_user:adm" "$logs_path" #================================================= # NGINX CONFIGURATION diff --git a/scripts/remove b/scripts/remove index cee4c2c..988301f 100755 --- a/scripts/remove +++ b/scripts/remove @@ -17,7 +17,7 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get $app domain) db_name="$app" db_user="mmuser" -smtp_user="$app" +mattermost_user="$app" final_path="/var/www/$app" data_path="/home/yunohost.app/$app" logs_path="/var/log/$app" @@ -77,4 +77,4 @@ sudo rm -rf "$logs_path" # REMOVE DEDICATED USER #================================================= -ynh_system_user_delete "$smtp_user" +ynh_system_user_delete "$mattermost_user" diff --git a/scripts/restore b/scripts/restore index 6ae3cff..d1f4d44 100644 --- a/scripts/restore +++ b/scripts/restore @@ -27,7 +27,7 @@ data_path="/home/yunohost.app/$app" logs_path="/var/log/$app" db_name="$app" db_user="mmuser" -smtp_user="$app" +mattermost_user="$app" #================================================= # CHECK IF THE APP CAN BE RESTORED @@ -71,10 +71,10 @@ ynh_mysql_connect_as "$db_user" "$db_pwd" "$db_name" < ./db.sql #================================================= # Create the dedicated user (if not existing) -smtp_user="$app" -if ! ynh_system_user_exists "$smtp_user"; then - smtp_password=$(ynh_app_setting_get $app smtppwd) - useradd -M --shell /bin/false -p $(openssl passwd -1 "$smtp_password") "$smtp_user" +mattermost_user="$app" +if ! ynh_system_user_exists "$mattermost_user"; then + mattermost_user_password=$(ynh_app_setting_get $app smtppwd) + useradd -M --shell /bin/false -p $(openssl passwd -1 "$mattermost_user_password") "$mattermost_user" fi #================================================= @@ -82,13 +82,13 @@ fi #================================================= # Restore permissions on app files -sudo chown -R "$smtp_user:www-data" "$final_path" +sudo chown -R "$mattermost_user:www-data" "$final_path" mkdir -p "$data_path" -sudo chown -R "$smtp_user:www-data" "$data_path" +sudo chown -R "$mattermost_user:www-data" "$data_path" mkdir -p "$logs_path" -sudo chown -R "$smtp_user:adm" "$logs_path" +sudo chown -R "$mattermost_user:adm" "$logs_path" #================================================= # RESTORE SSOWAT diff --git a/scripts/upgrade b/scripts/upgrade index a101c06..c9a46d7 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -24,7 +24,7 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get $app domain) is_public=$(ynh_app_setting_get $app is_public) port=$(ynh_app_setting_get $app port) -smtp_user="$app" +mattermost_user="$app" root_path="$(pwd)/.." final_path="/var/www/$app" @@ -144,9 +144,9 @@ fi # RESTORE FILE PERMISSIONS #================================================= -sudo chown -R "$smtp_user:www-data" "$final_path" -sudo chown -R "$smtp_user:www-data" "$data_path" -sudo chown -R "$smtp_user:adm" "$logs_path" +sudo chown -R "$mattermost_user:www-data" "$final_path" +sudo chown -R "$mattermost_user:www-data" "$data_path" +sudo chown -R "$mattermost_user:adm" "$logs_path" #================================================= # RELOAD NGINX