restore 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #!/bin/bash
  2. source ../settings/scripts/_common.sh
  3. source /usr/share/yunohost/helpers
  4. #=================================================
  5. # RESTORE THE APP MAIN DIR
  6. #=================================================
  7. ynh_print_info "Restoring the app files..."
  8. ynh_restore_file --origin_path="/usr/local/bin/$service_name-loadcubefile.sh"
  9. ynh_restore_file --origin_path="/etc/yunohost/hooks.d/90-vpnclient.tpl"
  10. ynh_restore_file --origin_path="/etc/openvpn/client.conf.tpl"
  11. ynh_restore_file --origin_path="/etc/openvpn/client.conf" --not_mandatory
  12. ynh_restore_file --origin_path="/etc/openvpn/client.cube" --not_mandatory
  13. ynh_restore_file --origin_path="/etc/openvpn/client.ovpn" --not_mandatory
  14. ynh_restore_file --origin_path="/etc/openvpn/scripts/route-up.d/10-set-firewall"
  15. ynh_restore_file --origin_path="/etc/openvpn/scripts/route-up.d/20-set-dns"
  16. ynh_restore_file --origin_path="/etc/openvpn/scripts/route-up.d/30-set-server-ipv6-route"
  17. ynh_restore_file --origin_path="/etc/openvpn/scripts/route-up.d/40-set-ipv6"
  18. ynh_restore_file --origin_path="/etc/openvpn/scripts/route-down.d/10-unset-firewall"
  19. ynh_restore_file --origin_path="/etc/openvpn/scripts/route-down.d/20-unset-dns"
  20. ynh_restore_file --origin_path="/etc/openvpn/scripts/route-down.d/30-unset-server-ipv6-route"
  21. ynh_restore_file --origin_path="/etc/openvpn/scripts/route-down.d/40-unset-ipv6"
  22. ynh_restore_file --origin_path="/etc/openvpn/keys/"
  23. ynh_restore_file --origin_path="/etc/openvpn/scripts/run-parts.sh"
  24. ynh_restore_file --origin_path="/usr/local/bin/$service_name"
  25. ynh_restore_file --origin_path="/usr/local/bin/$service_checker_name.sh"
  26. #=================================================
  27. # RESTORE SYSTEMD
  28. #=================================================
  29. ynh_print_info "Restoring the systemd configuration..."
  30. ynh_restore_file --origin_path="/etc/systemd/system/$service_name.service"
  31. ynh_restore_file --origin_path="/etc/systemd/system/$service_checker_name.service"
  32. ynh_restore_file --origin_path="/etc/systemd/system/$service_checker_name.timer"
  33. ynh_restore_file --origin_path="/etc/systemd/system/openvpn@.service.d/override.conf"
  34. systemctl daemon-reload
  35. systemctl enable "$service_name.service" --quiet
  36. systemctl enable "$service_checker_name.service" --quiet
  37. systemctl enable "openvpn@.service" --quiet
  38. #=================================================
  39. # ADVERTISE SERVICE IN ADMIN PANEL
  40. #=================================================
  41. yunohost service add $service_name --description "Tunnels the internet traffic through a VPN" --need_lock --test_status="systemctl is-active openvpn@client.service" --log "/var/log/ynh-vpnclient.log"
  42. #=================================================
  43. # END OF SCRIPT
  44. #=================================================
  45. ynh_print_info "Restoration completed for $app"