Automated replacement of /etc/network/interfaces

Home Forums Conduit: mLinux Model Automated replacement of /etc/network/interfaces

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #32568
    Martin Bures
    Participant

    I am trying to build an automated installer script to flash our gateways with the Senet Packet forwarder. I am having trouble replacing the /etc/network/interfaces file so that I can turn off the static ip address on 192.168.2.1 and have it listen to dhcp on 192.168.1.x.

    When I try to do this with a script – either with sed or by directly replacing the file, it does not seem to persist. When I do it manually with vi, it works.

    Do you have any thoughts on how to accomplish this?

    #32569
    Jeff Hatch
    Keymaster

    Hello Martin,

    Could you post the code that you are trying to do this with, both the “replacing” code and the sed code? Maybe someone can help you fix the code if there is something incorrect.

    Jeff

    #32576
    Martin Bures
    Participant

    #!/bin/sh

    ntpdate pool.ntp.org

    sed -i -e ‘s/yes/no/g’ /etc/default/lora-network-server
    sed -i -e ‘s/static/dhcp/g’ /etc/network/interfaces
    sed -i -e ‘s/address/#address/g’ /etc/network/interfaces
    sed -i -e ‘s/netmask/#netmask/g’ /etc/network/interfaces

    cat /etc/default/lora-network-server
    cat /etc/network/interfaces | grep dhcp -C 8

    /etc/init.d/networking restart

    #32578
    Jeff Hatch
    Keymaster

    Hello Martin,

    I figured out how mLinux may be thwarting your editing via script. There is a script “/etc/init.d/config” that creates links to all the configuration files since I believe that /etc is not writable on some systems (I am not sure why mLinux is behaving in this manner other than on mLinux upgrades the /var/config directory and partition there don’t get overwritten). Anyway, I believe that your script is actually overwriting the link and not the file the link points to, ie. instead of editing the file /etc/network/interfaces->/var/config/network/interfaces, it is reading the resolved linked file “/var/config/network/interfaces”, editing it, and then writing to /etc/network/interfaces creating a new file. This works as expected.

    However, upon reboot, the /etc/init.d/config script runs and since /etc/network/interfaces is not a link it blows /etc/network/interfaces away and creates the link described in the previous paragraph.

    To address this try editing the file in /var/config/network/interfaces instead. That way it should persist.

    Thank You,

    Jeff

    #32579
    Martin Bures
    Participant

    THANK YOU.

    I will take a look at this.

    Best Regards.
    Martin.

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.