restore 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. ynh_die "restore script is not implemented yet"
  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. mkdir -p /etc/openvpn/
  22. cp -a "${backup_dir}/keys/" /etc/openvpn/
  23. cp -a "${backup_dir}/client.conf.tpl" /etc/openvpn/
  24. chown -R root:${sysuser} /etc/openvpn/keys/
  25. gitcommit=$(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. rm -r "${tmpdir}/"