mirror of
https://github.com/YunoHost-Apps/mattermost_ynh.git
synced 2024-09-03 19:36:29 +02:00
scripts: support multi-instance install
This commit is contained in:
parent
0918978e92
commit
256cafcb07
6 changed files with 30 additions and 26 deletions
|
@ -13,7 +13,7 @@
|
|||
setup_public=1
|
||||
upgrade=1
|
||||
backup_restore=1
|
||||
multi_instance=0
|
||||
multi_instance=1
|
||||
port_already_use=1 (8085)
|
||||
# Checks not supported yet
|
||||
change_url=0
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
"name": "pmorinerie",
|
||||
"email": "kemenaran@gmail.com"
|
||||
},
|
||||
"multi_instance": false,
|
||||
"multi_instance": true,
|
||||
"services": [
|
||||
"nginx"
|
||||
],
|
||||
|
|
|
@ -91,19 +91,20 @@ logs_path="/var/log/$app"
|
|||
# CREATE A MYSQL DATABASE
|
||||
#=================================================
|
||||
|
||||
db_name="mattermost"
|
||||
db_name="$app"
|
||||
db_user="mmuser"
|
||||
db_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')
|
||||
ynh_mysql_create_db $db_name $db_user $db_password
|
||||
ynh_app_setting_set mattermost mysqlpwd "$db_password"
|
||||
ynh_mysql_create_db "$db_name" "$db_user" "$db_password"
|
||||
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") "mattermost"
|
||||
ynh_app_setting_set mattermost smtppwd "$smtp_password"
|
||||
sudo useradd -M --shell /bin/false -p $(openssl passwd -1 "$smtp_password") "$smtp_user"
|
||||
ynh_app_setting_set "$app" smtppwd "$smtp_password"
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
|
@ -131,7 +132,7 @@ sudo sed -i "s|\"Directory\": \"./data/\"|\"Directory\": \"${data_path}/\"|g"
|
|||
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\"|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
|
||||
|
@ -149,9 +150,9 @@ ynh_app_setting_set "$app" analytics "$analytics"
|
|||
# SECURE FILES AND DIRECTORIES
|
||||
#=================================================
|
||||
|
||||
sudo chown -R mattermost:www-data "$final_path"
|
||||
sudo chown -R mattermost:www-data "$data_path"
|
||||
sudo chown -R mattermost:adm "$logs_path"
|
||||
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"
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
|
@ -192,4 +193,4 @@ sudo systemctl reload nginx
|
|||
# START SERVER
|
||||
#=================================================
|
||||
|
||||
sudo systemctl start mattermost
|
||||
sudo systemctl start "$app"
|
||||
|
|
|
@ -14,9 +14,10 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
domain=$(ynh_app_setting_get mattermost domain)
|
||||
db_name="mattermost"
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
db_name="$app"
|
||||
db_user="mmuser"
|
||||
smtp_user="$app"
|
||||
final_path="/var/www/$app"
|
||||
data_path="/home/yunohost.app/$app"
|
||||
logs_path="/var/log/$app"
|
||||
|
@ -76,4 +77,4 @@ sudo rm -rf "$logs_path"
|
|||
# REMOVE DEDICATED USER
|
||||
#=================================================
|
||||
|
||||
ynh_system_user_delete "$app"
|
||||
ynh_system_user_delete "$smtp_user"
|
||||
|
|
|
@ -27,6 +27,7 @@ data_path="/home/yunohost.app/$app"
|
|||
logs_path="/var/log/$app"
|
||||
db_name="$app"
|
||||
db_user="mmuser"
|
||||
smtp_user="$app"
|
||||
|
||||
#=================================================
|
||||
# CHECK IF THE APP CAN BE RESTORED
|
||||
|
@ -62,8 +63,8 @@ ynh_restore_file "$data_path"
|
|||
#=================================================
|
||||
|
||||
db_pwd=$(ynh_app_setting_get $app mysqlpwd)
|
||||
ynh_mysql_setup_db $db_user $db_name $db_pwd
|
||||
ynh_mysql_connect_as $db_user $db_pwd $db_name < ./db.sql
|
||||
ynh_mysql_setup_db "$db_user" "$db_name" "$db_pwd"
|
||||
ynh_mysql_connect_as "$db_user" "$db_pwd" "$db_name" < ./db.sql
|
||||
|
||||
#=================================================
|
||||
# RECREATE THE DEDICATED USER
|
||||
|
@ -81,13 +82,13 @@ fi
|
|||
#=================================================
|
||||
|
||||
# Restore permissions on app files
|
||||
sudo chown -R mattermost:www-data "$final_path"
|
||||
sudo chown -R "$smtp_user:www-data" "$final_path"
|
||||
|
||||
mkdir -p "$data_path"
|
||||
sudo chown -R mattermost:www-data "$data_path"
|
||||
sudo chown -R "$smtp_user:www-data" "$data_path"
|
||||
|
||||
mkdir -p "$logs_path"
|
||||
sudo chown -R mattermost:adm "$logs_path"
|
||||
sudo chown -R "$smtp_user:adm" "$logs_path"
|
||||
|
||||
#=================================================
|
||||
# RESTORE SSOWAT
|
||||
|
|
|
@ -21,9 +21,10 @@ ynh_abort_if_errors
|
|||
#=================================================
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
domain=$(ynh_app_setting_get mattermost domain)
|
||||
is_public=$(ynh_app_setting_get mattermost is_public)
|
||||
port=$(ynh_app_setting_get mattermost port)
|
||||
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"
|
||||
|
||||
root_path="$(pwd)/.."
|
||||
final_path="/var/www/$app"
|
||||
|
@ -143,9 +144,9 @@ fi
|
|||
# RESTORE FILE PERMISSIONS
|
||||
#=================================================
|
||||
|
||||
sudo chown -R mattermost:www-data "$final_path"
|
||||
sudo chown -R mattermost:www-data "$data_path"
|
||||
sudo chown -R mattermost:adm "$logs_path"
|
||||
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"
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
|
|
Loading…
Reference in a new issue