Init Script

Hi,
I manually installed tomcat5 on my server and want it to start directly after booting.

I wrote a short Init-script for that:

#!/bin/sh

BEGIN INIT INFO

Provides: tomcat

Required-Start: $network $syslog $remote_fs

Should-Start: $named $syslog $time

Required-Stop: $network $syslog

Should-Stop: $named $syslog $time

Default-Start: 3 5

Default-Stop: 0 1 2 6

Short-Description: Tomcat Servlet Container

Description: Start Tomcat to allow JAVA server pages

END INIT INFO

rc.status

. /etc/rc.status
rc_reset

Variables

Java

JAVA_HOME="/etc/alternatives/jre"
JRE_HOME="/etc/alternatives/jre"

Tomcat

CATALINA_BASE="/srv/apache-tomcat-5.5.27"
CATALINA_HOME="/srv/apache-tomcat-5.5.27"
JASPER_HOME="/srv/apache-tomcat-5.5.27"
CATALINA_TMPDIR="/srv/apache-tomcat-5.5.27/temp"

case “$1” in
start)
echo “Starting Tomcat 5.5.27”
/srv/apache-tomcat-5.5.27/bin/startup.sh
rc_status -v
;;
stop)
echo “Shutting down Tomcat 5.5.27”
/srv/apache-tomcat-5.5.27/bin/shutdown.sh
rc_status -v
;;
restart)
$0 stop
echo “Waiting 5s …”
$0 start
rc_status
;;
*)
echo “Usage: $0 {start|stop|restart}”
exit 1
esac
rc_exit

It’s located in /etc/init.d
After that I created a symbolic link to /usr/sbin/rctomcat5
Then I used insserv to activate the script and set the runlevels to 3 and 5 via YAST

Unfortunately after rebooting the system I get an error that there must be a least one java environment variable set. Where do I have to set the variable (I though I just have to set them in the script)

Can any help me find a solution

BTW: The script works fine after booting using the console

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Try exporting them instead of just setting them, perhaps. Change:

JAVA_HOME="/etc/alternatives/jre"
JRE_HOME="/etc/alternatives/jre"

to:

export JAVA_HOME="/etc/alternatives/jre"
export JRE_HOME="/etc/alternatives/jre"

Good luck.

On 03/09/2010 11:16 AM, flekschas wrote:
>
> Hi,
> I manually installed tomcat5 on my server and want it to start directly
> after booting.
>
> I wrote a short Init-script for that:
>
> #!/bin/sh
> ### BEGIN INIT INFO
> # Provides: tomcat
> # Required-Start: $network $syslog $remote_fs
> # Should-Start: $named $syslog $time
> # Required-Stop: $network $syslog
> # Should-Stop: $named $syslog $time
> # Default-Start: 3 5
> # Default-Stop: 0 1 2 6
> # Short-Description: Tomcat Servlet Container
> # Description: Start Tomcat to allow JAVA server pages
> ### END INIT INFO
>
> # rc.status
> . /etc/rc.status
> rc_reset
>
> # Variables
> # Java
> JAVA_HOME="/etc/alternatives/jre"
> JRE_HOME="/etc/alternatives/jre"
>
> # Tomcat
> CATALINA_BASE="/srv/apache-tomcat-5.5.27"
> CATALINA_HOME="/srv/apache-tomcat-5.5.27"
> JASPER_HOME="/srv/apache-tomcat-5.5.27"
> CATALINA_TMPDIR="/srv/apache-tomcat-5.5.27/temp"
>
> case “$1” in
> start)
> echo “Starting Tomcat 5.5.27”
> /srv/apache-tomcat-5.5.27/bin/startup.sh
> rc_status -v
> ;;
> stop)
> echo “Shutting down Tomcat 5.5.27”
> /srv/apache-tomcat-5.5.27/bin/shutdown.sh
> rc_status -v
> ;;
> restart)
> $0 stop
> echo “Waiting 5s …”
> $0 start
> rc_status
> ;;
> *)
> echo “Usage: $0 {start|stop|restart}”
> exit 1
> esac
> rc_exit
>
> It’s located in /etc/init.d
> After that I created a symbolic link to /usr/sbin/rctomcat5
> Then I used insserv to activate the script and set the runlevels to 3
> and 5 via YAST
>
> Unfortunately after rebooting the system I get an error that there must
> be a least one java environment variable set. Where do I have to set the
> variable (I though I just have to set them in the script)
>
> Can any help me find a solution
>
> BTW: The script works fine after booting using the console
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.12 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJLlppsAAoJEF+XTK08PnB5CzIP/i/oxHJ88e0iwXx2jqRVmRLW
o+Q7s7moMyECHoBoQwvv/K+5Bht19yCfLaaPuHyRz+PNOc1HmFglzrra1b4wTQnX
algxaIIUMu5BoJasSyUV6aK84MRX9sTjv48c2UGFqgEFO/B2vmoa0f1ZoEQdnZis
XHjtQ5pkldpyYXr9EYsKJAgrCBGXN2zCsZNDp0O9MdCyiXzowDJLgir+qvUO38FO
GcMp6ZYMIXai+lpDSfs9MRmGfBbK16Jxwhc+x3POhsT9IwfaA10DK2yZf7mPkBhx
YdBFaA8ZjaIgbqWt2OkaymPcqdez8TzcsfohCuXoZla3bA77X0LCcXpRpNxdRLD0
qYp4WkNZ5rbE2vELVmnRD8DXkkRJlqfgL3py1XXogdLSKrNr6ZCTzGPER1Pg9gE6
Fs/gKuRy1vvNnA4RNyqyGX6TmFNac7ZW8Xo74tcKPTSlSX3pe0r15i5jBANHs6iV
U7f55raSQHFSuMVEZXvjYTjdQtuC83C/SPM+lPVoq/t5gBY0eGJpbViIZyUjTBcd
s+uC56RLvMndxuw2DZxfBGZs1GaRyW3HwPNB5RVRTW/1BNHi2rve10zUmcVY9d6I
QBi/Z0Oh1rWsNdMtujGVXLdgJETB83ql7sjhYWnLfHAMbV4yflovpBtLurSs0QqV
ZLLGoEC/xcY0WW2bus4r
=YHyZ
-----END PGP SIGNATURE-----

I thought about that as well and already tested it but nothing changed. Even though the variables are exported they’re not available outside the script.
What wonders me is that I checked the init script from tomcat6 and there are no environment variables set too (or I don’t see them)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

A few things to start narrowing it down:

First, my laptop has a few other Java environment variables. These won’t
be the same paths as yours, but perhaps Tomcat likes one of them:

JAVA_BINDIR=/usr/lib64/jvm/jre/bin
JAVA_HOME=/usr/lib64/jvm/jre
JAVA_ROOT=/usr/lib64/jvm/jre

Also, with that in mind, what does the following return from your console
when you are able to load Tomcat manually after booting?

env | grep -i java

Finally for serious troubleshooting fun run the script manually as follows
and see what it shows in case something useful is returned:

bash -x /usr/sbin/rctomcat5 start

This will generate a bunch of output so be sure your scrollback buffer in
your shell is nice and high.

Good luck.

On 03/10/2010 09:06 AM, flekschas wrote:
>
> I thought about that as well and already tested it but nothing changed.
> Even though the variables are exported they’re not available outside the
> script.
> What wonders me is that I checked the init script from tomcat6 and
> there are no environment variables set too (or I don’t see them)
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.12 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJLl8w+AAoJEF+XTK08PnB5d1MQAJKtKzzGdN81ZPzDmcCt5/1C
f3lPXseW3diXTB/cvFTsUBafFpOklMz/AXTeFBYqA8AtXpfjj1poYbAhM/yfEp9L
LjWnpKeUqvyTayz2q3PghFnLV0etsgWiTZ4itIQgUULVOc7g9a5ueLkPZ5kl9GhZ
IbNxvSTMJFzCKVkAuAwJIpiBoTGF4B4OhW2RYJrKbv2eJ/xwz6H9CNyQl3+MitEQ
tG0bh5Fvhzyz/wmRIWZOns2r9Rrn+wGJMR+D2xDzr2dg4TZ7sF84BgovGVUikuO4
RQ3aQYsGwnuR/qqODLz25l2+Td60+0ydWnf2hs7M4/Vk/5zzR+YscyfeGda4mM52
qafPblDotL8TJz6T+FNy9zFPo/mgxsMIk4Am4NS2Cvr8Op+pLKQ+iU7QIZjwd/8g
29BpfqJ2BdE9SSiUOHAV3ESyJKe/vZU1s+uSZHKnwl749BD8HLO9sXfqQ0/uCTOv
oIgf8QP36rPaNNzwvgzIRf+sTKMbAtOEGIA0eupHlML3SL20QLWaRu0H5lzhDnU/
Zqsz30Yfry3FSOyGjn+BA6x7a3DLepnGHloaNbyZrMq0r9XOrhEe4JsicYsHBdsv
ZNJhIMd8xpd8d0+hMARsdclHkPw0+EBi3D8wF5vkWZe7BzirIfxNvbvk7vwQMRlf
8szDPNzsDe7Jp2LWiHVX
=cI/G
-----END PGP SIGNATURE-----

Okay :slight_smile:
Everything is fine now. It had nothing to do with the script. Another application caused an error by apache which led to this error.
Thanks for you help

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Interesting. Thanks for posting back your results.

Good luck.

On 03/10/2010 12:26 PM, flekschas wrote:
>
> Okay :slight_smile:
> Everything is fine now. It had nothing to do with the script. Another
> application caused an error by apache which led to this error.
> Thanks for you help
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.12 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJLl/XuAAoJEF+XTK08PnB5iOEQAKPlsCGuIwruZRfIWBGyPXG4
ggmvwQaOCGQKBtIa1YWfbrS5RGul/L5gLpiq4BICcvgxLY9GcdOxQ4pguiInE+Gz
J/qi5m1FlurtLhuZW0RvG2BYWKYW8b9BC1vE4azdqkMW7uh575XWo47TLeCbtY1y
EDbXzw0YDc3mwXBF3aStQjOv9G20zZavunsEWmJRqC9isHdo0FioLtCdYSuGPwrd
q+ssAXlO+6AEDdSW2wiANuvDYamz0cvA52PfL7yYhfilqliE92nH3ER3KDkk4tNb
1v51q/ZdeqP72qr2QVOHVQmG57vW6IFpmYStgPY4ZNkrR0FsnhqaSYg/qPM1zeId
wyDkkB8A+hNgd/DF3zgYLFZBfu6DI4rfTTEhc0boYOyuK3CrNQQwNkH7NmxccLaE
ajeXVvH4QHxXuBTiWN59BfUalSGOEaMS8p3P6O/TStuYnphe5ZaWSpnbZUM7FT06
NpgFAiw2MRLAy6yYcHG/PewiZyYybYXkBDPjK6hfYekvz9g+kLfwxoch68AZnok9
8X4pnPn+CicJdJCo4GM+OtY8mSGiNW8/4n1k+KfmrRQmp5nQx5om/m6LcHT3LW/m
y0jPsGZvrZxONZ2E2kC0bvphCPdi079PkjG0XmlqlQGN/jtzMIIQaJhBu++LeEcX
97pqC8L6zfroVpOfNjSO
=CPJU
-----END PGP SIGNATURE-----