summaryrefslogtreecommitdiff
path: root/package/p910nd/files/p910nd.init
blob: 1a6c4f4a138136c1649c007226918ff7ef55151d (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
#!/bin/sh

DEFAULT=/etc/default/p910nd
RUN_D=/var/run

_start() {
 mkdir -p $RUN_D
 [ -f $DEFAULT ] && (
  while read port options; do
   case "$port" in
    ""|\#*)
     continue;
   esac
   p910nd $options $port
   if [ $? -ne 0 ]; then
    exit 1
   fi
  done
 ) < $DEFAULT
 exit 0
}

_stop() {
 [ -f $DEFAULT ] && (
  while read port options; do
   case "$port" in
    ""|\#*)
     continue;
   esac
   PID_F=$RUN_D/p910${port}d.pid
   [ -f $PID_F ] && kill $(cat $PID_F)
  done
 ) < $DEFAULT
}

case $1 in
 start)
  _start
  ;;
 stop)
  _stop
  ;;
 *)
  echo "usage: $0 (start|stop)"
  exit 1
esac
exit $?