summaryrefslogtreecommitdiff
path: root/testing/bitlbee/rc.d
blob: ade85221adeb8e8419b50caf3e36111ba5a6145a (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
#!/bin/bash

. /etc/rc.conf
. /etc/rc.d/functions

pidfile=/run/bitlbee/bitlbee.pid
if [[ -r $pidfile ]]; then
  read -r PID < "$pidfile"
  if [[ ! -d /proc/$PID ]]; then
    # stale pidfile
    unset PID
    rm -f "$pidfile"
  fi
fi

case $1 in
  start)
    stat_busy "Starting bitlbee daemon"
    if [[ $PID ]] || ! su -s /bin/sh -c '/usr/sbin/bitlbee -F' bitlbee; then
      stat_fail
      exit 1
    else
      add_daemon bitlbee
      stat_done
    fi
    ;;
  stop)
    stat_busy "Stopping bitlbee daemon"
    if [[ -z $PID ]] || ! kill $PID &>/dev/null; then
      stat_fail
      exit 1
    else
      rm -f "$pidfile"
      rm_daemon bitlbee
      stat_done
    fi
    ;;
  restart)
    $0 stop
    sleep 3
    $0 start
    ;;
  *)
    echo "usage: $0 {start|stop|restart}"
    exit 1
    ;;
esac

# vim: set ft=sh et ts=2 sw=2: