summaryrefslogtreecommitdiff
path: root/network/murmur/rc.murmur
blob: e14567938bec1e3cfdbf24b753e32af077ceff91 (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
#!/bin/bash

PIDFILE=/var/run/murmur/murmur.pid

murmur_start() {
  echo -n "Starting Murmur Server: "
  mkdir -p $(dirname $PIDFILE)
  chown @USER@:@GROUP@ $(dirname $PIDFILE)

  if [ ! -f $PIDFILE ]; then
    /usr/bin/murmurd -ini /etc/murmur.ini & > /dev/null 2>&1
    echo "OK"
  else
    echo -n "Removing stale lock.. "
    /bin/rm -f $PIDFILE
    /usr/bin/murmurd -ini /etc/murmur.ini & > /dev/null 2>&1
    echo "OK"
  fi
}

murmur_stop() {
  echo -n "Stopping Murmur: "
  if [ -f $PIDFILE ]; then
    /bin/kill $(/bin/cat $PIDFILE)
    /bin/rm -f $PIDFILE
    echo "OK"
  else
    echo "Not Running"
  fi
}

case "$1" in
  start)
    murmur_start
    ;;
  stop)
    murmur_stop
    ;;
  restart)
    murmur_stop && (/bin/sleep 1 && murmur_start)
    ;;
  *)
    echo "Usage: rc.murmur {start|stop|restart}"
esac