1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/mattermost_ynh.git synced 2024-09-03 19:36:29 +02:00

scripts: rename smtp_user to mattermost_user

This commit is contained in:
Pierre de La Morinerie 2018-01-30 12:19:02 +05:30
parent 256cafcb07
commit 3c9e53fe57
4 changed files with 34 additions and 34 deletions

View file

@ -101,10 +101,10 @@ ynh_app_setting_set "$app" mysqlpwd "$db_password"
# CREATE USER FOR EMAIL NOTIFICATIONS # CREATE USER FOR EMAIL NOTIFICATIONS
#================================================= #=================================================
smtp_user="$app" mattermost_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') 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 "$smtp_password") "$smtp_user" sudo useradd -M --shell /bin/false -p $(openssl passwd -1 "$mattermost_user_password") "$mattermost_user"
ynh_app_setting_set "$app" smtppwd "$smtp_password" ynh_app_setting_set "$app" smtppwd "$mattermost_user_password"
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
@ -121,25 +121,25 @@ sudo mkdir -p "$logs_path"
#================================================= #=================================================
# Configure Service Settings # Configure Service Settings
sudo sed -i "s|\"SiteURL\": \"\"|\"SiteURL\": \"https://${domain}${path_url}\"|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 sudo sed -i "s|\"ListenAddress\": \".*\"|\"ListenAddress\": \"127.0.0.1:${port}\"|g" $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"
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 # 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 # 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|\"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|\"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|\"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|\"SMTPUsername\": \"\"|\"SMTPUsername\": \"${mattermost_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|\"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|\"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|\"SMTPPort\": \"\"|\"SMTPPort\": \"25\"|g" $final_path/config/config.json
# Disable Mattermost debug console by default # 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 # 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 # Configure analytics according to user choice
if [ $analytics -eq 0 ]; then if [ $analytics -eq 0 ]; then
sudo sed -i "s|\"EnableDiagnostics\": true|\"EnableDiagnostics\": false|g" $final_path/config/config.json 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 # SECURE FILES AND DIRECTORIES
#================================================= #=================================================
sudo chown -R "$smtp_user:www-data" "$final_path" sudo chown -R "$mattermost_user:www-data" "$final_path"
sudo chown -R "$smtp_user:www-data" "$data_path" sudo chown -R "$mattermost_user:www-data" "$data_path"
sudo chown -R "$smtp_user:adm" "$logs_path" sudo chown -R "$mattermost_user:adm" "$logs_path"
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION

View file

@ -17,7 +17,7 @@ app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get $app domain) domain=$(ynh_app_setting_get $app domain)
db_name="$app" db_name="$app"
db_user="mmuser" db_user="mmuser"
smtp_user="$app" mattermost_user="$app"
final_path="/var/www/$app" final_path="/var/www/$app"
data_path="/home/yunohost.app/$app" data_path="/home/yunohost.app/$app"
logs_path="/var/log/$app" logs_path="/var/log/$app"
@ -77,4 +77,4 @@ sudo rm -rf "$logs_path"
# REMOVE DEDICATED USER # REMOVE DEDICATED USER
#================================================= #=================================================
ynh_system_user_delete "$smtp_user" ynh_system_user_delete "$mattermost_user"

View file

@ -27,7 +27,7 @@ data_path="/home/yunohost.app/$app"
logs_path="/var/log/$app" logs_path="/var/log/$app"
db_name="$app" db_name="$app"
db_user="mmuser" db_user="mmuser"
smtp_user="$app" mattermost_user="$app"
#================================================= #=================================================
# CHECK IF THE APP CAN BE RESTORED # 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) # Create the dedicated user (if not existing)
smtp_user="$app" mattermost_user="$app"
if ! ynh_system_user_exists "$smtp_user"; then if ! ynh_system_user_exists "$mattermost_user"; then
smtp_password=$(ynh_app_setting_get $app smtppwd) mattermost_user_password=$(ynh_app_setting_get $app smtppwd)
useradd -M --shell /bin/false -p $(openssl passwd -1 "$smtp_password") "$smtp_user" useradd -M --shell /bin/false -p $(openssl passwd -1 "$mattermost_user_password") "$mattermost_user"
fi fi
#================================================= #=================================================
@ -82,13 +82,13 @@ fi
#================================================= #=================================================
# Restore permissions on app files # 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" 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" mkdir -p "$logs_path"
sudo chown -R "$smtp_user:adm" "$logs_path" sudo chown -R "$mattermost_user:adm" "$logs_path"
#================================================= #=================================================
# RESTORE SSOWAT # RESTORE SSOWAT

View file

@ -24,7 +24,7 @@ app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get $app domain) domain=$(ynh_app_setting_get $app domain)
is_public=$(ynh_app_setting_get $app is_public) is_public=$(ynh_app_setting_get $app is_public)
port=$(ynh_app_setting_get $app port) port=$(ynh_app_setting_get $app port)
smtp_user="$app" mattermost_user="$app"
root_path="$(pwd)/.." root_path="$(pwd)/.."
final_path="/var/www/$app" final_path="/var/www/$app"
@ -144,9 +144,9 @@ fi
# RESTORE FILE PERMISSIONS # RESTORE FILE PERMISSIONS
#================================================= #=================================================
sudo chown -R "$smtp_user:www-data" "$final_path" sudo chown -R "$mattermost_user:www-data" "$final_path"
sudo chown -R "$smtp_user:www-data" "$data_path" sudo chown -R "$mattermost_user:www-data" "$data_path"
sudo chown -R "$smtp_user:adm" "$logs_path" sudo chown -R "$mattermost_user:adm" "$logs_path"
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX