mynode/rootfs/standard/usr/bin/mynode_vpn.sh

36 lines
916 B
Bash
Raw Normal View History

2019-08-13 03:29:53 +00:00
#!/bin/bash
2019-08-26 00:49:22 +00:00
source /usr/share/mynode/mynode_config.sh
2019-08-13 03:29:53 +00:00
apt -y update
2019-08-26 00:49:22 +00:00
mkdir -p $VPN_BACKUP_DIR
2019-08-13 03:29:53 +00:00
while [ true ]; do
2019-08-26 00:49:22 +00:00
# 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
2019-08-13 03:29:53 +00:00
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
2019-08-26 00:49:22 +00:00
# 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
2019-08-13 03:29:53 +00:00
fi
systemctl enable openvpn
systemctl start openvpn
sleep 365d
done