summaryrefslogtreecommitdiff
path: root/shared/uci-defaults/0_default_config
blob: 010de78c148ca0fd34d31850bec04ba3e675312d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/sh

opkg install /ipks/*
ip link set eth0 mtu 1460

rule_name=$(uci add network rule)

# Extract configs from /proc/cmdline
bridged_wifi_tap=false
instance_name="cvd-1"
words=$(cat /proc/cmdline)
while
    word=${words%%" "*}
    if [ "$word" = "bridged_wifi_tap=true" ]; then
        bridged_wifi_tap=true
    elif echo "$word" | grep "^wan_gateway="; then
        uci set network.wan.gateway=${word#*"="}
    elif echo "$word" | grep "^wan_ipaddr="; then
        uci set network.wan.ipaddr=${word#*"="}
    elif echo "$word" | grep "^wan_broadcast="; then
        uci set network.wan.broadcast=${word#*"="}
    elif echo "$word" | grep "^instance_name="; then
        instance_name=${word#*"="}
    fi
    next=${words#*" "}
    [ "$words" != "$next" ]
do
    words=$next
done

if $bridged_wifi_tap; then
    uci set network.wan.netmask="255.255.255.0"
else
    uci set network.wan.netmask="255.255.255.252"
fi

# Modify the path of the web service, luci.
ln -sf $(readlink -f /www/cgi-bin/cgi-backup) /www/cgi-bin/cgi-backup
ln -sf $(readlink -f /www/cgi-bin/cgi-download) /www/cgi-bin/cgi-download
ln -sf $(readlink -f /www/cgi-bin/cgi-exec) /www/cgi-bin/cgi-exec
ln -sf $(readlink -f /www/cgi-bin/cgi-upload) /www/cgi-bin/cgi-upload
web_base="devices/$instance_name/openwrt"
mkdir -p "/www/$web_base/"
mv /www/cgi-bin "/www/$web_base/"
mv /www/luci-static "/www/$web_base/"
mv /www/index.html "/www/$web_base/"
echo "<meta http-equiv=\"refresh\" content=\"0; url=$web_base/\" />" > /www/index.html
uci set uhttpd.main.cgi_prefix="/$web_base/cgi-bin"
uci delete uhttpd.main.lua_prefix
uci add_list uhttpd.main.lua_prefix="/$web_base/cgi-bin/luci=/usr/lib/lua/luci/sgi/uhttpd.lua"
uci set uhttpd.main.ubus_prefix="/$web_base/ubus"
uci set luci.main.mediaurlbase="/$web_base/luci-static/bootstrap"
uci set luci.main.resourcebase="/$web_base/luci-static/resources"
uci set luci.main.ubuspath="/$web_base/ubus/"
uci set luci.themes.Bootstrap="/$web_base/luci-static/bootstrap"
uci set luci.themes.BootstrapDark="/$web_base/luci-static/bootstrap-dark"
uci set luci.themes.BootstrapLight="/$web_base/luci-static/bootstrap-light"

uci commit

# Regarding hostapd issue of OpenWRT 22.03.X versions, reboot it.
reboot