#!/bin/sh
set -x
. /var/etc/autostart/start-config

echo "start /var/etc/autostart/start-first.sh"
insmod /lib/modules/ntfs.ko
insmod /lib/modules/fuse.ko
#insmod /lib/modules/autofs4.ko
insmod /lib/modules/cifs.ko
#insmod /lib/modules/hfsplus.ko
#insmod /lib/modules/hfs.ko

TMP=/tmp/.dns
#GATEWAY=`cat /proc/cmdline | cut -d : -f 3`
NAMESERVER=/etc/resolv.conf
#IP=`cat /proc/cmdline | cut -d " " -f 4 | cut -d "=" -f 2 | cut -d : -f 1`
#NETMASK=`cat /proc/cmdline | cut -d " " -f 4 | cut -d "=" -f 2 | cut -d : -f 4`

HELP=`cat /proc/cmdline | sed -e 's#ip=#_#g' | cut -d "_" -f 2`
GATEWAY=`echo "$HELP" | cut -d ":" -f 3`
IP=`echo "$HELP" | cut -d ":" -f 1`
NETMASK=`echo "$HELP" | cut -d ":" -f 4`


if [ ! -f /etc/network/interfaces.org ]; then
  cp /etc/network/interfaces /etc/network/interfaces.org
  echo "$GATEWAY" > /etc/default_gw
  echo "auto eth0" > /etc/network/interfaces
  echo "iface eth0 inet static" >> /etc/network/interfaces
  echo "	address $IP" >> /etc/network/interfaces
  echo "	netmask $NETMASK" >> /etc/network/interfaces
  echo "	gateway $GATEWAY" >> /etc/network/interfaces
  sync
fi

/etc/init.d/networking start

if [ `which telnet | wc -l` -eq 1 ] && [ $telnet == 'y' ]; then                      
	echo "start telnetd"
	telnetd -l /bin/login
fi

if [ `which ftpd | wc -l` -eq 1 ] && [ $ftpd == 'y' ]; then
	echo "start ftpd"
	ftpd -D
else
  echo "start vsftpd"
	/etc/init.d/vsftpd start	
fi

#/etc/init.d/autofs start

exit