summarylogtreecommitdiffstats
path: root/rc.d_rxstack
blob: 3886b05d018ab00f4170b32608986ea14668c5ea (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
#!/bin/bash

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

PID=$(pidof -o %PPID /usr/bin/rxstack)

stat_started() {
    deltext
    printf "${C_OTHER}[${C_DONE}STARTED${C_OTHER}]${C_CLEAR} \n"
}

stat_stopped() {
    deltext
    printf "${C_OTHER}[${C_DONE}STOPPED${C_OTHER}]${C_CLEAR} \n"
}

case "$1" in
  start)
    stat_busy "Starting Regina Stack"
    [ -z "${PID}" ] && /usr/bin/rxstack -d &> /dev/null
    if [ $? -gt 0 ]; then
      stat_fail
    else
      add_daemon rxstack
      stat_done
    fi
    ;;
  stop)
    stat_busy "Stopping Regina Stack"
    /usr/bin/rxstack -k &> /dev/null
    if [ $? -gt 0 ]; then
      stat_fail
    else
      rm_daemon rxstack
      stat_done
    fi
    ;;
  status)
    stat_busy "Regina Stack"
    echo -en '\b\b\b\b'
    [ -z "${PID}" ] && stat_stopped
    [ -z "${PID}" ] || stat_started
    ;;
  restart)
    $0 stop
    sleep 1
    $0 start
    ;;
  *)
    echo "usage: $0 {start|stop|status|restart}"
esac
exit 0