Skip to content

obuspa: init: fix manipulating USP_BOARD_IFNAME env var in .profile

Roman Azarenko requested to merge obuspa-sed-root-profile-fix into devel

This addresses two problems:

  1. sed 'g/export USP_BOARD_NAME/d' would erase all the lines in the affected file, regardless of whether there was a match or not. Replace this with sed '/foo/d', which correctly deletes just the affected lines. For example:

    $ cat <<'EOF' >foo
    export LINE1=one
    export USP_BOARD_IFNAME=two
    export LINE3=three
    export USP_BOARD_IFNAME=four
    export LINE5=five
    EOF
    $ sed 'g/export USP_BOARD_NAME/d' foo  # bad
    
    $ sed '/export USP_BOARD_NAME/d' foo  # good
    export LINE1=one
    export LINE3=three
    export LINE5=five
  2. Changing an interface/ifname in UCI configuration would end up appending to /root/.profile due to how the control flow was written. For example:

    $ cat /root/.profile
    
    export USP_BOARD_IFNAME=lo
    $ grep -E 'interface|ifname' /etc/config/obuspa
    	option interface 'loopback'
    $ sed -i 's/loopback/lan/' /etc/config/obuspa
    $ /etc/init.d/obuspa restart
    $ cat /root/.profile
    
    export USP_BOARD_IFNAME=lo
    export USP_BOARD_IFNAME=br-lan

Merge request reports