Article
Problem:
I installed DirXML Remote Loader using the script from http://www.novell.com/coolsolutions/feature/16975.html
With this script it is not possible to see easily if the DirXML Remote Loader is started or not.
It can be done with ps -ef |grep dirxml, but that will fill up the screen with a lot of Java classes.
Solution:
I added a section to the script to make status checking possible, like every decent script should have.
Example:
This example is for a SAP DirXML driver. The variables DIRXML_HOME, DIRXML_CONF, REMOTELOADER, REMOTELOADERPASSWD and DRIVERPASSWD are probably different on your system, double check this before using the script on a production system.
# -- [ Remote loader startup and shutdown script ] --
### BEGIN INIT INFO
# Provides: novell-remoteloader
# Description: Start DirXML Remote Loader
### END INIT INFO
DIRXML_HOME="/usr/lib/dirxml"
DIRXML_CONF="/opt/novell/dirxml/configsapum.txt"
REMOTELOADER="/usr/bin/dirxml_jremote"
REMOTELOADERPASSWD=""
DRIVERPASSWD=""
PIDFILE="/var/run/remoteloader.pid"
case "$1" in
"start" )
/bin/echo -n "Setting up DirXML Remote Loader..."
cd $DIRXML_HOME
$REMOTELOADER -config $DIRXML_CONF -sp $REMOTELOADERPASSWD $DRIVERPASSWD
/bin/echo -n "Starting the DirXML Remote Loader..."
$REMOTELOADER -config $DIRXML_CONF &
sleep 1s
# This is probably not the best way to get the PID, but it certainly works. Change 8001 to whatever the local listening port is.
netstat -plant | grep LIST | grep java | grep 8001 |awk '{print $7}' | awk -F "/" '{print $1}' > $PIDFILE
echo "done"
;;
"stop" )
/bin/echo -n "Stopping the DirXML Remote Loader..."
/bin/kill `cat $PIDFILE`
rm -f $PIDFILE
/bin/echo "done"
;;
"status" )
PRG_PID=`cat $PIDFILE`
if [ "$PRG_PID" ]; then
echo "DirXML Remote Loader is running with pid $PRG_PID"
exit 0
else
echo "DirXML Remote Loader is not running"
exit 1
fi
;;
* )
/bin/echo "Usage: /etc/init.d/novell-remoteloader {start|stop|status}"
exit 1
;;
esac
exit 0Environment:
The script should work on almost every Linux version, as long as you use bash shell.
Tested on Linux 2.6.5-7.286-smp, SLES9 SP3 AMD64
Related Articles
User Comments
- Be the first to comment! To leave a comment you need to Login or Register
- 4976 reads


0