You are not logged in.

#1 2010-03-19 06:25:17

ngoonee
Forum Fellow
From: Between Thailand and Singapore
Registered: 2009-03-17
Posts: 7,360

[solved] JAVA_HOME env variable for daemons

Hi all,

I'm writing up a PKGBUILD for funambol, a java-based synchronization server. It runs fine for me as long as the JAVA_HOME env variable is set. Unfortunately, when I create an /etc/rc.d script for funambol and run it, that env variable is not set. Neither is it set when I use sudo. I have to su to root before running the /etc/rc.d script.

Short of hard-coding JAVA_HOME within the /etc/rc.d script, is there any other way for me to use the JAVA_HOME environment variable? Where is it set, anyway, that its not available when booting up?

Last edited by ngoonee (2010-03-19 07:26:55)


Allan-Volunteer on the (topic being discussed) mailn lists. You never get the people who matters attention on the forums.
jasonwryan-Installing Arch is a measure of your literacy. Maintaining Arch is a measure of your diligence. Contributing to Arch is a measure of your competence.
Griemak-Bleeding edge, not bleeding flat. Edge denotes falls will occur from time to time. Bring your own parachute.

Offline

#2 2010-03-19 07:13:42

hbekel
Member
Registered: 2008-10-04
Posts: 311

Re: [solved] JAVA_HOME env variable for daemons

~$> pacman -Qo /etc/profile.d/jre.sh
/etc/profile.d/jre.sh is owned by jre 6u18-1

JAVA_HOME is exported by /etc/profile.d/jre.sh. Since your package should require jre already, I'd simply source that file from /etc/rc.d/funambol.

Note that /etc/profile and /etc/profile.d only get sourced if you do a proper login. Since startup scripts are not run from a root login shell, the environment is not sourced from profile.

Offline

#3 2010-03-19 07:26:19

ngoonee
Forum Fellow
From: Between Thailand and Singapore
Registered: 2009-03-17
Posts: 7,360

Re: [solved] JAVA_HOME env variable for daemons

Thanks hbekel. Thing is, java can be provided by jre OR by openjdk. Anyway, my current (hackish) solution involves a grep and a couple of sed's on /etc/profile.d/*. Looks like there's not much else that can be done. The only other java-based init script I know off is gcaldaemon, which hard-codes JAVA_HOME assuming JRE is installed.

Oh well, I suppose it IS solved. For reference, I'm using this line:-

export JAVA_HOME=$(grep -h JAVA_HOME /etc/profile.d/* | sed '/^#/d' | sed -e 's/.*JAVA_HOME=//')

Allan-Volunteer on the (topic being discussed) mailn lists. You never get the people who matters attention on the forums.
jasonwryan-Installing Arch is a measure of your literacy. Maintaining Arch is a measure of your diligence. Contributing to Arch is a measure of your competence.
Griemak-Bleeding edge, not bleeding flat. Edge denotes falls will occur from time to time. Bring your own parachute.

Offline

Board footer

Powered by FluxBB