#!/bin/sh [ -z "$1" ] && { echo "Please specify mode: ap, wisp, 3g, router" } model=$(awk 'BEGIN{FS="-"} /machine/ {print tolower($2)}' /proc/cpuinfo) eth_wan=eth0 eth_lan=eth1 case "$model" in "ar300"|"ar300m"|"inet"|"ar150") ;; "mt300n"|"mt300a") eth_wan=eth0.2 eth_lan=eth0.1 ;; esac mode=$1 current_wan_proto=$(uci get network.wan.proto) current_proto=$(uci get network.lan.proto) #orig_wan_proto=$(uci get network.wan._orig_proto) #orig_lan_proto=$(uci get network.lan._orig_proto) case "$mode" in "router") uci set network.wan.ifname="$eth_wan" #proto can be dhcp, static, pppoe etc, we can just keep it [ -z "$current_wan_proto" ] && uci set network.wan.proto='dhcp' uci set network.lan.ifname="$eth_lan" uci set network.lan.proto='static' #regardless the proto, we can set default ip [ -z "$(uci get network.lan.ipaddr)" ] && { uci set network.lan.ipaddr='192.168.8.1' uci set network.lan.netmask='255.255.255.0' } uci set dhcp.lan.ignore='0' ;; "ap") uci set network.wan.ifname='' uci set network.lan.ifname="$eth_wan $eth_lan" uci set dhcp.lan.ignore='1' ;; "wisp") uci set network.wan.ifname='' uci set network.lan.ifname="$eth_lan" uci set dhcp.lan.ignore='0' #start repeater auto detect script to choose repeater #connect_wisp & ;; "3g") uci set network.wan.protp='3g' uci set dhcp.lan.ignore='0' #start 3g auto detect script to set device, server, apn #connect_3g & ;; esac uci commit network uci commit dhcp /etc/init.d/network restart