aboutsummaryrefslogtreecommitdiff
path: root/ham/aprx/rc.aprx.new
blob: d5cc498eca0b74370b406909c05565a2119a8763 (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
62
63
64
65
66
67
68
69
#!/bin/sh
#
# aprx daemon control script.
# Written for Slackware Linux by JK Wood <joshuakwood@gmail.com>

BIN=/sbin/aprx
CONF=/etc/aprx.conf
PID=/var/run/aprx.pid

aprx_start() {
  # Sanity checks.
  if [ ! -r $CONF ]; then # no config file, exit:
    echo "$CONF does not appear to exist. Abort."
    exit 1
  fi

  if [ -s $PID ]; then
    echo "aprx appears to already be running?"
    exit 1
  fi

  echo "Starting aprx daemon..."
  if [ -x $BIN ]; then
    $BIN -f $CONF
  fi
}

aprx_stop() {
  echo "Shutdown aprx gracefully..."
  if [ -r $PID ]; then
    kill -HUP $(cat $PID)
    rm -f $PID
  else
    killall -HUP -q aprx
  fi
  echo
}

aprx_restart() {
  aprx_stop
  sleep 3
  aprx_start
}

aprx_status() {
  if [ -e $PID ]; then
    echo "aprx is running."
  else
    echo "arpx is stopped."
    exit 1
  fi
}

case "$1" in
  start)
    aprx_start
    ;;
  stop)
    aprx_stop
    ;;
  restart)
    aprx_restart
    ;;
  status)
    aprx_status
    ;;
  *)
  echo "usage: `basename $0` {start|stop|restart|status}"
esac