mirror of
https://github.com/pivpn/pivpn.git
synced 2024-12-24 13:50:16 +00:00
deee38b20e
- Add curl as a dependency for those who run the script without 'curl URL | bash'. - Use POSIX 'command -v' instead of 'hash'. - Check if packages have actually been installed and abort execution if they have not. - Fixed issue with getStaticIPv4Settings() that prevented existing network settings to be used as static IP settings when running the script unattended with empty $IPv4addr and $IPv4gw variables. - Exit if processing wireguard-linux-compat fails. - Exit if 50unattended-upgrades fails to extract. - Exit clientSTAT.sh if the wg0 interface is not available. - Moved the Self Check to a single script since dedicated versions were very similar. - Add 'pivpn -wg' to update WireGuard for users running Raspbian with armv6l kernel.
59 lines
1.5 KiB
Bash
Executable file
59 lines
1.5 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
backupdir=pivpnbackup
|
|
date=$(date +%Y%m%d-%H%M%S)
|
|
setupVars="/etc/pivpn/setupVars.conf"
|
|
|
|
if [ ! -f "${setupVars}" ]; then
|
|
echo "::: Missing setup vars file!"
|
|
exit 1
|
|
fi
|
|
|
|
# shellcheck disable=SC1090
|
|
source "${setupVars}"
|
|
|
|
checkbackupdir(){
|
|
|
|
if [[ ! -d $install_home/$backupdir ]]; then
|
|
mkdir -p "$install_home"/"$backupdir"
|
|
fi
|
|
|
|
}
|
|
|
|
backup_openvpn(){
|
|
|
|
openvpndir=/etc/openvpn
|
|
ovpnsdir=${install_home}/ovpns
|
|
checkbackupdir
|
|
backupzip=$date-pivpnovpnbackup.tgz
|
|
# shellcheck disable=SC2210
|
|
tar czpf "$install_home"/"$backupdir"/"$backupzip" "$openvpndir" "$ovpnsdir" > /dev/null 2>&1
|
|
echo -e "Backup crated to $install_home/$backupdir/$backupzip \nTo restore the backup, follow instructions at:\nhttps://github.com/pivpn/pivpn/wiki/FAQ#how-can-i-migrate-my-configs-to-another-pivpn-instance"
|
|
|
|
}
|
|
|
|
backup_wireguard(){
|
|
|
|
wireguarddir=/etc/wireguard
|
|
configsdir=${install_home}/configs
|
|
checkbackupdir
|
|
backupzip=$date-pivpnwgbackup.tgz
|
|
tar czpf "$install_home"/"$backupdir"/"$backupzip" "$wireguarddir" "$configsdir" > /dev/null 2>&1
|
|
echo -e "Backup crated to $install_home/$backupdir/$backupzip \nTo restore the backup, follow instructions at:\nhttps://github.com/pivpn/pivpn/wiki/FAQ#how-can-i-migrate-my-configs-to-another-pivpn-instance"
|
|
|
|
}
|
|
|
|
if [[ ! $EUID -eq 0 ]];then
|
|
if [[ $(dpkg-query -s sudo) ]];then
|
|
export SUDO="sudo"
|
|
else
|
|
echo "::: Please install sudo or run this as root."
|
|
exit 0
|
|
fi
|
|
fi
|
|
|
|
if [[ "${VPN}" == "wireguard" ]]; then
|
|
backup_wireguard
|
|
else
|
|
backup_openvpn
|
|
fi
|