remove 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. #=================================================
  31. # STOP AND REMOVE SERVICES
  32. #=================================================
  33. ynh_print_info "Stopping and removing services"
  34. systemctl stop $service_checker_name
  35. systemctl disable $service_checker_name --quiet
  36. systemctl stop $service_checker_name.timer && sleep 1
  37. systemctl disable $service_checker_name.timer --quiet
  38. if ynh_exec_warn_less yunohost service status $service_name >/dev/null
  39. then
  40. yunohost service stop $service_name
  41. yunohost service disable $service_name --quiet
  42. yunohost service remove $service_name
  43. fi
  44. for FILE in $(ls /etc/systemd/system/$service_name* /usr/local/bin/ynh-vpnclient* /tmp/.ynh-vpnclient-*)
  45. do
  46. ynh_secure_remove "$FILE"
  47. done
  48. #=================================================
  49. # SPECIFIC REMOVE
  50. #================================================
  51. ynh_print_info "Removing openvpn configuration"
  52. # Remove openvpn configurations
  53. ynh_secure_remove /etc/openvpn/client.conf
  54. ynh_secure_remove /etc/openvpn/client.conf.tpl
  55. ynh_secure_remove /etc/openvpn/client.conf.tpl.restore
  56. # Remove YunoHost hook
  57. ynh_secure_remove /etc/yunohost/hooks.d/90-vpnclient.tpl
  58. # Remove openvpn service
  59. ynh_secure_remove /etc/systemd/system/openvpn@.service
  60. # Remove openvpn certificates
  61. ynh_secure_remove /etc/openvpn/keys
  62. # Reload systemd configuration
  63. systemctl daemon-reload
  64. #=================================================
  65. # REMOVE DEPENDENCIES
  66. #=================================================
  67. ynh_print_info "Removing dependencies"
  68. ynh_remove_app_dependencies
  69. # Remove sources
  70. ynh_secure_remove "/var/www/${app}"
  71. #=================================================
  72. # REMOVE DEDICATED USER
  73. #=================================================
  74. ynh_print_info "Removing the dedicated system user"
  75. # Delete a system user
  76. ynh_system_user_delete ${app}
  77. ynh_secure_remove "/etc/sudoers.d/${app}_ynh"
  78. #=================================================
  79. # END OF SCRIPT
  80. #=================================================
  81. ynh_print_info "Removal of $app completed"