开发者

How do I set environment variables for system users in Ubuntu?

I have created a system user for my glassfishv3 installation tha开发者_如何学Ct has no interactive shell, so no environment variables are set on this user when glassfish is started through asadmin.

I have tried to copy in the environment by using the following commands in my init script:

jhv=$(grep JAVA_HOME /etc/environment)
$jhv
export JAVA_HOME    
sudo -u glassfish -E $glassfishpath/asadmin start-domain domain1

Inside of asadmin I echo $JAVA_HOME which prints JAVA_HOME correctly.

Once glassfish starts up, I launch a web service with a single method that prints the environment key value pairs. JAVA_HOME is not among them. This causes a problem with any script executed by glassfish that requires JAVA_HOME.

So how do I set JAVA_HOME on a system user/glassfish environment so it persists once the java container is launched?


Normally, the solution woulbe be to add the -E flag to the sudo command. This flag tells sudo to maintain the current user's environment variables when dropping down into root access.

It looks like you are already using this flag though so I don't know what the problem is. It could be that the flag is failing silently in your script and you are not being notified. Have you tried running the script's command manual in a shell? What is the result/output?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜