diff options
author | Christian Pointner <equinox@helsinki.at> | 2009-11-14 01:47:21 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2009-11-14 01:47:21 (GMT) |
commit | 0e5843d0ab4bed1a8bf9afb11834b4cc71d11adf (patch) | |
tree | 15303375849887e44b55ad994bc3bb0c4f431ca6 /openwrt/rhctl/files/switchctl.init | |
parent | a5e4a809402eb929e55072573a176d8c2ed44712 (diff) |
added serialclient to openwrt package
added config file to openwrt package
Diffstat (limited to 'openwrt/rhctl/files/switchctl.init')
-rwxr-xr-x | openwrt/rhctl/files/switchctl.init | 60 |
1 files changed, 42 insertions, 18 deletions
diff --git a/openwrt/rhctl/files/switchctl.init b/openwrt/rhctl/files/switchctl.init index 8ebe46f..c947e40 100755 --- a/openwrt/rhctl/files/switchctl.init +++ b/openwrt/rhctl/files/switchctl.init @@ -7,26 +7,50 @@ DESC=$BIN RUN_D=/var/run/rhctl PIDFILE=$RUN_D/$BIN.pid -start() { - echo -n "Starting $DESC:" - mkdir -p $RUN_D - $DAEMON --write-pid $PIDFILE - if [ $? -ne 0 ]; then - echo -n " Error" - else - echo -n " Ok" + +option_cb() { + local varname="$1" + local value="$2" + + if ! echo "$CONFIG_OPTIONS" | grep " $varname " > /dev/null; then + CONFIG_OPTIONS="$CONFIG_OPTIONS $varname " + fi +} + +start_daemon() { + local option + local value + local args="" + + for option in $CONFIG_OPTIONS + do + config_get value "switchctl" "$option" + option=`echo $option | tr '_' '-'` + if [ -n "$value" ]; then + args="$args --$option $value" fi - echo "." + done + local status="OK" + $DAEMON --write-pid $PIDFILE $args || status="failed" + echo -n "($status)" +} + +start() { + echo -n "Starting $DESC:" + config_load "rhctl" + mkdir -p $RUN_D + config_foreach start_daemon "switchctl" + echo "." } stop() { - echo -n "Stopping $DESC:" - if [ -f $PIDFILE ]; then - kill `cat $PIDFILE` > /dev/null 2>&1 - rm -f $PIDFILE > /dev/null 2>&1 - echo -n " Ok" - else - echo -n " not running" - fi - echo "." + echo -n "Stopping $DESC:" + if [ -f $PIDFILE ]; then + kill `cat $PIDFILE` > /dev/null 2>&1 + rm -f $PIDFILE > /dev/null 2>&1 + echo -n " Ok" + else + echo -n " not running" + fi + echo "." } |