summaryrefslogtreecommitdiff
path: root/openwrt/rhctl/files
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2010-01-12 02:58:08 (GMT)
committerChristian Pointner <equinox@helsinki.at>2010-01-12 02:58:08 (GMT)
commit09a4632f7ae58f11d73dcbbbb7e69b397a40b9f6 (patch)
treee22186b600787b5212afc6fcc1fbb5428fbf3e2b /openwrt/rhctl/files
parent2b5f6eac7186f4044a69daa60b35bcc581c75a9e (diff)
mode leds lua client works now
updated openwrt package
Diffstat (limited to 'openwrt/rhctl/files')
-rwxr-xr-xopenwrt/rhctl/files/luaclient.init112
-rw-r--r--openwrt/rhctl/files/rhctl.config9
2 files changed, 120 insertions, 1 deletions
diff --git a/openwrt/rhctl/files/luaclient.init b/openwrt/rhctl/files/luaclient.init
new file mode 100755
index 0000000..bd0a796
--- /dev/null
+++ b/openwrt/rhctl/files/luaclient.init
@@ -0,0 +1,112 @@
+#!/bin/sh /etc/rc.common
+START=73
+
+BIN=luaclient
+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 "$2" "forced"
+}
+
+foreach_config() {
+ local cfg="$1"
+ local name
+ local option
+ local value
+ local args=""
+ local forced=0
+
+ config_get name "$cfg" "name"
+ if [ -n "$2" ] && [ "x$2" != "x$name" ]; then
+ return
+ fi
+
+ if [ -n "$3" ] && [ "x$3" == "xforced" ]; then
+ forced=1
+ fi
+
+ for option in $CONFIG_OPTIONS
+ do
+ config_get value "$cfg" "$option"
+ if [ "x$option" == "xdisabled" ]; then
+ if [ $forced -eq 0 ] && [ -n "$value" ] && [ $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 "luaclient" "$1"
+ shift
+ done
+ else
+ config_foreach foreach_config "luaclient"
+ 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 "."
+}
diff --git a/openwrt/rhctl/files/rhctl.config b/openwrt/rhctl/files/rhctl.config
index 2e4f176..7d3f06f 100644
--- a/openwrt/rhctl/files/rhctl.config
+++ b/openwrt/rhctl/files/rhctl.config
@@ -31,4 +31,11 @@ config 'heartbeatclient'
option baudrate '38400'
option device '/dev/ttyHeartbeat'
option timeout '15'
- option led 'heartbeat' \ No newline at end of file
+ option led 'heartbeat'
+
+config 'luaclient'
+# option disabled 1
+ option name 'mode-leds'
+ option log 'syslog:3,luaclient-mode-leds,daemon'
+ option command_sock '/var/run/rhctl/switchctl.sock'
+ option lua_file '/usr/share/rhctl/mode-leds.lua'