remove 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #!/bin/bash
  2. source _common.sh
  3. source /usr/share/yunohost/helpers
  4. #=================================================
  5. # STOP AND REMOVE SERVICES
  6. #=================================================
  7. ynh_print_info "Stopping and removing services"
  8. systemctl stop $service_checker_name.timer && sleep 1
  9. systemctl disable $service_checker_name.timer --quiet
  10. systemctl stop $service_checker_name
  11. systemctl disable $service_checker_name --quiet
  12. if ynh_exec_warn_less yunohost service status $service_name >/dev/null
  13. then
  14. yunohost service stop $service_name
  15. yunohost service disable $service_name --quiet
  16. yunohost service remove $service_name
  17. fi
  18. for FILE in $(ls /etc/systemd/system/$service_name* /usr/local/bin/ynh-vpnclient* /tmp/.ynh-vpnclient-*)
  19. do
  20. ynh_secure_remove "$FILE"
  21. done
  22. #=================================================
  23. # SPECIFIC REMOVE
  24. #================================================
  25. ynh_print_info "Removing openvpn configuration"
  26. # Remove openvpn configurations
  27. ynh_secure_remove /etc/openvpn/client.conf
  28. ynh_secure_remove /etc/openvpn/client.conf.tpl
  29. ynh_secure_remove /etc/openvpn/client.cube
  30. ynh_secure_remove /etc/openvpn/client.ovpn
  31. # Remove openvpn script
  32. ynh_secure_remove /etc/openvpn/scripts/run-parts.sh
  33. ynh_secure_remove "/etc/openvpn/scripts/route-up.d/10-set-firewall"
  34. ynh_secure_remove "/etc/openvpn/scripts/route-up.d/20-set-dns"
  35. ynh_secure_remove "/etc/openvpn/scripts/route-up.d/30-set-server-ipv6-route"
  36. ynh_secure_remove "/etc/openvpn/scripts/route-up.d/40-set-ipv6"
  37. ynh_secure_remove "/etc/openvpn/scripts/route-down.d/10-unset-firewall"
  38. ynh_secure_remove "/etc/openvpn/scripts/route-down.d/20-unset-dns"
  39. ynh_secure_remove "/etc/openvpn/scripts/route-down.d/30-unset-server-ipv6-route"
  40. ynh_secure_remove "/etc/openvpn/scripts/route-down.d/40-unset-ipv6"
  41. # Remove YunoHost hook
  42. ynh_secure_remove /etc/yunohost/hooks.d/90-vpnclient.tpl
  43. # Remove openvpn service
  44. ynh_secure_remove /etc/systemd/system/openvpn@.service.d/override.conf
  45. # Remove openvpn certificates
  46. ynh_secure_remove /etc/openvpn/keys
  47. # Reload systemd configuration
  48. systemctl daemon-reload
  49. # Make sure to reload the firewall now that the post_iptables_rules ain't there anymore
  50. ynh_print_info "Reloading firewall"
  51. yunohost firewall reload
  52. #=================================================
  53. # END OF SCRIPT
  54. #=================================================
  55. ynh_print_info "Removal of $app completed"