Announcement

Collapse
No announcement yet.

environment variable ignored by shell in /etc/init.d

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    environment variable ignored by shell in /etc/init.d

    Greetings!

    I've run into an odd problem. I have Java JDK installed under /opt/jdk1.6 and there is a symlink
    /opt/java -> /opt/jdk1.6

    I also have Aptivity installed with its startup script in /etc/init.d/aptivity which expects JAVA_HOME to be set up, therefore I created /etc/profile.d/java.*sh setting JAVA_HOME.

    In fact, there are two questions:

    a) JAVA_HOME in not being picked up

    b) even when I manually set "export JAVA_HOME=/opt/java", when I run /etc/init.d/aptivity, the script does not see the JAVA_HOME at all!

    Can anyone explain what is going one? Thanks in advance.

    #2
    Re: environment variable ignored by shell in /etc/init.d

    The boot scripts do not run as a logged in user so your environment has no effect. Probably you are using sudo to run it manually and the environment is not carrying over. To have that set in the init script, set it in the init script.

    Comment


      #3
      Re: environment variable ignored by shell in /etc/init.d

      Yes, that is what I had done, but I'd like to understand why it happens./etc/profile is supposed to be executed for ever user, root including, and it starts with

      if [ -d /etc/profile.d ]; then
      for i in /etc/profile.d/*.sh; do
      if [ -r $i ]; then
      . $i
      fi
      done
      unset i
      fi

      so that every user, including root, should have JAVA_HOME set.

      As to sudo, I cheat by "sudo su" :-)

      -a

      Comment


        #4
        Re: environment variable ignored by shell in /etc/init.d

        The boot scripts are not run in a login shell of any user. Only a login shell will read /etc/profile. If you want any thing, even PATH, set in an init script you must set it in that script. That is true of cron also.

        Comment

        Working...
        X