Add backup/restore scripts
This commit is contained in:
parent
99f5652af4
commit
6bc8691d4d
10
scripts/backup
Normal file
10
scripts/backup
Normal 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
|
@ -18,7 +18,7 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# This is an upgrade?
|
||||
upgrade=$([ "$VPNCLIENT_UPGRADE" == 1 ] && echo true || echo false)
|
||||
upgrade=$([ "${VPNCLIENT_UPGRADE}" == 1 ] && echo true || echo false)
|
||||
|
||||
# Retrieve arguments
|
||||
domain=${1}
|
||||
@ -55,7 +55,7 @@ fi
|
||||
if ! $upgrade; then
|
||||
|
||||
# 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_port -v 1194
|
||||
sudo yunohost app setting vpnclient server_proto -v udp
|
||||
@ -66,6 +66,10 @@ if ! $upgrade; then
|
||||
|
||||
fi
|
||||
|
||||
# Save git commit
|
||||
gitcommit=$(git rev-parse HEAD)
|
||||
sudo yunohost app setting vpnclient gitcommit -v "${gitcommit}"
|
||||
|
||||
# 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_compressed /usr/local/bin/
|
||||
|
20
scripts/restore
Normal file
20
scripts/restore
Normal 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
|
@ -15,7 +15,7 @@ tmpdir=$(mktemp -dp /tmp/ vpnclient-upgrade-XXXXX)
|
||||
sudo cp -a /etc/openvpn/keys/ "${tmpdir}/"
|
||||
|
||||
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}"
|
||||
|
||||
sudo cp -a "${tmpdir}/keys/"* /etc/openvpn/keys/ 2> /dev/null
|
||||
|
Loading…
x
Reference in New Issue
Block a user