Hi, I want to configure my network interface during boot via a config file. However I can not configure it properly.

Can anybody help ?

script:

#!/bin/sh /etc/rc.common
# iptables script

START=40


start() {

    setip

    file="/www/config/ipaddr.txt"

    { read -r f1; read -r f2; read -r f3; read -r f4;} < $file

    printf '%s %s %s\n' "$f1" "$f2" "$f3" "$f4"


    if [ "$f4" = "static" ]; then
        uci delete network.lan.proto
        uci set networ.lan.proto='static'
        uci set networ.lan.netmask=$f2
        uci set networ.lan.ip6assign='60'
        uci set networ.lan.ipaddr=$f1
        uci commit network
    fi


    if [ "$f4" = "dhcp" ]; then
        uci delete networ.lan.proto
        uci delete networ.lan.netmask
        uci delete networ.lan.ip6assign
        uci delete networ.lan.ipaddr
        uci set network.lan.proto='dhcp'
        uci commit network
    fi
} 

config file

192.168.0.11
255.255.255.0
192.168.0.1
static

(Last edited by enkavak on 20 Jul 2017, 17:51)