Edit /etc/profile

Discussion in 'Tomato Firmware' started by windom, Jul 3, 2018.

  1. windom

    windom Serious Server Member

    I want to edit /etc/profile which actually resides in /rom/etc/profile. That, of course, is a read-only file system. What is the technique for doing this? Maybe I need to use a different approach? One of the things I want to change is the path.

    windom
     
  2. Chmmmr

    Chmmmr Reformed Router Member

    I usually just add a command to the init script (/admin-scripts.asp).

    something like this:

    Code:
    echo "LABEL=ENTWARE /opt ext2 rw,noatime 1 1" >> /etc/fstab
     
  3. Sean B.

    Sean B. LI Guru Member

    You can add to the system path via the nvram ram variable env_path. IE:

    Code:
    nvram set env_path="/tmp/mnt/flashdrive:"
    nvram commit
    Make sure multiple paths are separated with a : , as well having a : end the line as well. If done from a shell, you must log out/log in for the change to take effect.
     
  4. koitsu

    koitsu Network Guru Member

    If it's for a single user (ex. root), then use dotfiles: /root/.profile will work just fine.

    If it's system-wide, and you truly need this: did you actually examine /etc/profile? If so, you would find these two lines:

    Code:
    [ -f /jffs/etc/profile ] && . /jffs/etc/profile
    [ -f /opt/etc/profile ] && . /opt/etc/profile
    
    From this, it should become quite apparent what you can do achieve additional settings or overwrites to whatever is in /etc/profile: just make sure you have one of those two files existing and you should be fine. If you're using a USB HDD or USB flash drive with Entware (previously known as Entware-ng or Entware-ng-3x), be aware that it installs a default /opt/etc/profile which you can tweak as you see fit.

    There is also another way, specifically using a bind mount, but the above mechanisms are already in place and don't require any magic/tweaking to accomplish. If you don't use Entware, then you can literally do something like this in Scripts -> Init:

    Code:
    mkdir -p -m 755 /opt/etc
    cat >> /opt/etc/profile < 'EOF'
    your
    profile
    contents
    here
    EOF
    chmod 644 /opt/etc/profile
    
    ...and the next time you get a shell, it should read /etc/profile, which in turn sources/reads /opt/etc/profile. You can use the same methodology as above but for /root/.profile if desired.
     
    Monk E. Boy likes this.
  5. windom

    windom Serious Server Member

    @koltsu, your first suggestion is just what I need. I feel so dull-witted not having seen that.
    Thank you.

    windom
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice