restore 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/bin/bash
  2. #=================================================
  3. # IMPORT GENERIC HELPERS
  4. #=================================================
  5. if [ ! -e _common.sh ]; then
  6. # Fetch helpers file if not in current directory
  7. cp ../settings/scripts/_common.sh ./_common.sh
  8. chmod a+rx _common.sh
  9. fi
  10. source _common.sh
  11. source /usr/share/yunohost/helpers
  12. #=================================================
  13. # MANAGE SCRIPT FAILURE
  14. #=================================================
  15. # Exit if an error occurs during the execution of the script
  16. ynh_abort_if_errors
  17. backup_dir="${1}/apps/vpnclient"
  18. sudo mkdir -p /etc/openvpn/
  19. sudo cp -a "${backup_dir}/keys/" /etc/openvpn/
  20. sudo cp -a "${backup_dir}/client.conf.tpl" /etc/openvpn/
  21. sudo chown -R root:admins /etc/openvpn/keys/
  22. gitcommit=$(sudo grep revision /etc/yunohost/apps/vpnclient/status.json | sed 's/.*"revision": "\([^"]\+\)".*/\1/')
  23. tmpdir=$(mktemp -dp /tmp/ vpnclient-restore-XXXXX)
  24. git clone https://github.com/labriqueinternet/vpnclient_ynh.git "${tmpdir}/"
  25. git --work-tree "${tmpdir}/" --git-dir "${tmpdir}/.git/" reset --hard "${gitcommit}"
  26. cd "${tmpdir}/scripts/"
  27. bash ./upgrade
  28. sudo rm -r "${tmpdir}/"