#!/bin/sh
### BEGIN INIT INFO
# Provides:          usbnet-emergency-telnetd
# Required-Start:    udev
# Required-Stop:     $remote_fs $syslog
# Default-Start:     S
# Default-Stop:      
# Short-Description: Start daemon at boot time
# Description:       Enable service provided by daemon.
### END INIT INFO
# ugly hacks follow

tablet_setup()
{
	BOOTTYPE=0
	if [ -e /tmp/.bootmode ]; then
		BOOTTYPE=`cat /tmp/.bootmode`
	fi
	if [ -e /boot/tmp/.bootmode ]; then
		BOOTTYPE=`cat /boot/tmp/.bootmode`
	fi
	if [ x$BOOTTYPE = x3 ]; then
		/sbin/modprobe g_ether
		/sbin/ifconfig usb0 192.168.2.2 netmask 255.255.255.0
		/sbin/utelnetd -i usb0 -d -l /bin/bash
		echo You can now connect on USBnet, 192.168.2.2 netmask 255.255.255.0, telnet.
	fi
}

case "$1" in
        start|restart|force-reload)
        tablet_setup
        ;;
        stop)
        ;;
        *)
        echo "Usage: /etc/init.d/usbnet-console {start|stop|restart|force-reload}" >&2
        exit 3
        ;;
esac
