remove 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. systemctl stop $service_checker_name
  36. systemctl disable $service_checker_name
  37. systemctl stop $service_checker_name.timer && sleep 1
  38. systemctl disable $service_checker_name.timer
  39. if ynh_exec_warn_less yunohost service status $service_name >/dev/null
  40. then
  41. yunohost service stop $service_name
  42. yunohost service disable $service_name
  43. yunohost service remove $service_checker
  44. fi
  45. for FILE in $(ls /etc/systemd/system/$service_name* /usr/local/bin/ynh-vpnclient* /tmp/.ynh-vpnclient-*)
  46. do
  47. ynh_secure_remove "$FILE"
  48. done
  49. #=================================================
  50. # REMOVE NGINX CONFIGURATION
  51. #=================================================
  52. ynh_print_info "Removing NGINX web server configuration"
  53. # Remove the dedicated NGINX config
  54. ynh_remove_nginx_config
  55. #=================================================
  56. # REMOVE PHP-FPM CONFIGURATION
  57. #=================================================
  58. ynh_print_info "Removing PHP-FPM configuration"
  59. # Remove the dedicated PHP-FPM config
  60. ynh_remove_fpm_config
  61. #=================================================
  62. # SPECIFIC REMOVE
  63. #================================================
  64. ynh_print_info "Removing openvpn configuration"
  65. # Remove openvpn configurations
  66. ynh_secure_remove /etc/openvpn/client.conf
  67. ynh_secure_remove /etc/openvpn/client.conf.tpl
  68. ynh_secure_remove /etc/openvpn/client.conf.tpl.restore
  69. # Remove YunoHost hook
  70. ynh_secure_remove /etc/yunohost/hooks.d/90-vpnclient.tpl
  71. # Remove openvpn service
  72. ynh_secure_remove /etc/systemd/system/openvpn@.service
  73. # Remove openvpn certificates
  74. ynh_secure_remove /etc/openvpn/keys
  75. # Reload systemd configuration
  76. systemctl daemon-reload
  77. #=================================================
  78. # REMOVE DEPENDENCIES
  79. #=================================================
  80. ynh_print_info "Removing dependencies"
  81. ynh_remove_app_dependencies
  82. # Remove sources
  83. ynh_secure_remove "/var/www/${app}"
  84. #=================================================
  85. # REMOVE DEDICATED USER
  86. #=================================================
  87. ynh_print_info "Removing the dedicated system user"
  88. # Delete a system user
  89. ynh_system_user_delete ${app}
  90. ynh_secure_remove "/etc/sudoers.d/${app}_ynh"
  91. #=================================================
  92. # END OF SCRIPT
  93. #=================================================
  94. ynh_print_info "Removal of $app completed"