_common.sh 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/bin/bash
  2. #
  3. # Common variables and helpers
  4. #
  5. pkg_dependencies="sipcalc dnsutils openvpn curl fake-hwclock"
  6. service_name="ynh-vpnclient"
  7. service_checker_name=$service_name"-checker"
  8. # Operations needed by both 'install' and 'upgrade' scripts
  9. function vpnclient_deploy_files_and_services()
  10. {
  11. # Ensure vpnclient_ynh has its own system user
  12. if ! ynh_system_user_exists ${app}
  13. then
  14. ynh_system_user_create ${app}
  15. fi
  16. # Install command-line cube file loader
  17. install -o root -g root -m 0755 ../conf/$service_name-loadcubefile.sh /usr/local/bin/
  18. # Copy confs
  19. chown root:${app} /etc/openvpn/
  20. chmod 775 /etc/openvpn/
  21. mkdir -pm 0755 /etc/yunohost/hooks.d/post_iptable_rules/
  22. install -b -o root -g ${app} -m 0644 ../conf/openvpn_client.conf.tpl /etc/openvpn/client.conf.tpl
  23. install -b -o root -g root -m 0755 ../conf/hook_post-iptable-rules /etc/yunohost/hooks.d/90-vpnclient.tpl
  24. install -b -o root -g root -m 0644 ../conf/openvpn@.service /etc/systemd/system/
  25. # Create certificates directory
  26. mkdir -pm 0770 /etc/openvpn/keys/
  27. chown root:${app} /etc/openvpn/keys/
  28. #=================================================
  29. # Copy init script
  30. install -o root -g root -m 0755 ../conf/$service_name /usr/local/bin/
  31. # Copy checker timer
  32. install -o root -g root -m 0755 ../conf/$service_checker_name.sh /usr/local/bin/
  33. install -o root -g root -m 0644 ../conf/$service_checker_name.timer /etc/systemd/system/
  34. systemctl daemon-reload
  35. #=================================================
  36. # SETUP SYSTEMD
  37. #=================================================
  38. ynh_print_info "Configuring a systemd service..."
  39. ynh_add_systemd_config $service_name "$service_name.service"
  40. ynh_add_systemd_config $service_checker_name "$service_checker_name.service"
  41. }