Linux RedHat init.d Scripts for Tomcat based RQM
Hi,
I would like to share my init.d script for RedHat like OS for RQM. It checks the status of the running Tomcat instance via looking for the opened server port RQM so it provides a correct running state. It could also easily adopted to other Jazz based tools.
Best Regards,
Ren
I would like to share my init.d script for RedHat like OS for RQM. It checks the status of the running Tomcat instance via looking for the opened server port RQM so it provides a correct running state. It could also easily adopted to other Jazz based tools.
Best Regards,
Ren
#!/bin/sh
# rqm
# chkconfig: 35 95 25
# Source function library
. /etc/rc.d/init.d/functions
script_result=0
start() {
RQM_START=$"Starting RQM service: "
echo -n "$RQM_START"
/opt/IBM/RQM201/server/server.startup
ret=$?
if [ $ret -eq 0 ]
then
success "$RQM_START"
else
failure "$RQM_START"
script_result=1
fi
echo
}
stop() {
echo -n $"Stopping RQM service: "
/opt/IBM/RQM201/server/server.shutdown
ret=$?
if [ $ret -eq 0 ]
then
echo_success
else
echo_failure
script_result=1
fi
echo
}
checkstate()
{
# check if rqm is running and listening on 9443
javagrep=(`netstat -nlp | grep 9443.*java`)
if [ -z $javagrep ];then
echo $"${base} is stopped"
return 3
else
pid=`netstat -nlp | grep 9443.*java | sed -e 's/ //g' | sed -e 's/^.*LISTEN\(.*\)\/java.*/\1/g'`
echo $"rqm (pid $pid) is running..."
return 0
fi
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
checkstate
script_result=$?
;;
restart)
stop
start
;;
*)
echo $"Usage: $0 {start|stop|status|restart}"
script_result=1
esac
exit $script_result
2 answers
Hi,
I would like to share my init.d script for RedHat like OS for RQM. It checks the status of the running Tomcat instance via looking for the opened server port RQM so it provides a correct running state. It could also easily adopted to other Jazz based tools.
Best Regards,
Ren
#!/bin/sh
# rqm
# chkconfig: 35 95 25
# Source function library
. /etc/rc.d/init.d/functions
script_result=0
start() {
RQM_START=$"Starting RQM service: "
echo -n "$RQM_START"
/opt/IBM/RQM201/server/server.startup
ret=$?
if [ $ret -eq 0 ]
then
success "$RQM_START"
else
failure "$RQM_START"
script_result=1
fi
echo
}
stop() {
echo -n $"Stopping RQM service: "
/opt/IBM/RQM201/server/server.shutdown
ret=$?
if [ $ret -eq 0 ]
then
echo_success
else
echo_failure
script_result=1
fi
echo
}
checkstate()
{
# check if rqm is running and listening on 9443
javagrep=(`netstat -nlp | grep 9443.*java`)
if [ -z $javagrep ];then
echo $"${base} is stopped"
return 3
else
pid=`netstat -nlp | grep 9443.*java | sed -e 's/ //g' | sed -e 's/^.*LISTEN\(.*\)\/java.*/\1/g'`
echo $"rqm (pid $pid) is running..."
return 0
fi
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
checkstate
script_result=$?
;;
restart)
stop
start
;;
*)
echo $"Usage: $0 {start|stop|status|restart}"
script_result=1
esac
exit $script_result
----------------------------------
I tried you script for RRC. The script works ok, but when I start it as a service on bootup I can not get access to RRC. root is not capable of stopping the service using the script either. I am not a Linux person at all, but my sense is there are some permissions somewhere I am not setting properly. Do you have any suggestions for how I can get this working?
Thanks
John Hetrick
For RRC you need to start an XServer when using Linux in headless mode. I will post my running RRC script in the RRC forum.
Regarding permission problems you need to set the executable flag on the script. Given that you script is located in /etc/init.d
you need to run
cd /etc/init.d
chmod +x initscriptname
chkconfig --add initscriptname
reboot
But I think it is better is to include some Linux user/admin when not shure about how permissions/init.d scripts are working. One wrong command as root user and everything can be destroyed.
Best Regards,
Ren
Regarding permission problems you need to set the executable flag on the script. Given that you script is located in /etc/init.d
you need to run
cd /etc/init.d
chmod +x initscriptname
chkconfig --add initscriptname
reboot
But I think it is better is to include some Linux user/admin when not shure about how permissions/init.d scripts are working. One wrong command as root user and everything can be destroyed.
Best Regards,
Ren