restore 1.2 KB

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