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.

Haiya ala Solah