Running startAwareIMNoGUI.sh as a server startup script

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
Post Reply
jasoncol01
Posts: 3
Joined: Mon Jul 10, 2006 3:18 pm

Running startAwareIMNoGUI.sh as a server startup script

Post by jasoncol01 »

I have a hosted dedicated Linux server (LAMP config) setup to run AwareIM.
I am able to start the AwareIM server remotely by running startAwareIMNoGUI.sh from a terminal window.
How can I run the startAwareIMNoGUI.sh script automatically when the server boots up?
I've tried adding the command to the /etc/rc.d/rc.local file but it doesn't start the AwareIM server startup (boot).

Please advise.
aware_support
Posts: 7525
Joined: Sun Apr 24, 2005 12:36 am
Contact:

Post by aware_support »

Well, it should, unless your version of Linux does not support this file and has some other means of starting the script.

Do you have any other scripts in this file that you know are working?

Which version of Linux are you using?

Please also check that the startAwareIMNoGUI.sh script has an ampersand at the end. If it does not, please add one, so that the last line in the script looks like this:

$JDK_HOME/bin/java -Xmx96m -Xms20m -cp $CLASSPATH com.bas.basserver.bsmanager.NonGUIServerMonitorCallback &
Aware IM Support Team
tpetrasek
Posts: 2
Joined: Fri May 04, 2007 3:35 pm
Location: Atlanta, GA
Contact:

Post by tpetrasek »

I am having the same difficulty with the startAwareIMNoGUI.sh script. I am able to start the AwareIM server manually. Startup via system configuration scripts fails with a path error:

/usr/local/AwareIM/bin/startAwareIMNoGUI.sh: line 14: ../JDK/bin/java: No such file or directory

After editting paths in startAwareIMNoGUI.sh and startupOptions.props with the proper full-length pathnames, I get the same error, just later in the startup process:

Process status: Tomcat: Unable to start due to the following exception java.io.IOException java.io.IOException: ../JDK/bin/java: not found

Obviously, there are dependencies on relative paths in the existing configuration. Vladimir from your support department says the bin/ subdirectory must be the pwd of the startup script. I am loathe to put "cd /path/to/AwareIM" in the top of my init scripts; its just bad practice. Ideally, a single environment variable should control the root of all paths, doing away with fragile dependencies on relative path.

Any guidance you can provide in the automatic startup of AwareIM would be appreciated.
aware_support
Posts: 7525
Joined: Sun Apr 24, 2005 12:36 am
Contact:

Post by aware_support »

I understand that you loathe putting the cd ... in your file, but can you try?

It is really very strange that you are getting the ../JDK/bin/java error. The only places that references to ../JDK/bin/java are used are:

1) The startup script itself
2) startupOptions.props file
3) If the startupOptions.props file is not found then ../JDK/bin/java is used to start java (this is hardcoded)

So the only two possible explanations I can see is:
1) You didn't change the startup script or the startupOptions.props file
2) The startupOptions.props file is not being found so the default hardcoded value is used.

Is there anything displayed on the console? Could you provide the console output?
Aware IM Support Team
tpetrasek
Posts: 2
Joined: Fri May 04, 2007 3:35 pm
Location: Atlanta, GA
Contact:

Post by tpetrasek »

By carefully watching a truss that followed child processes as well as the parent, I was able to determine that not having a $PWD of the bin directory is what causes the startupOptions.props to not be found (ergo, the Tomcat exception). On startup, the props file is searched for in the $PWD via the '.' notation. This could be leveraged by an unpriviliged user to startup AwareIM on their own terms or for other non-legitimate purposes. Some samples of relative path security problems for your leisurely perusal:

[url]http://www.iss.net/issEn/xforce/xforceS ... htype=xfdb[/url]
[url]http://nvd.nist.gov/nvd.cfm?cvename=CVE-2001-0507[/url]
[url]http://nvd.nist.gov/nvd.cfm?cvename=CVE-1999-0388[/url]
[url]http://www.securityspace.com/smysecure/search.html[/url] (enter "relative path", no quot)

The best approach to removing dependencies on relative paths is to set and use a variable that stores the root of AwareIM. (e.g. - AWAREIM_ROOT=/some/path; exec $AWAREIM_ROOT/some/executable).

Security issues aside, automatic startup works with a simple little init script wrapper I wrote. Note the use of a variable to set the path and the use of parens to prevent accidental inheritance of the $PWD by other parts of the script.

[quote]
#!/bin/sh

AWAREIM_ROOT=/usr/local/AwareIM

case "$1" in

'start')
(cd $AWAREIM_ROOT/bin; $AWAREIM_ROOT/bin/startAwareIMNoGUI.sh)
;;

'stop')
(cd $AWAREIM_ROOT/bin; $AWAREIM_ROOT/bin/serverShutter.sh)
;;

*)
echo " Usage: $0 [start|stop]"
;;

esac
[/quote]
aware_support
Posts: 7525
Joined: Sun Apr 24, 2005 12:36 am
Contact:

Post by aware_support »

Thanks for sharing this. You are right - the scripts could be a little more sophisticated.
Aware IM Support Team
Post Reply