summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorStig Thormodsrud <stig@uffda.(none)>2007-10-31 18:51:55 -0700
committerStig Thormodsrud <stig@uffda.(none)>2007-10-31 18:51:55 -0700
commit0e4fea93eaf510e18b10d0bba288c90002955e81 (patch)
tree8ab8fbe879aabc5252e2c4ae59f95f2b5866d698 /scripts
parente992ddd83ab2002ea6aeb9a4cacf89f9a888c17b (diff)
parent61f301fce041eb658d62579879ae6fb355b0cde7 (diff)
downloadvyatta-cfg-system-0e4fea93eaf510e18b10d0bba288c90002955e81.tar.gz
vyatta-cfg-system-0e4fea93eaf510e18b10d0bba288c90002955e81.zip
Merge branch 'master' of http://phuket.vyatta.com/vyatta-cfg-system
Conflicts: Makefile.am
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/telnetd.init59
1 files changed, 59 insertions, 0 deletions
diff --git a/scripts/telnetd.init b/scripts/telnetd.init
new file mode 100755
index 00000000..b8368f03
--- /dev/null
+++ b/scripts/telnetd.init
@@ -0,0 +1,59 @@
+#! /bin/bash
+
+declare progname=${0##*/}
+declare action=$1; shift
+
+port=$1; shift
+
+: ${port:=23}
+: ${bb:=/bin/busybox}
+
+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" == telnetd ] ; then
+ echo $pid
+ return
+ fi
+ done
+ false
+}
+
+start ()
+{
+ local -i pid=$( running_pid )
+
+ [ $pid -ne 0 ] && return
+ $bb telnetd -p $port
+}
+
+stop ()
+{
+ local -i pid=$( running_pid )
+ [ $pid -ne 0 ] && kill $pid
+}
+
+status ()
+{
+ pidof $bb | while read pid ; do
+ f=$(tr '\000' '\t' < /proc/$pid/cmdline | cut -f2)
+ if [ $f == telnetd ] ; then
+ echo running
+ return
+ fi
+ done
+ echo not running
+ false
+}
+
+case "$action" in
+ start) start;;
+ stop) stop;;
+ restart) stop; sleep 1; start;;
+ status) status;;
+ *) echo "Usage: $progname {start|stop|restart|status}"
+ exit 1
+esac