Hello,
To achieve this, a custom script could be used to check weather OpenVPN is connected or not:
#!/bin/sh
if ubus call vuci.services.openvpn openvpn_status | grep -q 'ipaddress'; then
logger "OpenVPN is connected"
else
logger "OpenVPN is disconnected, restarting..."
/etc/init.d/openvpn restart
fi |
For this example, this script can be placed in /etc/check_openvpn.sh
Afterward, run a command chmod +x /etc/check_openvpn.sh to allow the file to be executed.
Then a crontab would need to be added:
* * * * * /etc/check_openvpn.sh >/dev/null 2>&1
This would run the script every minute. This crontab syntax can be altered using this crontab generator.
For editing the existing crontab file and creating a script file, the VI editor can be used. More information about it can be found here.
NOTE: Please keep in mind, that in the script, logs will be added every time the script runs. This can be useful for troubleshooting, however, if they are not needed, they can be omitted.
Let me know if any more help is needed!
Best regards,
DaumantasG