1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/mattermost_ynh.git synced 2024-09-03 19:36:29 +02:00
This commit is contained in:
ericgaspar 2021-01-10 20:59:59 +01:00
parent 99da117ae4
commit 89f6da98c1
No known key found for this signature in database
GPG key ID: 574F281483054D44
2 changed files with 36 additions and 19 deletions

View file

@ -87,6 +87,7 @@ db_user=mmuser
db_pwd=$(ynh_string_random --length=30) db_pwd=$(ynh_string_random --length=30)
ynh_app_setting_set --app=$app --key=db_name --value=$db_name ynh_app_setting_set --app=$app --key=db_name --value=$db_name
ynh_app_setting_set --app=$app --key=db_user --value=$db_user
ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd
ynh_psql_test_if_first_run ynh_psql_test_if_first_run

View file

@ -14,12 +14,11 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get $app domain) domain=$(ynh_app_setting_get $app domain)
db_name="$app" db_name=$(ynh_app_setting_get $app db_name)
db_user=$(ynh_app_setting_get $app mysqluser)
db_user=${db_user:-"mmuser"} db_user=${db_user:-"mmuser"}
mattermost_user="$app" final_path=$(ynh_app_setting_get --app=$app --key=final_path)
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"
@ -30,43 +29,53 @@ logs_path="/var/log/$app"
# REMOVE SERVICE FROM ADMIN PANEL # REMOVE SERVICE FROM ADMIN PANEL
#================================================= #=================================================
if yunohost service status | grep -q "$app"; then # Remove the service from the list of services known by Yunohost (added from `yunohost service add`)
yunohost service remove "$app" if ynh_exec_warn_less yunohost service status $app >/dev/null
then
ynh_script_progression --message="Removing $app service..." --weight=1
yunohost service remove $app
fi fi
#================================================= #=================================================
# STOP AND REMOVE SERVICE # STOP AND REMOVE SERVICE
#================================================= #=================================================
ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1
# Remove systemd service # Remove the dedicated systemd config
if $(systemctl -q is-active "$app"); then
systemctl stop "$app"
fi
ynh_remove_systemd_config ynh_remove_systemd_config
# Legacy, for older versions of this app which used supervisor #=================================================
if [ -f "/etc/supervisor/conf.d/${app}.conf" ]; then # REMOVE THE POSTGRESQL DATABASE
supervisorctl stop "$app" #=================================================
ynh_secure_remove --file="/etc/supervisor/conf.d/${app}.conf" ynh_script_progression --message="Removing the PostgreSQL database..." --weight=2
fi
# Remove a database if it exists, along with the associated user
ynh_psql_remove_db --db_user=$db_user --db_name=$db_name
#================================================= #=================================================
# REMOVE THE MYSQL DATABASE # REMOVE DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Removing dependencies..." --weight=1
ynh_mysql_remove_db "$db_user" "$db_name" # Remove metapackage and its dependencies
ynh_remove_app_dependencies
#================================================= #=================================================
# REMOVE APP MAIN DIR # REMOVE APP MAIN DIR
#================================================= #=================================================
ynh_script_progression --message="Removing $app main directory..." --weight=6
# Remove the app directory securely
ynh_secure_remove --file="$final_path"
ynh_secure_remove "$final_path"
ynh_secure_remove "$data_path" ynh_secure_remove "$data_path"
#================================================= #=================================================
# REMOVE NGINX CONFIGURATION # REMOVE NGINX CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Removing NGINX web server configuration..." --weight=5
# Remove the dedicated NGINX config
ynh_remove_nginx_config ynh_remove_nginx_config
#================================================= #=================================================
@ -78,5 +87,12 @@ ynh_secure_remove --file="$logs_path"
#================================================= #=================================================
# REMOVE DEDICATED USER # REMOVE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Removing the dedicated system user..." --weight=1
ynh_system_user_delete "$mattermost_user" ynh_system_user_delete --username=$app
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Removal of $app completed" --last