#!/bin/sh INTERFACE=$1 STATUS=$2 pdnsd_going_up() { # Check whether pDNSd is already running before starting it. if [ `rc.d list|grep pdnsd|cut -f1 -d']'|cut -d'[' -f2` == 'STOPPED' ]; then rc.d start pdnsd else rc.d restart pdnsd fi } pdnsd_going_down() { # Check for active interface, take offline if none is active if [ ! `nm-tool|grep State|cut -f2 -d' '` = 'connected' ]; then rc.d stop pdnsd else # If another interface is active, restart so we're sure we're using # the active connection. rc.d restart pdnsd fi } case "$STATUS" in up) pdnsd_going_up ;; vpn-up) pdnsd_going_up ;; down) pdnsd_going_down ;; vpn-down) pdnsd_going_down ;; esac