Tiny Core Linux

Tiny Core Extensions => TCE Q&A Forum => Topic started by: polikuo on January 04, 2017, 09:32:52 PM

Title: Setting environment variables
Post by: polikuo on January 04, 2017, 09:32:52 PM
What is the best way to set environment variables for an extension ?
Is there an official way ?  ???

I have some ideas:
  1. Modify ~/.ashrc    with "tce.installed/script"
  2. Modify ~/.profile   with "tce.installed/script"
  3. Add a file into directory /etc/profile.d
      (Must be named as "*.sh", see http://forum.tinycorelinux.net/index.php/topic,5086.msg27095.html (http://forum.tinycorelinux.net/index.php/topic,5086.msg27095.html))

If one choose to modify "~/.ashrc:~/.profile" with "tce.installed/script"
I can come up 2 ways:
  -- echo lines to the files: echo export FOO=\"Hello World\" >> ~/.ashrc
  -- create config files and source it: echo source /path/to/config/files >> ~/.ashrc

Generally speaking, the benefit of modifying "~/.ashrc:~/.profile" is that the user can use it right away.
However, users might have change their setting, it's not easy to avoid messing up these settings.

On the other hand, by adding a file into directory /etc/profile.d,
the modification would be system wide, but requires a user to log out and log back in.

Any ideas ? ???
Title: Re: Setting environment variables
Post by: curaga on January 05, 2017, 01:49:41 AM
An extension shouldn't modify ~/.profile or ~/.ashrc, unless it's a private one and you know it won't mangle anything. /etc/profile.d is the way.