44 lines
1.3 KiB
Bash
44 lines
1.3 KiB
Bash
#!/bin/bash
|
|
|
|
echo "restore script is not implemented"
|
|
exit 0
|
|
#=================================================
|
|
# IMPORT GENERIC HELPERS
|
|
#=================================================
|
|
|
|
if [ ! -e _common.sh ]; then
|
|
# Fetch helpers file if not in current directory
|
|
cp ../settings/scripts/_common.sh ./_common.sh
|
|
chmod a+rx _common.sh
|
|
fi
|
|
source _common.sh
|
|
source /usr/share/yunohost/helpers
|
|
|
|
#=================================================
|
|
# MANAGE SCRIPT FAILURE
|
|
#=================================================
|
|
|
|
# Exit if an error occurs during the execution of the script
|
|
ynh_abort_if_errors
|
|
|
|
#sysuser="${app}"
|
|
sysuser="vpnclient" # XXX hard-coded variable
|
|
|
|
backup_dir="${1}/apps/vpnclient"
|
|
|
|
sudo mkdir -p /etc/openvpn/
|
|
sudo cp -a "${backup_dir}/keys/" /etc/openvpn/
|
|
sudo cp -a "${backup_dir}/client.conf.tpl" /etc/openvpn/
|
|
sudo chown -R root:${sysuser} /etc/openvpn/keys/
|
|
|
|
gitcommit=$(sudo grep revision /etc/yunohost/apps/vpnclient/status.json | sed 's/.*"revision": "\([^"]\+\)".*/\1/')
|
|
tmpdir=$(mktemp -dp /tmp/ vpnclient-restore-XXXXX)
|
|
|
|
git clone https://github.com/labriqueinternet/vpnclient_ynh.git "${tmpdir}/"
|
|
git --work-tree "${tmpdir}/" --git-dir "${tmpdir}/.git/" reset --hard "${gitcommit}"
|
|
|
|
cd "${tmpdir}/scripts/"
|
|
bash ./upgrade
|
|
|
|
sudo rm -r "${tmpdir}/"
|