summaryrefslogtreecommitdiffstats
path: root/wicd/build/rc.wicd
blob: c7a5190f65dacb6a076128fe6cf42067975d7ae2 (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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/sh

# /etc/rc.d/rc.wicd
# Start/stop/restart the Wicd daemon

# This is defined in /usr/lib/python2.5/site-packages/wicd/wpath.py
PIDFILE="/var/run/wicd/wicd.pid"

# Define start and stop functions

wicd_start() {
  if [ -e $PIDFILE ]; then
    echo "Wicd appears to already be running."
    echo "If this is not the case, then remove "
    echo "$PIDFILE and try again..."
    exit 1
  else
    echo "Starting wicd daemon..."
    wicd 2>/dev/null 1>&2
  fi
}

wicd_stop() {
  echo "Stopping wicd daemon..."
  if [ -e $PIDFILE ]; then
    kill $(cat $PIDFILE) 2>/dev/null
    rm -f $PIDFILE 2>/dev/null
  else
    pkill -f python.*wicd-daemon.py 2>/dev/null
  fi
}

wicd_status() {
  if [ -e $PIDFILE ]; then
    echo "Wicd is running at pid $(cat $PIDFILE)."
  else
    echo "Can not determine if Wicd is running."
  fi
}

# See how we were called and take appropriate action	

case $1 in
  start)
    wicd_start
    ;;
  stop)
    wicd_stop
    ;;
  restart)
    wicd_stop
    wicd_start
    ;;
  status)
    wicd_status
    ;;
  *)
    echo "Usage: $0 {start|stop|restart|status}"
    exit 1
    ;;
esac