summarylogtreecommitdiffstats
path: root/00-pdnsd
blob: 55ce59748ee14b900f01b47a4a98fc6eb2e06708 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/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