Saturday, March 14, 2009

Starting a script after NetworkManager

I need to access a VPN. But to be able to start the VPN I need a network connection. How to know when NetworkManager has already created your connection? By refering to here, you can add scripts into the /etc/NetworkManager/dispatcher.d to be run by network manager everytime an interface go up or down.

#!/bin/bash

IF=$1
STATUS=$2

if [ "$STATUS" = "up" ]; then
/etc/rc.d/openvpn start
else
/etc/rc.d/openvpn stop
fi

So that openvpn will start straight away whenever any interface (IF) has the status up.

2 comments:

lxe said...

This does not work for me. Running NM 0.7.996, does this method still work (am I doing something wrong) or have newer builds (since you posted) broken this functionality?

Abdullah Zainul Abidin said...

Maybe this might be of help?
https://issues.foresightlinux.org/browse/FL-1377

Haiya ala Solah