|
@@ -9,28 +9,29 @@ ynh_setting() {
|
|
|
|
|
|
source ./prerequisites
|
|
|
|
|
|
+cachedir=/var/cache/labriqueinternet/
|
|
|
domain=$(ynh_setting vpnclient domain)
|
|
|
path=$(ynh_setting vpnclient path)
|
|
|
server_name=$(ynh_setting vpnclient server_name)
|
|
|
|
|
|
-tmpdir=$(mktemp -dp /tmp/ vpnclient-upgrade-XXXXX)
|
|
|
-sudo cp -a /etc/yunohost/apps/vpnclient/settings.yml "${tmpdir}/"
|
|
|
-sudo cp -a /etc/openvpn/keys/ "${tmpdir}/"
|
|
|
+sudo mkdir -m 0700 -p "${cachedir}/vpnclient/"
|
|
|
+backupdir=$(mktemp -dp ${cachedir}/vpnclient/ upgrade_$(date +%Y-%m-%d-%H%M%S)_XXXXX)
|
|
|
+
|
|
|
+sudo tar czf "${backupdir}/etc_openvpn.tgz" /etc/openvpn/
|
|
|
+sudo cp -a /etc/yunohost/apps/vpnclient/settings.yml "${backupdir}/"
|
|
|
+sudo cp -a /etc/openvpn/keys/ "${backupdir}/"
|
|
|
|
|
|
if [ ! -e /etc/openvpn/client.conf.tpl.restore ] || ! cmp -s /etc/openvpn/client.conf.tpl{,.restore}; then
|
|
|
- sudo cp -a /etc/openvpn/client.conf.tpl "${tmpdir}/"
|
|
|
+ sudo cp -a /etc/openvpn/client.conf.tpl "${backupdir}/"
|
|
|
fi
|
|
|
|
|
|
export VPNCLIENT_UPGRADE=1
|
|
|
-echo "Current path: $PWD"
|
|
|
sudo bash /etc/yunohost/apps/vpnclient/scripts/remove &> /dev/null
|
|
|
-echo "Current path: $PWD"
|
|
|
bash ./install "${domain}" "${path}" "${server_name}"
|
|
|
|
|
|
-sudo cp -a "${tmpdir}/settings.yml" /etc/yunohost/apps/vpnclient/
|
|
|
-sudo cp -a "${tmpdir}/keys/"* /etc/openvpn/keys/ 2> /dev/null
|
|
|
-sudo cp -a "${tmpdir}/client.conf.tpl" /etc/openvpn/ 2> /dev/null
|
|
|
-sudo rm -r "${tmpdir}/"
|
|
|
+sudo cp -a "${backupdir}/settings.yml" /etc/yunohost/apps/vpnclient/
|
|
|
+sudo cp -a "${backupdir}/keys/"* /etc/openvpn/keys/ 2> /dev/null
|
|
|
+sudo cp -a "${backupdir}/client.conf.tpl" /etc/openvpn/ 2> /dev/null
|
|
|
|
|
|
# Changes
|
|
|
|