Tiny Core Linux

Tiny Core Extensions => TCE Q&A Forum => Topic started by: polikuo on January 05, 2017, 12:32:52 AM

Title: Setting environment variables
Post by: polikuo on January 05, 2017, 12:32:52 AM
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, 04: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.
Title: Re: Setting environment variables
Post by: beginners++luck on June 21, 2024, 11:34:54 PM
> /etc/profile.d is the way.
How are environmental variables in Tinycore permanently set? I haven't found this. Direct editing of /etc/profile.d doesn't work; not being in /home/or /opt), it isn't backed up to my USB. I am trying to correct for the wrong search of ALSA's alias.config, and that can be done with an environmental variable ALSA_CONFIG_... Thanks!
Title: Re: Setting environment variables
Post by: Rich on June 21, 2024, 11:57:35 PM
Hi beginners++luck
Welcome to the forum.

... Direct editing of /etc/profile.d doesn't work; not being in /home/or /opt), it isn't backed up to my USB. ...
You can add it to your backup:
Code: [Select]
echo etc/profile.d >> /opt/.filetool.lst
filetool -b
Title: Re: Setting environment variables
Post by: beginners++luck on June 22, 2024, 01:03:31 AM
Thanks, Rich!