summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorMichael Larson <slioch@eng-140.vyatta.com>2007-12-14 16:29:32 -0800
committerMichael Larson <slioch@eng-140.vyatta.com>2007-12-14 16:29:32 -0800
commit40f3f645c5f29136f771b952b871f836c2f17997 (patch)
tree6777a64e4398afd39bf1b6872342d09c049e3762 /scripts
parent59b21be36b2f4cd74aa0cea53492e3023b59770b (diff)
downloadvyatta-wanloadbalance-40f3f645c5f29136f771b952b871f836c2f17997.tar.gz
vyatta-wanloadbalance-40f3f645c5f29136f771b952b871f836c2f17997.zip
added init script
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/wlb.init43
1 files changed, 43 insertions, 0 deletions
diff --git a/scripts/wlb.init b/scripts/wlb.init
new file mode 100755
index 0000000..60315f4
--- /dev/null
+++ b/scripts/wlb.init
@@ -0,0 +1,43 @@
+#! /bin/bash
+
+declare progname=${0##*/}
+declare action=$1; shift
+
+conf=$1; shift
+
+
+test -x $bb || exit 0
+
+running_pid ()
+{
+ pidof $bb | while read pid ; do
+ f=$(tr '\000' '\t' < /proc/$pid/cmdline 2>/dev/null | cut -f2)
+ if [ "$f" == wlb ] ; then
+ echo $pid
+ return
+ fi
+ done
+ false
+}
+
+start ()
+{
+ local -i pid=$( running_pid )
+
+ [ $pid -ne 0 ] && return
+ sh -c wlb -f $conf
+}
+
+stop ()
+{
+ local -i pid=$( running_pid )
+ [ $pid -ne 0 ] && kill $pid
+}
+
+case "$action" in
+ start) start;;
+ stop) stop;;
+ restart) stop; sleep 1; start;;
+ *) echo "Usage: $progname {start|stop|restart}"
+ exit 1
+esac