#!/bin/ash
#
#
#
 case "$1" in
 'add')
 echo "23 stream tcp nowait root busybox telnetd -i" > /etc/inetd/telnet.conf
 ;;
 'start')
 telnetd add
 inetd
 ;;
 'remove')
 rm /etc/inetd/telnet.conf 2>/dev/null
 ;;
 'stop')
 telnetd remove
 inetd
 ;;
 'restart')
 telnetd start
 ;;
 'test')
 if [ ! -e /etc/inetd/telnet.conf ]; then
   echo "Your Telnet Server seems to be down."
   read -p "Do you wish to start it now (y/n)?: " CHOICE
   CHOICE=y$CHOICE
   if [ $CHOICE = yy ]; then
     telnetd start
   fi
 fi
 clear
 echo "Busybox Telnet Client will try to connect to your localhost:"
 telnet localhost
 ;;
 'help')
 echo "telnetd start --> start Telnet server"
 echo "telnetd stop --> stop Telnet server"
 echo "telnetd restart --> restart Telnet server"
 echo "telnetd test --> test Telnet server"
 ;;
 *)
 echo "Usage:"
 telnetd help
 ;;
 esac