Martineau
Part of the Furniture
Thank you @Martineau this script is exactly what I was looking for and works perfectly!
Just a side question.. if you use the multiconfig option where you list server/ports in /jffs/configs/VPN_Failover.. how do handle the OpenVPN configuration files (certs, settings, authorization, etc) that is usually uploaded for the 5 WebUI clients?
The 'multiconfig' option was designed to be used for round-robin selection from a list of OpenVPN servers (i.e. UDP/TCP sockets) provided by the same VPN ISP.
Code:
# Tricky business of restoring NVRAM and the three cert files 'ca,crt and key' # v1.12??
# Should the script save a working VPN Client NVRAM config when it requests and successfully starts a VPN Client?
# nvram show >2/dev/null | grep vpn_client5_ | sort >/jffs/openvpn/VPN_Failover/vpn_client5_NVRAM
# or
# ./nvram-save.sh -i ${THIS_VPN}ovpn.ini -nojffs -nouser
#
#
# Read the NVRAM vars and restore 'em... # v1.12??
Restore_VPN_NVRAM ${THIS_VPN}_ovpn.sh
# Since '/jffs/openvpn' holds the 'live' keys, use '/jffs/openvpn/VPN_Failover' to restore them
if [ ! -f /jffs/openvpn/VPN_Failover ] then
cp -/jffs/openvpn /jffs/openvpn/VPN_Failover
else
# Now we can overwrite the target certs.... # v1.12??
cp -af /jffs/openvpn/VPN_Failover/vpn_crt_client${THIS_VPN}_ca /jffs/openvpn/vpn_crt_client${THIS_VPN}_ca
cp af /jffs/openvpn/VPN_Failover/vpn_crt_client${THIS_VPN}_crt /jffs/openvpn/vpn_crt_client${THIS_VPN}_crt
cp -af /jffs/openvpn/VPN_Failover/vpn_crt_client${THIS_VPN}_key /jffs/openvpn/vpn_crt_client${THIS_VPN}
fi
I believe for most users, switching between different VPN configs/providers is best handled without invoking the 'multiconfig' option - although there is then of course a limit of five round-robin entities.