#!/bin/sh

echo "Setting the Ethernet speed to 100Mb/s Full-duplex"
TRD_LIB=ethtool
if [ ! -d ${TRD_LIB} ]
then
  ifdown eth0
  # Give time for Windows to recognize the disappearance of this connection
  sleep 5
  ethtool -s eth0 autoneg on speed 100 duplex full
  ifup eth0
  sleep 5
fi

# ensure that this can be executed for debugging use
chmod 777 /mnt/SMC/remountMediaRW.sh

echo "Starting SMCServer..."
if [ -b /dev/mmcblk0p5 ]
then
	cd /media
	./LxServer.elf &
	sleep 2
	#Give some time for the LxServer to load the ServoParams's file
	./SMCServer.elf &
#	Not yet ready for general release.  Manually edit/launch to test.

else
	cd /mnt
	./SMCServer.elf &
fi

echo "Updating time if necessary..."
todate=$(date +%Y)
badyear=2001
if [ $todate == $badyear ]  # date should NEVER be 2001 for the SMC.  NEVER.
then
    echo Fixing Time...
    sleep 20
    ntpd -p 0.pool.ntp.org 1.pool.ntp.org 2.pool.ntp.org 
    sleep 20
    hwclock --systohc
    echo Fixed.
fi

#Disable the COM0 serial port console
if [ -f /etc/inittab ]  
then
#echo "in the process of disabling the COM0"
sed -i 's/\PS0/#\1/' /etc/inittab 
telinit q 
fi


