Author: hauke
Date: 2016-04-17 14:49:54 +0200 (Sun, 17 Apr 2016)
New Revision: 49179

Modified:
   trunk/package/base-files/files/bin/config_generate
Log:
base-files: allow to set arbitrary ip address and netmask

Signed-off-by: Roman Yeryomin <[email protected]>
Signed-off-by: Hauke Mehrtens <[email protected]>


Modified: trunk/package/base-files/files/bin/config_generate
===================================================================
--- trunk/package/base-files/files/bin/config_generate  2016-04-17 12:49:30 UTC 
(rev 49178)
+++ trunk/package/base-files/files/bin/config_generate  2016-04-17 12:49:54 UTC 
(rev 49179)
@@ -56,11 +56,11 @@
 
 addr_offset=2
 generate_network() {
-       local ifname macaddr protocol type
+       local ifname macaddr protocol type ipaddr netmask
 
        json_select network
                json_select "$1"
-                       json_get_vars ifname macaddr protocol
+                       json_get_vars ifname macaddr protocol ipaddr netmask
                json_select ..
        json_select ..
 
@@ -88,16 +88,18 @@
 
        case "$protocol" in
                static)
-                       local ipaddr
+                       local ipad
                        case "$1" in
-                               lan) ipaddr="192.168.1.1" ;;
-                               *) ipaddr="192.168.$((addr_offset++)).1" ;;
+                               lan) ipad=${ipaddr:-"192.168.1.1"} ;;
+                               *) 
ipad=${ipaddr:-"192.168.$((addr_offset++)).1"} ;;
                        esac
 
+                       netm=${netmask:-"255.255.255.0"}
+
                        uci -q batch <<-EOF
                                set network.$1.proto='static'
-                               set network.$1.ipaddr='$ipaddr'
-                               set network.$1.netmask='255.255.255.0'
+                               set network.$1.ipaddr='$ipad'
+                               set network.$1.netmask='$netm'
                                set network.$1.ip6assign='60'
                        EOF
                ;;
_______________________________________________
openwrt-commits mailing list
[email protected]
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-commits

Reply via email to