base-files: allow to set arbitrary ip address and netmask
Signed-off-by: Roman Yeryomin <roman@advem.lv> Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de> SVN-Revision: 49179
This commit is contained in:
parent
336ad4c9aa
commit
ea6d36111b
1 changed files with 9 additions and 7 deletions
|
@ -56,11 +56,11 @@ generate_static_network() {
|
||||||
|
|
||||||
addr_offset=2
|
addr_offset=2
|
||||||
generate_network() {
|
generate_network() {
|
||||||
local ifname macaddr protocol type
|
local ifname macaddr protocol type ipaddr netmask
|
||||||
|
|
||||||
json_select network
|
json_select network
|
||||||
json_select "$1"
|
json_select "$1"
|
||||||
json_get_vars ifname macaddr protocol
|
json_get_vars ifname macaddr protocol ipaddr netmask
|
||||||
json_select ..
|
json_select ..
|
||||||
json_select ..
|
json_select ..
|
||||||
|
|
||||||
|
@ -88,16 +88,18 @@ generate_network() {
|
||||||
|
|
||||||
case "$protocol" in
|
case "$protocol" in
|
||||||
static)
|
static)
|
||||||
local ipaddr
|
local ipad
|
||||||
case "$1" in
|
case "$1" in
|
||||||
lan) ipaddr="192.168.1.1" ;;
|
lan) ipad=${ipaddr:-"192.168.1.1"} ;;
|
||||||
*) ipaddr="192.168.$((addr_offset++)).1" ;;
|
*) ipad=${ipaddr:-"192.168.$((addr_offset++)).1"} ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
netm=${netmask:-"255.255.255.0"}
|
||||||
|
|
||||||
uci -q batch <<-EOF
|
uci -q batch <<-EOF
|
||||||
set network.$1.proto='static'
|
set network.$1.proto='static'
|
||||||
set network.$1.ipaddr='$ipaddr'
|
set network.$1.ipaddr='$ipad'
|
||||||
set network.$1.netmask='255.255.255.0'
|
set network.$1.netmask='$netm'
|
||||||
set network.$1.ip6assign='60'
|
set network.$1.ip6assign='60'
|
||||||
EOF
|
EOF
|
||||||
;;
|
;;
|
||||||
|
|
Loading…
Reference in a new issue