summaryrefslogtreecommitdiff
path: root/package/base-files
diff options
context:
space:
mode:
authorHauke Mehrtens <hauke@hauke-m.de>2016-04-17 12:49:54 +0000
committerHauke Mehrtens <hauke@hauke-m.de>2016-04-17 12:49:54 +0000
commitea6d36111ba9d76ba46b9382d47283aa015e7039 (patch)
tree3f6dc17db5ecf2f7599c851b3c8e5e2897a1d852 /package/base-files
parent336ad4c9aab2f102ec7d4f8c01d0e592e2e2ad5d (diff)
downloadmtk-20170518-ea6d36111ba9d76ba46b9382d47283aa015e7039.zip
mtk-20170518-ea6d36111ba9d76ba46b9382d47283aa015e7039.tar.gz
mtk-20170518-ea6d36111ba9d76ba46b9382d47283aa015e7039.tar.bz2
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
Diffstat (limited to 'package/base-files')
-rwxr-xr-xpackage/base-files/files/bin/config_generate16
1 files changed, 9 insertions, 7 deletions
diff --git a/package/base-files/files/bin/config_generate b/package/base-files/files/bin/config_generate
index 4256d3c..03d1a36 100755
--- a/package/base-files/files/bin/config_generate
+++ b/package/base-files/files/bin/config_generate
@@ -56,11 +56,11 @@ generate_static_network() {
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 @@ generate_network() {
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
;;