LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 10-07-2010, 06:06 PM   #1
dchester11
LQ Newbie
 
Registered: Feb 2010
Posts: 21

Rep: Reputation: 0
chkconfig runs script with different PATH values


I have a question regarding the user that chkconfig runs as. My chkconfig script calls some other scripts to start up a tomcat instance. But the secondary scripts use %JAVA_HOME and for some reason the user it's running under doesn't have that defined. I can call the scripts directly as the root or as another user and it works properly. But I added an echo in the script and when chkconfig calls the script it has a much smaller $PATH and no $JAVA_HOME. Any ideas what is happening here??
 
Old 10-07-2010, 06:40 PM   #2
kbp
Senior Member
 
Registered: Aug 2009
Posts: 3,758

Rep: Reputation: 643Reputation: 643Reputation: 643Reputation: 643Reputation: 643Reputation: 643
When using scripts you shouldn't assume that any variables are 'inherited', set them explicitly or source a file that sets them. This is especially true if your startup script is using 'su' to launch a process as another user, by default su will sanitise the environment before executing the script.

Do something like:
Code:
su - tomcat -c ". /home/tomcat/env.sh; /opt/tomcat/bin/tomcatctl start"
cheers
 
Old 10-07-2010, 08:14 PM   #3
dchester11
LQ Newbie
 
Registered: Feb 2010
Posts: 21

Original Poster
Rep: Reputation: 0
So even if I have the scripts setup in /etc/profile.d when chkconfig runs scripts and executes a su command, these may not be applied? Oy! This has been making my head explode all day. It seems like you would be able to set system level variables that would always apply. Not the case though?
 
Old 10-07-2010, 09:36 PM   #4
kbp
Senior Member
 
Registered: Aug 2009
Posts: 3,758

Rep: Reputation: 643Reputation: 643Reputation: 643Reputation: 643Reputation: 643Reputation: 643
It's always better to be explicit than to trust in something that may change underneath you
 
  


Reply

Tags
chkconfig, fedora, java, user


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Bash script is enterpreting $1, $2 values in awk script ... praveen_218 Programming 4 09-14-2009 03:38 PM
how to register auto start/stop service script with chkconfig travellers Linux - Software 8 06-15-2009 11:02 AM
bash script path issue - how to pass a path as a string to a variable PiNPOiNT Programming 5 04-17-2009 05:48 PM
Shell Script: want to insert values in database when update script runs ring Programming 2 10-25-2007 10:48 PM
script to change unix path to windows path in all files csross Programming 8 04-29-2006 01:05 PM


All times are GMT -5. The time now is 03:44 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration