aboutsummaryrefslogtreecommitdiff
path: root/ham/svxlink/rc.svxlink
blob: b57cc81409ff10e7661d50dc37664c4e9f696d60 (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
#!/bin/sh
# Start/stop/restart svxlink.

# Start svxlink:
svxlink_start() {
  CMDLINE="/usr/bin/svxlink --daemon --runasuser=svxlink --pidfile=/var/run/svxlink.pid --logfile=/var/log/svxlink"
  # CMDLINE="/usr/bin/svxlink --daemon --runasuser=svxlink --pidfile=/var/run/svxlink.pid"
  echo -n "Starting SvxLink:  $CMDLINE"
  $CMDLINE
  echo
}

# Stop svxlink:
svxlink_stop() {
  echo -n "Stopping SvxLink..."
  if [ -r /var/run/svxlink.pid ]; then
    kill $(cat /var/run/svxlink.pid)
    rm -f /var/run/svxlink.pid
  else
    killall -q svxlink
  fi
  echo
}

# Restart svxlink:
svxlink_restart() {
  svxlink_stop
  sleep 1
  svxlink_start
}

# Check if svxlink is running:
svxlink_status() {
  if [ -e /var/run/svxlink.pid ]; then
    echo "SvxLink is running."
  else 
    echo "SvxLink is stopped."
    exit 1
  fi
}

case "$1" in
'start')
  svxlink_start
  ;;
'stop')
  svxlink_stop
  ;;
'restart')
  svxlink_restart
  ;;
'status')
  svxlink_status
  ;;
*)
  echo "usage $0 start|stop|restart|status"
esac