mirror of
https://github.com/Heleguo/lede.git
synced 2025-12-16 19:01:32 +00:00
base-files: compatible with old luci
This commit is contained in:
parent
dace6c0b75
commit
f19009ba68
@ -3,7 +3,6 @@
|
|||||||
CFG=/etc/board.json
|
CFG=/etc/board.json
|
||||||
|
|
||||||
. /usr/share/libubox/jshn.sh
|
. /usr/share/libubox/jshn.sh
|
||||||
. /lib/functions/ipv4.sh
|
|
||||||
|
|
||||||
[ -s $CFG ] || /bin/board_detect || exit 1
|
[ -s $CFG ] || /bin/board_detect || exit 1
|
||||||
[ -s /etc/config/network -a -s /etc/config/system ] && exit 0
|
[ -s /etc/config/network -a -s /etc/config/system ] && exit 0
|
||||||
@ -43,16 +42,16 @@ generate_static_network() {
|
|||||||
set network.loopback='interface'
|
set network.loopback='interface'
|
||||||
set network.loopback.device='lo'
|
set network.loopback.device='lo'
|
||||||
set network.loopback.proto='static'
|
set network.loopback.proto='static'
|
||||||
add_list network.loopback.ipaddr='127.0.0.1/8'
|
set network.loopback.ipaddr='127.0.0.1'
|
||||||
delete network.globals
|
set network.loopback.netmask='255.0.0.0'
|
||||||
set network.globals='globals'
|
|
||||||
set network.globals.dhcp_default_duid='auto'
|
|
||||||
EOF
|
EOF
|
||||||
[ -e /proc/sys/net/ipv6 ] && {
|
[ -e /proc/sys/net/ipv6 ] && {
|
||||||
uci -q batch <<-EOF
|
uci -q batch <<-EOF
|
||||||
set network.globals.ula_prefix='auto'
|
delete network.globals
|
||||||
EOF
|
set network.globals='globals'
|
||||||
}
|
set network.globals.ula_prefix='auto'
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
if json_is_a dsl object; then
|
if json_is_a dsl object; then
|
||||||
json_select dsl
|
json_select dsl
|
||||||
@ -161,19 +160,18 @@ generate_network() {
|
|||||||
|
|
||||||
case "$protocol" in
|
case "$protocol" in
|
||||||
static)
|
static)
|
||||||
local ipad netm prefix
|
local ipad
|
||||||
case "$1" in
|
case "$1" in
|
||||||
lan) ipad=${ipaddr:-"192.168.1.1"} ;;
|
lan) ipad=${ipaddr:-"192.168.1.1"} ;;
|
||||||
*) ipad=${ipaddr:-"192.168.$((addr_offset++)).1"} ;;
|
*) ipad=${ipaddr:-"192.168.$((addr_offset++)).1"} ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
netm=${netmask:-"255.255.255.0"}
|
netm=${netmask:-"255.255.255.0"}
|
||||||
str2ip netm "$netm"
|
|
||||||
netmask2prefix prefix "$netm"
|
|
||||||
|
|
||||||
uci -q batch <<-EOF
|
uci -q batch <<-EOF
|
||||||
set network.$1.proto='static'
|
set network.$1.proto='static'
|
||||||
add_list network.$1.ipaddr='$ipad/$prefix'
|
set network.$1.ipaddr='$ipad'
|
||||||
|
set network.$1.netmask='$netm'
|
||||||
EOF
|
EOF
|
||||||
[ -e /proc/sys/net/ipv6 ] && uci set network.$1.ip6assign='60'
|
[ -e /proc/sys/net/ipv6 ] && uci set network.$1.ip6assign='60'
|
||||||
;;
|
;;
|
||||||
|
|||||||
@ -10,6 +10,7 @@ uci_apply_defaults() {
|
|||||||
cd /etc/uci-defaults || return 0
|
cd /etc/uci-defaults || return 0
|
||||||
files="$(ls)"
|
files="$(ls)"
|
||||||
[ -z "$files" ] && return 0
|
[ -z "$files" ] && return 0
|
||||||
|
mkdir -p /tmp/.uci
|
||||||
applied=""
|
applied=""
|
||||||
for file in $files; do
|
for file in $files; do
|
||||||
( . "./$(basename $file)" ) && applied="$applied $file"
|
( . "./$(basename $file)" ) && applied="$applied $file"
|
||||||
|
|||||||
@ -1,49 +0,0 @@
|
|||||||
. /lib/functions.sh
|
|
||||||
|
|
||||||
migrate_ports() {
|
|
||||||
local config="$1"
|
|
||||||
local type ports ifname
|
|
||||||
|
|
||||||
config_get type "$config" type
|
|
||||||
[ "$type" != "bridge" ] && return
|
|
||||||
|
|
||||||
config_get ports "$config" ports
|
|
||||||
[ -n "$ports" ] && return
|
|
||||||
|
|
||||||
config_get ifname "$config" ifname
|
|
||||||
[ -z "$ifname" ] && return
|
|
||||||
|
|
||||||
for port in $ifname; do
|
|
||||||
uci add_list network.$config.ports="$port"
|
|
||||||
done
|
|
||||||
uci delete network.$config.ifname
|
|
||||||
}
|
|
||||||
|
|
||||||
migrate_bridge() {
|
|
||||||
local config="$1"
|
|
||||||
local type ifname
|
|
||||||
|
|
||||||
config_get type "$config" type
|
|
||||||
[ "$type" != "bridge" ] && return
|
|
||||||
|
|
||||||
config_get ifname "$config" ifname
|
|
||||||
|
|
||||||
uci -q batch <<-EOF
|
|
||||||
add network device
|
|
||||||
set network.@device[-1].name='br-$config'
|
|
||||||
set network.@device[-1].type='bridge'
|
|
||||||
EOF
|
|
||||||
for port in $ifname; do
|
|
||||||
uci add_list network.@device[-1].ports="$port"
|
|
||||||
done
|
|
||||||
|
|
||||||
uci -q batch <<-EOF
|
|
||||||
delete network.$config.type
|
|
||||||
delete network.$config.ifname
|
|
||||||
set network.$config.device='br-$config'
|
|
||||||
EOF
|
|
||||||
}
|
|
||||||
|
|
||||||
config_load network
|
|
||||||
config_foreach migrate_ports device
|
|
||||||
config_foreach migrate_bridge interface
|
|
||||||
@ -1,9 +0,0 @@
|
|||||||
[ "$(uci -q get network.globals.dhcp_default_duid)" != "auto" ] && exit 0
|
|
||||||
|
|
||||||
uci -q batch <<-EOF >/dev/null
|
|
||||||
# DUID-UUID - RFC6355
|
|
||||||
set network.globals.dhcp_default_duid="$(hexdump -vn 16 -e '"0004" 2/2 "%x"' /dev/urandom)"
|
|
||||||
commit network
|
|
||||||
EOF
|
|
||||||
|
|
||||||
exit 0
|
|
||||||
Loading…
Reference in New Issue
Block a user