install 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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 START
  20. #=================================================
  21. # IMPORT GENERIC HELPERS
  22. #=================================================
  23. source _common.sh
  24. source /usr/share/yunohost/helpers
  25. #=================================================
  26. # MANAGE SCRIPT FAILURE
  27. #=================================================
  28. # Exit if an error occurs during the execution of the script
  29. ynh_abort_if_errors
  30. #=================================================
  31. # RETRIEVE ARGUMENTS FROM THE MANIFEST
  32. #=================================================
  33. # Retrieve arguments
  34. app=$YNH_APP_INSTANCE_NAME
  35. #=================================================
  36. # STORE SETTINGS FROM MANIFEST
  37. #=================================================
  38. ynh_script_progression "Storing installation settings..."
  39. # Default values for config panel
  40. ynh_app_setting_set "$app" service_enabled 0
  41. ynh_app_setting_set "$app" dns_method "yunohost"
  42. ynh_app_setting_set "$app" nameservers ""
  43. ynh_app_setting_set "$app" ip6_addr ""
  44. ynh_app_setting_set "$app" ip6_net ""
  45. #=================================================
  46. # STANDARD MODIFICATIONS
  47. #=================================================
  48. # INSTALL DEPENDENCIES
  49. #=================================================
  50. ynh_script_progression "Installing dependencies..."
  51. ynh_install_app_dependencies "$pkg_dependencies"
  52. #=================================================
  53. # DEPLOY FILES FROM PACKAGE
  54. #=================================================
  55. ynh_script_progression "Deploy files from package..."
  56. vpnclient_deploy_files_and_services
  57. #=================================================
  58. # RELOAD SERVICES
  59. #=================================================
  60. ynh_script_progression "Reloading services..."
  61. # Set default inits
  62. # The boot order of these services are important, so they are disabled by default
  63. # and the vpnclient service handles them.
  64. systemctl disable openvpn --quiet
  65. systemctl stop openvpn
  66. # main service
  67. 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"
  68. yunohost service enable $service_name
  69. # checker service
  70. systemctl start $service_checker_name
  71. systemctl enable $service_checker_name --quiet
  72. systemctl start $service_checker_name.timer
  73. systemctl enable $service_checker_name.timer --quiet
  74. #=================================================
  75. # END OF SCRIPT
  76. #=================================================
  77. ynh_script_progression --message="Installation of $app completed" --last