restore 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #!/bin/bash
  2. #=================================================
  3. # GENERIC START
  4. #=================================================
  5. # IMPORT GENERIC HELPERS
  6. #=================================================
  7. source ../settings/scripts/_common.sh
  8. source /usr/share/yunohost/helpers
  9. #=================================================
  10. # MANAGE SCRIPT FAILURE
  11. #=================================================
  12. # Exit if an error occurs during the execution of the script
  13. ynh_abort_if_errors
  14. #=================================================
  15. # LOAD SETTINGS
  16. #=================================================
  17. ynh_print_info "Loading settings..."
  18. app=$YNH_APP_INSTANCE_NAME
  19. #=================================================
  20. # RESTORE THE APP MAIN DIR
  21. #=================================================
  22. ynh_print_info "Restoring the app files..."
  23. ynh_restore
  24. #=================================================
  25. # RECREATE THE DEDICATED USER
  26. #=================================================
  27. ynh_print_info "Recreating the dedicated system user..."
  28. # Create the dedicated user (if not existing)
  29. ynh_system_user_create $app
  30. #=================================================
  31. # SPECIFIC RESTORATION
  32. #=================================================
  33. # REINSTALL DEPENDENCIES
  34. #=================================================
  35. ynh_print_info "Reinstalling dependencies..."
  36. # Define and install dependencies
  37. ynh_install_app_dependencies "$pkg_dependencies"
  38. #=================================================
  39. # RESTORE SYSTEMD
  40. #=================================================
  41. ynh_print_info "Restoring the systemd configuration..."
  42. systemctl daemon-reload
  43. systemctl enable "$service_name.service" --quiet
  44. systemctl enable "$service_checker_name.service" --quiet
  45. systemctl enable "openvpn@.service" --quiet
  46. #=================================================
  47. # ADVERTISE SERVICE IN ADMIN PANEL
  48. #=================================================
  49. 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"
  50. #=================================================
  51. # GENERIC FINALIZATION
  52. #=================================================
  53. #=================================================
  54. # END OF SCRIPT
  55. #=================================================
  56. ynh_print_info "Restoration completed for $app"