2019-02-27 21:45:28 +01:00

127 lines
4.0 KiB
Bash

#!/bin/bash
# VPN Client app for YunoHost
# Copyright (C) 2015 Julien Vaubourg <julien@vaubourg.com>
# Contribute at https://github.com/labriqueinternet/vpnclient_ynh
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#=================================================
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_print_info "Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get $app domain)
service_name=$(ynh_app_setting_get $app service_name)
service_checker_name=$service_name"-checker"
#=================================================
# STOP AND REMOVE SERVICES
#=================================================
ynh_print_info "Stopping and removing services"
yunohost service stop $service_checker_name
yunohost service disable $service_checker_name
yunohost service remove $service_checker_name
systemctl stop $service_checker_name.timer && sleep 1
systemctl disable $service_checker_name.timer
yunohost service stop $service_name
yunohost service disable $service_name
yunohost service remove $service_name
for FILE in $(ls /etc/systemd/system/$service_name* /usr/local/bin/ynh-vpnclient* /tmp/.ynh-vpnclient-*)
do
ynh_secure_remove "$FILE"
done
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
ynh_print_info "Removing nginx web server configuration"
# Remove the dedicated nginx config
ynh_remove_nginx_config
#=================================================
# REMOVE PHP-FPM CONFIGURATION
#=================================================
ynh_print_info "Removing php-fpm configuration"
# Remove the dedicated php-fpm config
ynh_remove_fpm_config
#=================================================
# SPECIFIC REMOVE
#================================================
ynh_print_info "Removing openvpn configuration"
# Remove openvpn configurations
ynh_secure_remove /etc/openvpn/client.conf
ynh_secure_remove /etc/openvpn/client.conf.tpl
ynh_secure_remove /etc/openvpn/client.conf.tpl.restore
# Remove YunoHost hook
ynh_secure_remove /etc/yunohost/hooks.d/90-vpnclient.tpl
# Remove openvpn service
ynh_secure_remove /etc/systemd/system/openvpn@.service
# Remove openvpn certificates
ynh_secure_remove /etc/openvpn/keys
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_print_info "Removing dependencies"
ynh_remove_app_dependencies
# Remove sources
ynh_secure_remove "/var/www/${app}"
# Reload systemd configuration
systemctl daemon-reload
# Restart services
# (this must happen before deleting the user, otherwise the user is
# being used by one of the php pool process)
systemctl restart php7.0-fpm
systemctl reload nginx
#=================================================
# REMOVE DEDICATED USER
#=================================================
ynh_print_info "Removing the dedicated system user"
# Delete a system user
ynh_system_user_delete ${app}
ynh_secure_remove "/etc/sudoers.d/${app}_ynh"
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info "Removal of $app completed"