VPN HDD backup

This commit is contained in:
Taylor Helsper 2019-08-25 19:49:22 -05:00
parent 6478e70492
commit da7bdf878c
3 changed files with 27 additions and 0 deletions

View File

@ -1,13 +1,33 @@
#!/bin/bash
source /usr/share/mynode/mynode_config.sh
apt -y update
mkdir -p $VPN_BACKUP_DIR
while [ true ]; do
# Check for backup files
if [ ! -f /home/pivpn/ovpns/mynode_vpn.ovpn ]; then
if [ -f $VPN_BACKUP_DIR/mynode_vpn.ovpn ]; then
cp $VPN_BACKUP_DIR/mynode_vpn.ovpn /home/pivpn/ovpns/mynode_vpn.ovpn
fi
if [ -d $VPN_BACKUP_DIR/openvpn ]; then
cp -rf $VPN_BACKUP_DIR/openvpn /etc
fi
fi
# Generate new files
if [ ! -f /home/pivpn/ovpns/mynode_vpn.ovpn ]; then
/usr/bin/mynode_setup_vpn.sh
mkdir -p /home/pivpn/ovpns
pivpn add -n mynode_vpn nopass -d 3650
# Backup files to HDD
sync
cp -rf /etc/openvpn/ $VPN_BACKUP_DIR/
cp /home/pivpn/ovpns/mynode_vpn.ovpn $VPN_BACKUP_DIR/mynode_vpn.ovpn
fi
systemctl enable openvpn

View File

@ -24,6 +24,7 @@ SERIAL_NUM=$(cat /proc/cpuinfo | grep Serial | cut -d ' ' -f 2)
# Set all default / standard bash config settings
MYNODE_DIR=/mnt/hdd/mynode
VPN_BACKUP_DIR=/mnt/hdd/mynode/vpn
QUICKSYNC_DIR=/mnt/hdd/mynode/quicksync
QUICKSYNC_CONFIG_DIR=/mnt/hdd/mynode/.config/transmission
QUICKSYNC_TORRENT_URL="https://mynodebtc.com/device/blockchain.tar.gz.torrent"

View File

@ -51,10 +51,16 @@ def page_regen_vpn():
if pw == None or p.authenticate("admin", pw) == False:
return redirect(url_for(".page_vpn_info", error_message="Invalid Password"))
# Stop
#os.system("rm /home/pivpn/ovpns/mynode_vpn.ovpn")
os.system("pivpn -r mynode_vpn")
os.system("systemctl stop openvpn")
os.system("systemctl stop vpn")
# Clean up files
os.system("rm -rf /mnt/hdd/mynode/vpn/*")
# Restart
os.system("systemctl start vpn")
# Download ovpn