LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 08-04-2006, 01:37 PM   #1
mh983
LQ Newbie
 
Registered: Jul 2006
Posts: 7

Rep: Reputation: 0
rc scripts, profile.d, and startup


I'm using some scripts in /etc/profile.d to define JAVA_HOME among other things. I also have some rc scripts in /etc/rc.d, such as rc.tomcat and rc.pgsql that depend on environment settings in /etc/profile.d.

However, at startup the scripts in /etc/profile.d are apparently not sourced, as I see errors from rc.tomcat saying JAVA_HOME not defined, etc.

I added ". /etc/profile.d/jdk.sh" to rc.tomcat and it works fine.

Does anyone know why I have to do this? Is there a better way?

/etc/profile clearly sources the scripts in /etc/profile.d, and if I just log in as root and then start up my rc scripts, they are fine. My guess is that at bootup, it is not a login shell, but I'm really not that familiar with the process.

On a side note, when this happens, I can see the error message such as "JAVA_HOME not defined" on the screen, but it doesn't show up in dmesg or the systemlog. Is that normal? Is there an easy way to log these things?

Thanks for any help.

mike
 
Old 08-04-2006, 02:28 PM   #2
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,141

Rep: Reputation: 168Reputation: 168
/etc/profile and /etc/profile.d/* are accessed on login, not startup, so none of the values they set are in effect when you boot the box. What you've done isn't wrong in that it works although you can just add the environment variables to rc.tomcat. There's a similar thread to this here.

The "JAVA_HOME not defined" message being displayed on the screen and not the logs may be because it is sent to stdout instead of stderr (it's something I've never checked). The logger command can be used in your startup scripts to send output to syslog (man logger).
 
Old 08-04-2006, 06:20 PM   #3
Woodsman
Senior Member
 
Registered: Oct 2005
Distribution: Slackware 14.1
Posts: 3,482

Rep: Reputation: 546Reputation: 546Reputation: 546Reputation: 546Reputation: 546Reputation: 546
In a normal Slackware installation, the /etc/profile script will execute all executable scripts located in the /etc/profile.d directory.

A couple of things to easily overlook:

1. Ensure the script you created in /etc/profile.d is executable and readable (755 file permissions).
2. Ensure the script is tagged with the normal shell declaration at the beginning of the file (#!/bin/sh).

Sourcing and executing a script are not the same. Sourcing means that a script is run as though the external code is actually written into the calling script. Executing a script means that the script is run externally. Thus, sourcing a script (. /etc/profile.d/jdk.sh or source /etc/profile.d/jdk.sh) will set the environment variables you want and the script need not be tagged as executable or declared internally as a shell script. To be run externally as within /etc/profile or directly from the command line, then the jdk.sh script needs to be executable (chmod +x) and properly declared internally as a shell script (#!/bin/sh).

FWIW, generally, in Slackware, use the /etc/rc.d directory for running scripts to run services and the /etc/profile.d directory for running scripts to set global environment variables.

I hope this helps.
 
  


Reply



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
Startup Scripts Mulsiphix Linux - Newbie 2 01-15-2006 10:26 PM
Mandriva startup scripts (need to add something to startup before X starts) thunderweasel Mandriva 3 01-01-2006 12:55 AM
Startup profile?? kprocter Linux - General 1 07-08-2003 08:20 AM
Startup (rc, profile, etc) scripts NewRedHatter Linux - Newbie 1 08-31-2002 12:36 AM
X Startup Scripts JHuizingh Linux - General 1 09-18-2001 01:02 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 06:28 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration