restore 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 start "$service_checker_name.service"
  45. systemctl enable "$service_checker_name.service" --quiet
  46. systemctl start "$service_checker_name.timer"
  47. systemctl enable "$service_checker_name.timer" --quiet
  48. systemctl enable "openvpn@.service" --quiet
  49. #=================================================
  50. # ADVERTISE SERVICE IN ADMIN PANEL
  51. #=================================================
  52. 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"
  53. #=================================================
  54. # GENERIC FINALIZATION
  55. #=================================================
  56. #=================================================
  57. # END OF SCRIPT
  58. #=================================================
  59. ynh_print_info "Restoration completed for $app"