summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.am1
-rwxr-xr-xscripts/telnetd.init59
-rw-r--r--templates/service/telnet/node.def4
-rw-r--r--templates/service/telnet/port/node.def3
4 files changed, 67 insertions, 0 deletions
diff --git a/Makefile.am b/Makefile.am
index 808ac3eb..d2d041d0 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -16,6 +16,7 @@ sbin_SCRIPTS += scripts/system/vyatta_update_logrotate.pl
sbin_SCRIPTS += scripts/system/vyatta_update_syslog.pl
sbin_SCRIPTS += scripts/snmp/vyatta-snmp.pl
sbin_SCRIPTS += scripts/snmp/snmpd.init
+sbin_SCRIPTS += scripts/telnetd.init
sysconf_DATA += sysconf/hosts
sysconf_DATA += sysconf/logrotate_messages
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
diff --git a/templates/service/telnet/node.def b/templates/service/telnet/node.def
new file mode 100644
index 00000000..5f4c1c7c
--- /dev/null
+++ b/templates/service/telnet/node.def
@@ -0,0 +1,4 @@
+help: "Enable/disable telnet protocol"
+delete: "sudo /opt/vyatta/sbin/telnetd.init stop"
+end: "if [ -z \"$(port/@)\" ]; then exit 0; fi; \
+ sudo /opt/vyatta/sbin/telnetd.init restart $(port/@)"
diff --git a/templates/service/telnet/port/node.def b/templates/service/telnet/port/node.def
new file mode 100644
index 00000000..0232af83
--- /dev/null
+++ b/templates/service/telnet/port/node.def
@@ -0,0 +1,3 @@
+type: u32
+default: 23
+help: "Port for telnet service"