summaryrefslogtreecommitdiffhomepage
path: root/contrib
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2008-09-13 21:45:21 +0000
committerJo-Philipp Wich <jow@openwrt.org>2008-09-13 21:45:21 +0000
commit8bba6cf4d061e28d8fda10a6f9348fa8a8b1380e (patch)
tree7e33dbb13cbb869ab7db74c413e6af9f3ad73751 /contrib
parentf424439b65f9b416de20486da56b387d52cfc81a (diff)
* luci/contrib/olsr: fix initscript to not kill itself sometimes
Diffstat (limited to 'contrib')
-rwxr-xr-xcontrib/package/olsrd-luci/files/etc/init.d/olsrd30
1 files changed, 25 insertions, 5 deletions
diff --git a/contrib/package/olsrd-luci/files/etc/init.d/olsrd b/contrib/package/olsrd-luci/files/etc/init.d/olsrd
index 2cadcafd9..54f5502bf 100755
--- a/contrib/package/olsrd-luci/files/etc/init.d/olsrd
+++ b/contrib/package/olsrd-luci/files/etc/init.d/olsrd
@@ -3,6 +3,10 @@
# Special thanks to bittorf wireless ))
START=50
+BIN=/usr/sbin/olsrd
+CONF=/var/etc/olsrd.conf
+PID=/var/run/olsrd.pid
+
OLSRD_OLSRD_SCHEMA='ignore:internal config_file:internal DebugLevel=0 IpVersion=4 AllowNoInt:bool=1 Pollrate=0.025 TcRedundancy=2 MprCoverage=3 LinkQualityFishEye=1 LinkQualityWinSize=100 LinkQualityDijkstraLimit=0+9.0 LinkQualityLevel=2 UseHysteresis:bool=0 FIBMetric=flat ClearScreen:bool=1 Willingness=3 LinkQualityAging=0.1 LinkQualityAlgorithm=etx_fpm'
OLSRD_IPCCONNECT_SCHEMA='ignore:internal Host:list Net:list2'
OLSRD_LOADPLUGIN_SCHEMA='ignore:internal library:internal Host:list Net:list2 Ping:list redistribute:list NonOlsrIf:list name:list lat lon latlon_infile HNA:list2 hosts:list2'
@@ -516,6 +520,14 @@ olsrd_write_config() {
}
start() {
+ ### check for running instance
+ if [ -s $PID ]; then
+ if kill -0 $(cat $PID) 2>&-; then
+ echo "there is already a running instance ($(cat $PID))"
+ return 1
+ fi
+ fi
+
SYSTEM_HOSTNAME=
SYSTEM_LAT=
SYSTEM_LON=
@@ -539,18 +551,26 @@ start() {
config_foreach olsrd_find_config_file olsrd
if [ -z "$OLSRD_CONFIG_FILE" ]; then
- mkdir -p -- /var/etc/
- olsrd_write_config > /var/etc/olsrd.conf
+ ### generate config
+ mkdir -p ${CONF%/*}
+ olsrd_write_config > $CONF
if [ "$INTERFACES_COUNT" -gt 0 -a "$OLSRD_COUNT" -gt 0 ]; then
- OLSRD_CONFIG_FILE=/var/etc/olsrd.conf
+ OLSRD_CONFIG_FILE=$CONF
fi
fi
[ -z "$OLSRD_CONFIG_FILE" ] && return 1
- olsrd -f "$OLSRD_CONFIG_FILE" -nofork < /dev/null > /dev/null &
+ ### start olsrd
+ start-stop-daemon -b -m -p $PID -x $BIN -S -- -f $CONF -nofork
}
stop() {
- killall olsrd
+ ### stop olsrd
+ start-stop-daemon -q -p $PID -a ${BIN##*/} -K
+}
+
+restart() {
+ ### override generic restart because we need some time between stop and start
+ stop; sleep 3; start
}