diff options
Diffstat (limited to 'openwrt/rhctl/files/heartbeatclient.init')
-rwxr-xr-x | openwrt/rhctl/files/heartbeatclient.init | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/openwrt/rhctl/files/heartbeatclient.init b/openwrt/rhctl/files/heartbeatclient.init new file mode 100755 index 0000000..1b7d004 --- /dev/null +++ b/openwrt/rhctl/files/heartbeatclient.init @@ -0,0 +1,56 @@ +#!/bin/sh /etc/rc.common +START=72 + +BIN=heartbeatclient +DAEMON=/usr/bin/$BIN +DESC=$BIN +RUN_D=/var/run/rhctl +PIDFILE=$RUN_D/$BIN.pid + + +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 "$1" "$option" + option=`echo $option | tr '_' '-'` + if [ -n "$value" ]; then + args="$args --$option $value" + fi + 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 "hearbeatclient" + 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 "." +} |