View Full Version : Linux environment vars
Where (what file/script) do I need to set environment vars in to make them available to programs/daemons before a user logs in?
.bashrc obviously no good as only run when user logs in.
I was thinking /etc/profile, but this didnt seem to do what I wanted - maybe the export statement should be at the end of the script?
just put them in /etc/rc.d/rc.local if you have one. What distro are you running? Different distros have different hidy holes for this stuff.
Joel
Originally posted by dafoot
Where (what file/script) do I need to set environment vars in to make them available to programs/daemons before a user logs in?
.bashrc obviously no good as only run when user logs in.
I was thinking /etc/profile, but this didnt seem to do what I wanted - maybe the export statement should be at the end of the script?
where did you have the export statement at the moment?
Have tried hiding it in a number of the startup scripts.
Running Fedora 3 (aka redhat)
What is it exactly that needs the variables before login, and what variables are you trying to add?
Joel
Bit more info probably useful....
using statements of the format:
export VAR_NAME="/full/system/path";
Need to set vars before certain /etc/rc3.d/SxDaemon links kick in as these need the variable.
Guess either the syntax I am using for the export is wrong or the scripts I have using have been executing after the rcx.d directories are processed.
Also tried creating script in /etc/init.d/varsettingscript and creating a symlink /etc/rc3.d/S50setvars to that script. (the daemons that need these vars are S83 and S85 so order here isn't the problem(?) )
In case ur wondering linux is not my usual choice of OS - too many config files :)
tryin to start tomcat auto at startup.
apache2 aka httpd is starting fine - tomcat complaining the Java vars are not set. Fair enuf - they're not!
Both installed to /usr/local/<tomcat/apache> respectively.
Looking at logs the rc.local is only executing after the rcx.d directories have been processed, so that no good as the env setting script.
ok, so
put this in a file
#!/bin/bash
export path=$PATH:/java/bin/path
JAVA_HOME=/path/to/java
export JAVA_HOME
save it as
S18setenv in /etc/rc3.d/ and the same in /etc/rc5.d/
chmod +x both files
and reboot, or your alternative, is to set it up in rc.local (probably easier this way, but its upto you):
JAVA_HOME=/path/to/java
export JAVA_HOME
<tomcat command to start, i have nfi what it is>
apachectl start
Joel
tried script u mention in /etc/rc3.d + /etc/rc5.d
my vars not set neither is PATH updated with addition of /java/path
while I think of it...how do /etc/rc3.d and /etc/rc.d/rc3.d
differ from one another? y have both?
/etc/rc3.d is runlevel 3 (command line) rc5.d is runlevel 5 (graphical)
Try renaming the files to S30setenv, the SXX just denotes which order they run on startup, my guess is that something later is overwriting your default paths. /etc/profile should work for adding paths too tho, the tomcat server must run as a user so adheres to that.
Joel
Thanks for suggestions - have sorted it now.
Had created a S83tomcat script that was supposed to start tomcat as tomcat user.
TRied adding the export VAR statements to that but didnt work, tried it again and it seems to be (closer to) working. Must have had something wrong in the syntax before I guess.
*hit head against nearest wall*
Thanks again for suggestions. Now to remember how I set up jk connector last time I did this!
I dont envy you :P
And you should make linux your choice OS, despite the config files, its a far better system :)
Joel
do like it - when it works
i just dont like spending time configuring and arsin about with stuf to get stuf working as i want.
tho i am impressed with this fedora3 - much better than last version (redhat8) i tried.
just know that adding my usb scanner/pocketPC sync etc would cause headaches.
usb scanner will probably work with xsane, depending on your pocketpc it might work with synCE
Joel
hmm....so thats my hardware covered...unfortunately I dont think there is a linux version of 'Rome:total war' etc
While dual boot is an option - it would mean arsing about with raid/bootloaders etc. had enuf of that at work ;)
what about emulators, could you play rome through wine?
or failing that, get 2 pc's you know you should. Then use vnc to connect to the other one wherever you are sat (and from work).
Did have 3 or 4 at one point, running various flavours of windows/linux. The intention was to use diff systems for diff tasks. Ended up using one for everything so got rid of others.
Wine will work for some stuff, but think it is questionable for games requiring 3d support? Adds a layer of complexity, and so slowness to games that are already quite demanding on my system.
Consoles are better for games, although linux is improving.
BTW Windows is nearly ready for the consumer
http://os.newsforge.com/article.pl?sid=05/05/18/2033216&tid=149&tid=73&tid=16
I will always maintain PC better for RTS style games. Mouse type device works better for this than console controller.
I do prefer the consoles for quick action games generally tho. (currently using xbox+playstation)
|