[ -z "$ROOT" ] && ROOT=/www
CGI=$ROOT/web/mobile
CONFIG=$ROOT/config

source $CONFIG/ap.conf
[ -s $CONFIG/mobile.conf ] && source $CONFIG/mobile.conf

# UHTTPD
uciKey=uhttpd.config
uci -q del $uciKey
uci set $uciKey=uhttpd
uci set $uciKey.rfc1918_filter=0
uci set $uciKey.max_requests=10
uci set $uciKey.max_connections=100
uci set $uciKey.interpreter=.lua=/usr/bin/lua
uci set $uciKey.lua_prefix=/
uci set $uciKey.lua_handler=$CGI/handler.lua
uci set $uciKey.script_timeout=60
uci set $uciKey.network_timeout=30
uci set $uciKey.http_keepalive=1
uci set $uciKey.tcp_keepalive=1
uci set $uciKey.no_dirlists=1
uci set $uciKey.no_symlinks=1
uci add_list $uciKey.listen_http=80

# NETWORK
uciKey=network.wan
uci -q del $uciKey
uci set $uciKey=interface
uci set $uciKey.device=$MOBILE_DEV
uci set $uciKey.proto=qmi
[ -z "$MOBILE_APN" ] || uci set $uciKey.apn="$MOBILE_APN"
[ -z "$MOBILE_USERNAME" ] || uci set $uciKey.username="$MOBILE_USERNAME"
[ -z "$MOBILE_PASSWORD" ] || uci set $uciKey.password="$MOBILE_PASSWORD"
[ -z "$MOBILE_PIN" ] || uci set $uciKey.pin="$MOBILE_PIN"