install 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. domain=$YNH_APP_ARG_DOMAIN
  35. path_url=$YNH_APP_ARG_PATH
  36. app=$YNH_APP_INSTANCE_NAME
  37. final_path="/var/www/$app"
  38. #=================================================
  39. # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
  40. #=================================================
  41. ynh_script_progression "Validating installation parameters..."
  42. # Check destination directory
  43. test ! -e "$final_path" || ynh_die "Path is already in use: ${final_path}."
  44. # Register (book) web path
  45. ynh_webpath_register "$app" "$domain" "$path_url"
  46. #=================================================
  47. # STORE SETTINGS FROM MANIFEST
  48. #=================================================
  49. ynh_script_progression "Storing installation settings..."
  50. ynh_app_setting_set "$app" domain "$domain"
  51. ynh_app_setting_set "$app" final_path "$final_path"
  52. # Default values for config panel
  53. ynh_app_setting_set "$app" service_enabled 0
  54. ynh_app_setting_set "$app" dns_method "pushed"
  55. ynh_app_setting_set "$app" nameservers ""
  56. ynh_app_setting_set "$app" ip6_addr ""
  57. #=================================================
  58. # STANDARD MODIFICATIONS
  59. #=================================================
  60. # INSTALL DEPENDENCIES
  61. #=================================================
  62. ynh_script_progression "Installing dependencies..."
  63. ynh_install_app_dependencies "$pkg_dependencies"
  64. #=================================================
  65. # DEPLOY FILES FROM PACKAGE
  66. #=================================================
  67. ynh_script_progression "Deploy files from package..."
  68. vpnclient_deploy_files_and_services
  69. #=================================================
  70. # RELOAD SERVICES
  71. #=================================================
  72. ynh_script_progression "Reloading services..."
  73. # Set default inits
  74. # The boot order of these services are important, so they are disabled by default
  75. # and the vpnclient service handles them.
  76. systemctl disable openvpn --quiet
  77. systemctl stop openvpn
  78. # main service
  79. 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"
  80. yunohost service enable $service_name
  81. # checker service
  82. systemctl start $service_checker_name
  83. systemctl enable $service_checker_name --quiet
  84. systemctl start $service_checker_name.timer
  85. systemctl enable $service_checker_name.timer --quiet
  86. #=================================================
  87. # END OF SCRIPT
  88. #=================================================
  89. ynh_script_progression --message="Installation of $app completed" --last