Add backup/restore scripts

This commit is contained in:
Julien VAUBOURG 2015-07-25 16:33:57 +02:00
parent 99f5652af4
commit 6bc8691d4d
4 changed files with 37 additions and 3 deletions

10
scripts/backup Normal file
View File

@ -0,0 +1,10 @@
#!/bin/bash
# The parameter $1 is the backup directory location
# which will be compressed afterward
backup_dir="${1}/apps/vpnclient"
mkdir -p "${backup_dir}/"
sudo cp -a /etc/openvpn/keys/ "${backup_dir}/"
exit 0

View File

@ -18,7 +18,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# This is an upgrade? # This is an upgrade?
upgrade=$([ "$VPNCLIENT_UPGRADE" == 1 ] && echo true || echo false) upgrade=$([ "${VPNCLIENT_UPGRADE}" == 1 ] && echo true || echo false)
# Retrieve arguments # Retrieve arguments
domain=${1} domain=${1}
@ -55,7 +55,7 @@ fi
if ! $upgrade; then if ! $upgrade; then
# Save arguments # Save arguments
sudo yunohost app setting vpnclient service_enabled -v 1 sudo yunohost app setting vpnclient service_enabled -v 0
sudo yunohost app setting vpnclient server_name -v "${server_name}" sudo yunohost app setting vpnclient server_name -v "${server_name}"
sudo yunohost app setting vpnclient server_port -v 1194 sudo yunohost app setting vpnclient server_port -v 1194
sudo yunohost app setting vpnclient server_proto -v udp sudo yunohost app setting vpnclient server_proto -v udp
@ -66,6 +66,10 @@ if ! $upgrade; then
fi fi
# Save git commit
gitcommit=$(git rev-parse HEAD)
sudo yunohost app setting vpnclient gitcommit -v "${gitcommit}"
# Install IPv6 scripts # Install IPv6 scripts
sudo install -o root -g root -m 0755 ../conf/ipv6_expanded /usr/local/bin/ sudo install -o root -g root -m 0755 ../conf/ipv6_expanded /usr/local/bin/
sudo install -o root -g root -m 0755 ../conf/ipv6_compressed /usr/local/bin/ sudo install -o root -g root -m 0755 ../conf/ipv6_compressed /usr/local/bin/

20
scripts/restore Normal file
View File

@ -0,0 +1,20 @@
#!/bin/bash
# The parameter $1 is the uncompressed restore directory location
backup_dir="${1}/apps/vpnclient"
mkdir -p /etc/openvpn/
cp -a "${backup_dir}/keys/" /etc/openvpn/
gitcommit=$(sudo yunohost app setting vpnclient gitcommit)
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/"
./upgrade
sudo rm -r "${tmpdir}/"
exit 0

View File

@ -15,7 +15,7 @@ tmpdir=$(mktemp -dp /tmp/ vpnclient-upgrade-XXXXX)
sudo cp -a /etc/openvpn/keys/ "${tmpdir}/" sudo cp -a /etc/openvpn/keys/ "${tmpdir}/"
export VPNCLIENT_UPGRADE=1 export VPNCLIENT_UPGRADE=1
sudo bash /etc/yunohost/apps/vpnclient/scripts/remove sudo bash /etc/yunohost/apps/vpnclient/scripts/remove &> /dev/null
bash ./install "${domain}" "${path}" "${server_name}" bash ./install "${domain}" "${path}" "${server_name}"
sudo cp -a "${tmpdir}/keys/"* /etc/openvpn/keys/ 2> /dev/null sudo cp -a "${tmpdir}/keys/"* /etc/openvpn/keys/ 2> /dev/null