summaryrefslogtreecommitdiff
path: root/openwrt/package/miau/files/S50miau
blob: beef3105ddc33859b2c0aac85c35af84a52b2dae (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
#!/bin/sh

DEFAULT="/etc/default/miau"
OPTIONS="-d /etc/miau/"
LOG_DIR="/var/log/miau"
ERR_LOG="$LOG_DIR/error.log"
OUT_LOG="$LOG_DIR/miau.log"

[ -f $DEFAULT ] && . $DEFAULT
[ "$ENABLE_MIAU" = "yes" ] || exit 0

case $1 in
 start)
  [ -f /var/run/miau.pid ] && echo "[ERROR] miau is running"
  [ -f /var/run/miau.pid ] && exit 0
  [ -d /var/run ] || mkdir -p /var/run
  [ -d $LOG_DIR ] || mkdir -p $LOG_DIR 
  /usr/bin/miau -f $OPTIONS > $OUT_LOG 2> $ERR_LOG &
  PID=$!
  sleep 1 
  [ -d /proc/$PID ] && echo $PID > /var/run/miau.pid 
  [ -d /proc/$PID ] || echo "[ERROR] Unable to run miau as a daemon"
  ;;
 stop)
  [ -f /var/run/miau.pid ] && kill $(cat /var/run/miau.pid) >/dev/null 2>&1 && rm /var/run/miau.pid
  ;;
 *)
 echo "usage: $0 (start|stop)"
 exit 1
esac

exit $?