* luci/applications: olsr: add own initscript and configuration
[project/luci.git] / applications / luci-olsr / root / etc / init.d / olsrd
1 #!/bin/sh /etc/rc.common
2 START=50
3
4 BIN=/usr/sbin/olsrd
5 CONF=/var/etc/olsrd.conf
6 DEFAULT=/etc/default/olsrd
7 PID=/var/run/olsrd.pid
8
9 start() {
10         ### load defaults
11         [ -f $DEFAULT ] && . $DEFAULT
12
13         ### generate config
14         mkdir -p ${CONF%/*}
15         lua /lib/config/olsr.lua > $CONF
16
17         ### check for running instance (start-stop-daemon is too stupid to do this)
18         if [ -s $PID ]; then
19                 if kill -0 $(cat $PID) 2>&-; then
20                         echo "there is already a running instance ($(cat $PID))"
21                         exit 1
22                 fi
23         fi
24
25         ### start olsrd
26         start-stop-daemon -b -m -p $PID -x $BIN -S -- -f $CONF -nofork $OPTIONS
27 }
28
29 stop() {
30         ### stop olsrd
31         start-stop-daemon -q -p $PID -a ${BIN##*/} -K
32 }
33
34 restart() {
35         ### override generic restart because we need some time between stop and start
36         stop; sleep 3; start
37 }