restore 1.3 KB

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