blob: cec33beeae05bc0d9d214b423b7c2355312d207d [file] [log] [blame]
#!/bin/sh
# Simple script to switch wan interface
lan_port=""
mgmt_vlan=""
usage()
{
echo "Usage: $(basename $0) [-l lan] [-m mgmtvlan] <wan>" >&2
echo " lan - optional lan interface, e.g. eth0." >&2
echo " mgmtvlan - optional management vlan id, e.g. 4090" >&2
echo " wan - wan interface." >&2
}
switch_port()
{
wan_port=$1
/etc/init.d/S40lan stop
/etc/init.d/S72wan stop
echo $wan_port > /etc/config/wanport
echo $lan_port > /etc/config/lanport
echo $mgmt_vlan > /etc/config/mgmtvlan
if [ "x$lan_port" != "x" ]; then
/etc/init.d/S40lan start
fi
/etc/init.d/S72wan start
}
while getopts l:m: o; do
case $o in
l) lan_port=$OPTARG;;
m) mgmt_vlan=$OPTARG;;
esac
done
shift $(($OPTIND-1))
if [ $# -ne 1 ]; then
usage
exit 1
fi
switch_port $1