Openvpn trigger in PROCD script


how can I have my PROCD-based script reloaded if there're changes in any of the OpenVPN interfaces (up/down/ip renewal)?

Would procd_add_reload_interface_trigger work if I get the right interface name for the OpenVPN connection? Would config_load/config_foreach enumeration work?

If not, can I do an iface hotplug?


I have a hotplug script that starts the vpn on a wan network event.

if [ "${ACTION}" == "ifup" ] && [ "${INTERFACE}" = "wan" ]
    /etc/init.d/openvpn start

if [ "${ACTION}" == "ifdown" ] && [ "${INTERFACE}" = "wan" ]
    killall openvpn

Name /etc/hotplug.d/etc/iface/80-openvpn.

When a phone is plugged into my usb port it starts a tethering connection that creates a usb0 network device that is allocated to my wan which starts the openvpn to create a tunnel tap0 which is on my lan and all my router traffic goes through that from my cottage router to my home router. I'd be interested on how to set that up using the new PROCD.

Not quite what I asked.

Thanks to tip from @hnyman, I've adapted some code from dropbear init script, the following seems to detect OpenVPN changes (up/down/ip renewal):

st_load_interfaces(){ local d; config_get d $1 ifname; [ "$1" == "wan" -o "$d" != "${d/tun}" -o "$d" != "${d/tap}" ] && ifaces=" ${1} ${ifaces}"; }
service_triggers() {
		local ifaces n
		config_load network; config_foreach st_load_interfaces interface;
		for n in $ifaces; do procd_add_interface_trigger "interface.*" $n /etc/init.d/<<service>> reload; done;
1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.