OpenVPN AutoRestart Script

I often use OpenVPN for my VPN needs. It’s an Open Source SSL VPN with a whole bunch of features and plenty of configuration flexibility.
However, one issue is that when I make a configuration change and reload openvpn, all the clients have to reconnect. Usually this happens automatically, but sometimes some users lose their sessions and (understandably) get annoyed.

This then requires the configuration of a cronjob so OpenVPN gets restarted at a time that doesn’t annoy users, but sometimes it gets forgotten or another admin makes a change and doesn’t restart the service.

I’ve written a small script that uses md5sum to check if the openvpn config files have changed, and then restart the OpenVPN service automatically. I have it in /etc/cron.daily/ so it gets called at 4:00am.

Download the OpenVPN auto-restart script

This script could be easily adapted to handle any service you want.