#! /bin/sh
#
# etc/wlan/network
#
# Copyright (C) 2003 Lineo Solutions, Inc.  All Rights Reserved.
# --------------------------------------------------------------------
#
# based on etc/pcmcia/network
#
# set up network for Sarp SL
#
# network action device
#     action : start | stop
#     device : wlan0 ...
#

usage()
{
	echo "usage: network {start|stop} device"
	exit 1
}

# load up the network shared scripts
if [ -r ./shared ] ; then . ./shared ; else . /etc/pcmcia/shared ; fi

if [ ! -f /etc/pcmcia/network.functions ] ; then
    echo "/etc/pcmcia/network.functions not present, aborting"
    exit 1
fi
. /etc/pcmcia/network.functions

if [ ! -f /etc/wlan/wlan.conf ] ; then
    echo "/etc/wlan/wlan.conf not present, aborting"
    exit 1
fi
. /etc/wlan/wlan.conf

ACTION=$1
DEVICE=$2
if [ "$DEVICE" = "" ]; then
    usage
    exit 1
fi
eval 'SCHEME=$SCHEME_'$DEVICE
if [ "$SCHEME" = "" ]; then
    echo "SCHEME_$DEVICE is not set in /etc/wlan/wlan.conf"
    exit 1
fi
if [ "$SCHEME" = "wlanenable" ]; then
    exit 0
fi

# Load site-specific settings
ADDRESS="$SCHEME,$SOCKET,$INSTANCE,$HWADDR"
start_fn () { return; }
stop_fn () { return; }
. /etc/pcmcia/network.opts

case "$ACTION" in

'start')
    ifup
    start_fn $DEVICE
    ;;

'stop')
    stop_fn $DEVICE
    ifdown
    ;;

*)
    usage
    ;;

esac

exit 0
