1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/codimd_ynh.git synced 2024-09-03 18:16:32 +02:00
codimd_ynh/scripts/install

134 lines
3.8 KiB
Text
Raw Normal View History

2018-11-21 16:11:09 +01:00
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
2019-03-13 16:46:11 +01:00
# LOAD SETTINGS
2018-11-21 16:11:09 +01:00
#=================================================
2019-03-13 16:46:11 +01:00
ynh_print_info "Loading installation settings..."
2018-11-21 16:11:09 +01:00
app=$YNH_APP_INSTANCE_NAME
2019-03-13 16:46:11 +01:00
domain=$(ynh_app_setting_get $app domain)
port=$(ynh_app_setting_get $app port)
db_name=$(ynh_app_setting_get $app db_name)
db_user=$db_name
final_path=$(ynh_app_setting_get $app final_path)
2018-11-21 16:11:09 +01:00
#=================================================
2019-03-13 16:46:11 +01:00
# STANDARD REMOVE
#=================================================
# REMOVE SERVICE FROM ADMIN PANEL
2018-11-21 16:11:09 +01:00
#=================================================
2019-03-13 16:46:11 +01:00
# Remove a service from the admin panel, added by `yunohost service add`
if yunohost service status $app >/dev/null 2>&1
then
ynh_print_info "Removing $app service"
yunohost service remove $app
fi
2018-11-21 16:11:09 +01:00
#=================================================
2019-03-13 16:46:11 +01:00
# STOP AND REMOVE SERVICE
2018-11-21 16:11:09 +01:00
#=================================================
2019-03-13 16:46:11 +01:00
ynh_print_info "Stopping and removing the systemd service"
2018-11-21 16:11:09 +01:00
2019-03-13 16:46:11 +01:00
# Remove the dedicated systemd config
ynh_remove_systemd_config
2018-11-21 16:11:09 +01:00
#=================================================
2019-03-13 16:46:11 +01:00
# REMOVE THE POSTGRESQL DATABASE
2018-11-21 16:11:09 +01:00
#=================================================
2019-03-13 16:46:11 +01:00
ynh_print_info "Removing the PostgreSQL database"
2018-11-21 16:11:09 +01:00
2019-03-13 16:46:11 +01:00
# Remove a database if it exists, along with the associated user
ynh_psql_remove_db $db_name $db_name
2018-11-21 16:35:21 +01:00
#=================================================
2019-03-13 16:46:11 +01:00
# REMOVE DEPENDENCIES
2018-11-21 16:35:21 +01:00
#=================================================
2019-03-13 16:46:11 +01:00
ynh_print_info "Removing dependencies"
2018-11-21 16:35:21 +01:00
2019-03-13 16:46:11 +01:00
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
2018-11-21 16:35:21 +01:00
2018-11-21 19:24:30 +01:00
#=================================================
2019-03-13 16:46:11 +01:00
# REMOVE APP MAIN DIR
2018-11-21 19:24:30 +01:00
#=================================================
2019-03-13 16:46:11 +01:00
ynh_print_info "Removing app main directory"
2018-11-21 19:24:30 +01:00
2019-03-13 16:46:11 +01:00
# Remove the app directory securely
ynh_secure_remove "$final_path"
2018-11-21 19:24:30 +01:00
#=================================================
2019-03-13 16:46:11 +01:00
# REMOVE NGINX CONFIGURATION
2018-11-21 19:24:30 +01:00
#=================================================
2019-03-13 16:46:11 +01:00
ynh_print_info "Removing nginx web server configuration"
2018-11-21 19:24:30 +01:00
2019-03-13 16:46:11 +01:00
# Remove the dedicated nginx config
ynh_remove_nginx_config
2018-11-21 16:11:09 +01:00
#=================================================
2019-03-13 16:46:11 +01:00
# REMOVE PHP-FPM CONFIGURATION
2018-11-21 16:11:09 +01:00
#=================================================
2019-03-13 16:46:11 +01:00
#ynh_print_info "Removing php-fpm configuration"
2018-11-21 16:11:09 +01:00
2019-03-13 16:46:11 +01:00
# Remove the dedicated php-fpm config
#ynh_remove_fpm_config
2018-11-21 16:11:09 +01:00
2018-11-21 20:09:14 +01:00
#=================================================
2019-03-13 16:46:11 +01:00
# REMOVE LOGROTATE CONFIGURATION
2018-11-21 20:09:14 +01:00
#=================================================
2019-03-13 16:46:11 +01:00
ynh_print_info "Removing logrotate configuration"
2018-11-21 20:09:14 +01:00
2019-03-13 16:46:11 +01:00
# Remove the app-specific logrotate config
ynh_remove_logrotate
2018-11-21 20:09:14 +01:00
2018-11-21 16:11:09 +01:00
#=================================================
2019-03-13 16:46:11 +01:00
# CLOSE A PORT
2018-11-21 16:11:09 +01:00
#=================================================
2019-03-13 16:46:11 +01:00
if yunohost firewall list | grep -q "\- $port$"
then
ynh_print_info "Closing port $port"
ynh_exec_warn_less yunohost firewall disallow TCP $port
fi
2018-11-21 16:11:09 +01:00
#=================================================
2019-03-13 16:46:11 +01:00
# SPECIFIC REMOVE
#=================================================
# REMOVE THE CRON FILE
2018-11-21 16:11:09 +01:00
#=================================================
2019-03-13 16:46:11 +01:00
# Remove a cron file
ynh_secure_remove "/etc/cron.d/$app"
2018-11-21 16:11:09 +01:00
2019-03-13 16:46:11 +01:00
# Remove a directory securely
ynh_secure_remove "/etc/$app/"
2018-11-21 16:11:09 +01:00
2019-03-13 16:46:11 +01:00
# Remove the log files
ynh_secure_remove "/var/log/$app/"
2018-11-21 16:11:09 +01:00
#=================================================
# GENERIC FINALIZATION
#=================================================
2019-03-13 16:46:11 +01:00
# REMOVE DEDICATED USER
2018-11-21 16:11:09 +01:00
#=================================================
2019-03-13 16:46:11 +01:00
ynh_print_info "Removing the dedicated system user"
2018-11-21 16:11:09 +01:00
2019-03-13 16:46:11 +01:00
# Delete a system user
ynh_system_user_delete $app
2018-11-21 16:11:09 +01:00
#=================================================
2019-03-13 16:46:11 +01:00
# END OF SCRIPT
2018-11-21 16:11:09 +01:00
#=================================================
2019-03-13 16:46:11 +01:00
ynh_print_info "Removal of $app completed"