#!/bin/sh
#
# initAcerC300:    acer C300 init stuff
#
# Dusk 2005
# http://www.duskzone.it/works/linux/c300howto/

NAME="initAcerC300"
WLAN_ON_BOOT="off"    # "on" || "off"
MODEM_ON_BOOT="on"    # "on" || "off"

MODEM_SCRIPT="/etc/init.d/slmodemd"
WLAN_SCRIPT="/etc/init.d/ipw2200ctl"

# WARNING: this script assumes that all modules are correctly prepared to be used,
# there aren't any checks. It's also assumed that you auto-load "acerhk" by /etc/modules
# and that you have already setup modem and wlan init scripts

## ON SCREEN KEYS DEFINITIONS #################
setkeys() {
	echo 'Setting acer special keys... '
		#screen - screen lock
	setkeycodes 6c 152
		#screen - fn
	setkeycodes 6b 95
		#screen - up arrow
	setkeycodes 69 104
		#screen - down arrow
	setkeycodes 68 109
		#screen - screen rotation
	setkeycodes 67 177
	echo 'done'
}
###############################################

start() {
	setkeys
	case "$WLAN_ON_BOOT" in
		on) echo 'trying to enable wlan'
		    $WLAN_SCRIPT start
			;;
		off)echo 'trying to disable wlan'
		    $WLAN_SCRIPT stop
			;;
		*) echo WLAN_ON_BOOT value must be "on" or "off"
	esac

	case "$MODEM_ON_BOOT" in
		on) $MODEM_SCRIPT start && ln -s /dev/ttySL0 /dev/modem
			;;
		off) $MODEM_SCRIPT stop
			;;
		*) echo MODEM_ON_BOOT value must be "on" or "off"
	esac
}

stop() {
	echo 'Nothing to do';
	echo "use $MODEM_SCRIPT start/stop to enable/disable the smartlink modem"
        echo "and $WLAN_SCRIPT start/stop to enable/disable the ipw2200 adapter"
}

case "$1" in
  start)
	start
	;;
  stop)
	stop
	;;
  *)
        echo "Usage: /etc/init.d/$NAME {start|stop}"
	exit 1
esac					       
