remove 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #!/bin/bash
  2. # VPN Client app for YunoHost
  3. # Copyright (C) 2015 Julien Vaubourg <julien@vaubourg.com>
  4. # Contribute at https://github.com/labriqueinternet/vpnclient_ynh
  5. #
  6. # This program is free software: you can redistribute it and/or modify
  7. # it under the terms of the GNU Affero General Public License as published by
  8. # the Free Software Foundation, either version 3 of the License, or
  9. # (at your option) any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU Affero General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU Affero General Public License
  17. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. #=================================================
  19. # GENERIC STARTING
  20. #=================================================
  21. # IMPORT GENERIC HELPERS
  22. #=================================================
  23. source _common.sh
  24. source /usr/share/yunohost/helpers
  25. #=================================================
  26. # LOAD SETTINGS
  27. #=================================================
  28. app=$YNH_APP_INSTANCE_NAME
  29. domain=$(ynh_app_setting_get $app domain)
  30. service_name="ynh-vpnclient"
  31. service_checker_name=$service_name"-checker"
  32. #=================================================
  33. # Stop and remove yunohost services
  34. yunohost service stop $service_checker_name
  35. yunohost service disable $service_checker_name
  36. yunohost service remove $service_checker_name
  37. systemctl stop $service_checker_name.timer && sleep 1
  38. systemctl disable $service_checker_name.timer
  39. yunohost service stop $service_name
  40. yunohost service disable $service_name
  41. yunohost service remove $service_name
  42. for FILE in $(ls /etc/systemd/system/$service_name* /usr/local/bin/ynh-vpnclient* /tmp/.ynh-vpnclient-*)
  43. do
  44. ynh_secure_remove "$FILE"
  45. done
  46. # Remove confs
  47. ynh_secure_remove /etc/openvpn/client.conf
  48. ynh_secure_remove /etc/openvpn/client.conf.tpl
  49. ynh_secure_remove /etc/openvpn/client.conf.tpl.restore
  50. ynh_secure_remove /etc/nginx/conf.d/${domain}.d/${app}.conf
  51. ynh_secure_remove /etc/php5/fpm/pool.d/${app}.conf
  52. ynh_secure_remove /etc/yunohost/hooks.d/90-vpnclient.tpl
  53. ynh_secure_remove /etc/systemd/system/openvpn@.service
  54. # Remove certificates
  55. ynh_secure_remove /etc/openvpn/keys
  56. # Remove packages
  57. ynh_remove_app_dependencies
  58. # Remove sources
  59. ynh_secure_remove "/var/www/${app}"
  60. # Reload systemd configuration
  61. systemctl daemon-reload
  62. # Restart services
  63. # (this must happen before deleting the user, otherwise the user is
  64. # being used by one of the php pool process)
  65. systemctl restart php5-fpm
  66. systemctl reload nginx
  67. # Removed system user
  68. ynh_system_user_delete ${app}
  69. ynh_secure_remove "/etc/sudoers.d/${app}_ynh"