WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Setting environment variables  (Read 3596 times)

Offline polikuo

  • Hero Member
  • *****
  • Posts: 714
Setting environment variables
« 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)

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 ? ???
« Last Edit: January 05, 2017, 12:35:19 AM by polikuo »

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 11037
Re: Setting environment variables
« Reply #1 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.
The only barriers that can stop you are the ones you create yourself.

Offline beginners++luck

  • Newbie
  • *
  • Posts: 2
Re: Setting environment variables
« Reply #2 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!

Online Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11560
Re: Setting environment variables
« Reply #3 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

Offline beginners++luck

  • Newbie
  • *
  • Posts: 2
Re: Setting environment variables
« Reply #4 on: June 22, 2024, 01:03:31 AM »
Thanks, Rich!