#!/bin/sh /etc/rc.common
-# Copyright (C) 2006 OpenWrt.org
+# Copyright (C) 2007 OpenWrt.org
START=50
-DEFAULT=/etc/default/p910nd
-RUN_D=/var/run
+BIN=p910nd
+
+start_service() {
+ local section="$1"
+ config_get port "$section" port
+ config_get device "$section" device
+ config_get_bool bidirectional "$section" bidirectional
+
+ options=""
+ [ $bidirectional -eq 1 ] && {
+ options="$options -b"
+ }
+ options="$options -f $device $port"
+
+ $BIN $options
+}
+
+stop_service() {
+ local section="$1"
+ config_get port "$section" port
+
+ PID_F=/var/run/p910${port}d.pid
+ [ -f $PID_F ] && kill $(cat $PID_F)
+}
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
+ config_load "p910nd"
+ config_foreach start_service p910nd
}
stop() {
- [ -f $DEFAULT ] && (
- while read port options; do
- case "$port" in
- ""|\#*) continue;l
- esac
- PID_F=$RUN_D/p910${port}d.pid
- [ -f $PID_F ] && kill $(cat $PID_F)
- done
- ) < $DEFAULT
+ config_load "p910nd"
+ config_foreach stop_service p910nd
}
-