• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • FREE workshop: Preparing contractors for Autumn : Weds 29th Sep at 7.15pm. More details here.

Ubuntu: env variables and scripting issues

Collapse
X
  •  
  • Filter
  • Time
  • Show
Clear All
new posts

    Ubuntu: env variables and scripting issues

    Is there anything different about the way ubuntu deals with env variables in sctipts? I am trying to get tomcat installed and running which is something I have done a thousand times on Solaris.

    It relies on JAVA_HOME being set so...

    Code:
    JAVA_HOME=/opt/java/jdk1.6.0_14
    export JAVA_HOME
    
    echo $JAVA_HOME
    /opt/java/jdk1.6.0_14
    So I kick of the startup script and..

    Code:
    Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
    At least one of these environment variable is needed to run this program
    So a quick look at the startup script and..


    Code:
    # Make sure prerequisite environment variables are set
    if [ -z "$JAVA_HOME" -a -z "$JRE_HOME" ]; then
      # Bugzilla 37284 (reviewed).
      if $darwin; then
        if [ -d "/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home" ]; then
          export JAVA_HOME="/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home"
        fi
      else
        JAVA_PATH=`which java 2>/dev/null`
        if [ "x$JAVA_PATH" != "x" ]; then
          JAVA_PATH=`dirname $JAVA_PATH 2>/dev/null`
          JRE_HOME=`dirname $JAVA_PATH 2>/dev/null`
        fi
        if [ "x$JRE_HOME" = "x" ]; then
          # XXX: Should we try other locations?
          if [ -x /usr/bin/java ]; then
            JRE_HOME=/usr
          fi
        fi
      fi
      if [ -z "$JAVA_HOME" -a -z "$JRE_HOME" ]; then
        echo "1Neither the JAVA_HOME nor the JRE_HOME environment variable is defined"
        echo "At least one of these environment variable is needed to run this program"
        exit 1
      fi
    fi

    #2
    I haven't read this...but maybe this can help ? http://blog.datajelly.com/company/bl...on-ubuntu.html
    McCoy: "Medical men are trained in logic."
    Spock: "Trained? Judging from you, I would have guessed it was trial and error."

    Comment


      #3
      Originally posted by lilelvis2000 View Post
      I haven't read this...but maybe this can help ? http://blog.datajelly.com/company/bl...on-ubuntu.html
      That was almost what I was doing although they were going for auto startup and I was just hand cranking it.

      In the end I just hacked in the export at the top of the startup script which is not perfect but gets it working for now. Do not understand why it just drops the env variables as they are set before calling the script.

      Another entry in the hack list.

      Comment


        #4
        The only thing I can think is that tomcat script is switching to another user and thus using that account's environment instead of yours...but I could be very wrong.
        McCoy: "Medical men are trained in logic."
        Spock: "Trained? Judging from you, I would have guessed it was trial and error."

        Comment


          #5
          I think you are right. I set the JAVA_HOME as myself but have to sudo the tomcat to get it to run.

          Strangely it will not let me sudo the export though.

          I think if I let the auto startup run it then I can remove the hack I suppose.

          It is my first experience of running a lynux server after years of solaris, thought they would be the same but it is the small changes that confuse me.

          Cheers

          Comment


            #6
            This any help?

            Comment


              #7
              Why you running Tomcat as root? If you need port 80 then run Apache in front.
              Cats are evil.

              Comment


                #8
                They are completely different.

                as a test do
                >env

                and then
                >sudo env

                you'll see the difference.

                You'll need to either keep the script as it is...which IMHO isn't really a hack. Although I had thought that the current java was really done by a symbolic link...but anyway, or put the env variable into the .profile of the root user.
                McCoy: "Medical men are trained in logic."
                Spock: "Trained? Judging from you, I would have guessed it was trial and error."

                Comment


                  #9
                  Originally posted by NickFitz View Post
                  Yes, I thikn that is pretty similar to lilelvis2000's post where you set it up to start at startup and it will not have any issues with users.

                  I think I am used to running tomcat off solaris servers that have not been rebooted for 5 years.

                  Comment


                    #10
                    Originally posted by lilelvis2000 View Post
                    They are completely different.

                    as a test do
                    >env

                    and then
                    >sudo env

                    you'll see the difference.

                    You'll need to either keep the script as it is...which IMHO isn't really a hack. Although I had thought that the current java was really done by a symbolic link...but anyway, or put the env variable into the .profile of the root user.
                    Yes, that shows up the diff. Going to set up the .profile for the root. cheers

                    Comment

                    Working...
                    X