remove 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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. ynh_print_info "Loading installation settings..."
  29. app=$YNH_APP_INSTANCE_NAME
  30. domain=$(ynh_app_setting_get $app domain)
  31. #=================================================
  32. # STOP AND REMOVE SERVICES
  33. #=================================================
  34. ynh_print_info "Stopping and removing services"
  35. yunohost service stop $service_checker_name
  36. yunohost service disable $service_checker_name
  37. yunohost service remove $service_checker_name
  38. systemctl stop $service_checker_name.timer && sleep 1
  39. systemctl disable $service_checker_name.timer
  40. yunohost service stop $service_name
  41. yunohost service disable $service_name
  42. yunohost service remove $service_name
  43. for FILE in $(ls /etc/systemd/system/$service_name* /usr/local/bin/ynh-vpnclient* /tmp/.ynh-vpnclient-*)
  44. do
  45. ynh_secure_remove "$FILE"
  46. done
  47. #=================================================
  48. # REMOVE NGINX CONFIGURATION
  49. #=================================================
  50. ynh_print_info "Removing nginx web server configuration"
  51. # Remove the dedicated nginx config
  52. ynh_remove_nginx_config
  53. #=================================================
  54. # REMOVE PHP-FPM CONFIGURATION
  55. #=================================================
  56. ynh_print_info "Removing php-fpm configuration"
  57. # Remove the dedicated php-fpm config
  58. ynh_remove_fpm_config
  59. #=================================================
  60. # SPECIFIC REMOVE
  61. #================================================
  62. ynh_print_info "Removing openvpn configuration"
  63. # Remove openvpn configurations
  64. ynh_secure_remove /etc/openvpn/client.conf
  65. ynh_secure_remove /etc/openvpn/client.conf.tpl
  66. ynh_secure_remove /etc/openvpn/client.conf.tpl.restore
  67. # Remove YunoHost hook
  68. ynh_secure_remove /etc/yunohost/hooks.d/90-vpnclient.tpl
  69. # Remove openvpn service
  70. ynh_secure_remove /etc/systemd/system/openvpn@.service
  71. # Remove openvpn certificates
  72. ynh_secure_remove /etc/openvpn/keys
  73. #=================================================
  74. # REMOVE DEPENDENCIES
  75. #=================================================
  76. ynh_print_info "Removing dependencies"
  77. ynh_remove_app_dependencies
  78. # Remove sources
  79. ynh_secure_remove "/var/www/${app}"
  80. # Reload systemd configuration
  81. systemctl daemon-reload
  82. # Restart services
  83. # (this must happen before deleting the user, otherwise the user is
  84. # being used by one of the php pool process)
  85. systemctl restart php7.0-fpm
  86. systemctl reload nginx
  87. #=================================================
  88. # REMOVE DEDICATED USER
  89. #=================================================
  90. ynh_print_info "Removing the dedicated system user"
  91. # Delete a system user
  92. ynh_system_user_delete ${app}
  93. ynh_secure_remove "/etc/sudoers.d/${app}_ynh"
  94. #=================================================
  95. # END OF SCRIPT
  96. #=================================================
  97. ynh_print_info "Removal of $app completed"