restore 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. #sysuser="${app}"
  20. sysuser="vpnclient" # XXX hard-coded variable
  21. backup_dir="${1}/apps/vpnclient"
  22. sudo mkdir -p /etc/openvpn/
  23. sudo cp -a "${backup_dir}/keys/" /etc/openvpn/
  24. sudo cp -a "${backup_dir}/client.conf.tpl" /etc/openvpn/
  25. sudo chown -R root:${sysuser} /etc/openvpn/keys/
  26. gitcommit=$(sudo grep revision /etc/yunohost/apps/vpnclient/status.json | sed 's/.*"revision": "\([^"]\+\)".*/\1/')
  27. tmpdir=$(mktemp -dp /tmp/ vpnclient-restore-XXXXX)
  28. git clone https://github.com/labriqueinternet/vpnclient_ynh.git "${tmpdir}/"
  29. git --work-tree "${tmpdir}/" --git-dir "${tmpdir}/.git/" reset --hard "${gitcommit}"
  30. cd "${tmpdir}/scripts/"
  31. bash ./upgrade
  32. sudo rm -r "${tmpdir}/"