summaryrefslogtreecommitdiff
path: root/openwrt/rhctl/files/serialclient.init
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2009-11-14 01:47:21 (GMT)
committerChristian Pointner <equinox@helsinki.at>2009-11-14 01:47:21 (GMT)
commit0e5843d0ab4bed1a8bf9afb11834b4cc71d11adf (patch)
tree15303375849887e44b55ad994bc3bb0c4f431ca6 /openwrt/rhctl/files/serialclient.init
parenta5e4a809402eb929e55072573a176d8c2ed44712 (diff)
added serialclient to openwrt package
added config file to openwrt package
Diffstat (limited to 'openwrt/rhctl/files/serialclient.init')
-rw-r--r--openwrt/rhctl/files/serialclient.init108
1 files changed, 108 insertions, 0 deletions
diff --git a/openwrt/rhctl/files/serialclient.init b/openwrt/rhctl/files/serialclient.init
new file mode 100644
index 0000000..d869d25
--- /dev/null
+++ b/openwrt/rhctl/files/serialclient.init
@@ -0,0 +1,108 @@
+#!/bin/sh /etc/rc.common
+START=71
+
+BIN=serialclient
+DAEMON=/usr/bin/$BIN
+DESC=$BIN
+RUN_D=/var/run/rhctl
+
+
+option_cb() {
+ local varname="$1"
+ local value="$2"
+
+ if ! echo "$CONFIG_OPTIONS" | grep " $varname " > /dev/null; then
+ CONFIG_OPTIONS="$CONFIG_OPTIONS $varname "
+ fi
+}
+
+foreach_config_forced() {
+ foreach_config $1 "forced"
+}
+
+foreach_config() {
+ local cfg="$1"
+ local name
+ local option
+ local value
+ local args=""
+ local forced=0
+
+ if [ -n "$2" ] && [ "x$2" == "xforced" ]; then
+ forced=1
+ fi
+
+ config_get name "serialclient" "name"
+ for option in $CONFIG_OPTIONS
+ do
+ config_get value "serialclient" "$option"
+ if [ "x$option" == "xdisabled" ]; then
+ if [ $forced -eq 0 ] && [ $value -eq 1 ]; then
+ echo -n " $name(disabled)"
+ return
+ fi
+ continue
+ fi
+
+ if [ "x$option" == "xname" ]; then
+ continue
+ fi
+
+ option=`echo $option | tr '_' '-'`
+ if [ -n "$value" ]; then
+ args="$args --$option $value"
+ fi
+ done
+ echo -n " $name"
+ local status="OK"
+ $DAEMON --write-pid "$RUN_D/$BIN.$name.pid" $args || status="failed"
+ echo -n "($status)"
+}
+
+stop_client() {
+ local name=$1
+ local pidfile=$RUN_D/$BIN.$name.pid
+ echo -n " $name"
+ local status="OK"
+ if [ ! -f "$pidfile" ]; then
+ status="tunnel not active"
+ else
+ kill `cat $pidfile` > /dev/null 2>&1 || status="failed"
+ rm -f $pidfile
+ fi
+ echo -n "($status)"
+}
+
+start() {
+ echo -n "Starting $DESC:"
+ config_load "rhctl"
+ if [ $# -gt 0 ]; then
+ while [ $# -gt 0 ]; do
+ config_foreach foreach_config_forced "$1"
+ shift
+ done
+ else
+ config_foreach foreach_config ""
+ fi
+ echo "."
+}
+
+stop() {
+ echo -n "Stopping $DESC:"
+ local name
+ local pidfile
+
+ if [ $# -gt 0 ]; then
+ while [ $# -gt 0 ]; do
+ stop_client $1
+ shift
+ done
+ else
+ for pidfile in `ls $RUN_D/$BIN.*.pid 2> /dev/null`; do
+ name=${pidfile%%.pid}
+ name=${name##$RUN_D/$BIN.}
+ stop_client $name
+ done
+ fi
+ echo "."
+}