|
Novell /
IDM init.d Control ScriptsHaving installed IDM a couple times, I am still surprised Novell hasn't created standard init.d control scripts to startup IDM during server boot. To be far to Novell, neither MySQL and JBoss have standard control scripts! Each say this is because of the complexity of the product, but I claim that this is bullshit! As such I have created a few scripts that take care of this problem and give you a nice STANDARD interface to stop, start, restart and check the status of these services. All of these scripts were created on SLES10 (SuSE Linux Enterprise Server 10) and assume that the IDM installation was placed in the default location (/opt/novell/idm) Once these scripts are on the server (and tweaked to your specific installation) run: machine:~ # chkconfig novell-idm 35
/etc/init.d/novell-idm
#!/usr/bin/env bash
##############################################################################
# #
# /etc/init.d/novell-idm #
# and its symbolic link #
# /usr/sbin/rcnovell-idm #
# #
# Author: Bob Brandt (projects@brandt.ie) #
# #
# This init.d script is used to control the Novell IDM MySQL and JBoss #
# Service and is based on the standard SuSE init.d scripts. #
# This is the main script that is used to control the other init.d scripts #
# during boot. It ensures that the services are started and stopped in the #
# correct order. #
# #
##############################################################################
#
### BEGIN INIT INFO
# Provides: novell-idm
# Required-Start: $network
# Required-Stop:
# Default-Start: 3 5
# Default-Stop: 0 1 6
# Description: Start Novell IDM MySQL and JBoss Service
### END INIT INFO
# First reset status of this service
. /etc/rc.status
rc_reset
# Return values acc. to LSB for all commands but status:
# 0 - success
# 1 - generic or unspecified error
# 2 - invalid or excess argument(s)
# 3 - unimplemented feature (e.g. "reload")
# 4 - insufficient privilege
# 5 - program is not installed
# 6 - program is not configured
# 7 - program is not running
# Set default options
NOVL_MYSQL_START_SCRIPT=${NOVL_MYSQL_START_SCRIPT:="/etc/init.d/novell-mysql"}
NOVL_JBOSS_START_SCRIPT=${NOVL_JBOSS_START_SCRIPT:="/etc/init.d/novell-jboss"}
export NOVL_MYSQL_START_SCRIPT
export NOVL_JBOSS_START_SCRIPT
startdelay="1s"
# Check for installation errors
if [ ! -x ${NOVL_MYSQL_START_SCRIPT} ]; then
echo -n "Novell MySQL Start Script, ${NOVL_MYSQL_START_SCRIPT} does not exist."
rc_status -s
exit 6
fi
if [ ! -x ${NOVL_JBOSS_START_SCRIPT} ]; then
echo -n "Novell JBoss Start Script, ${NOVL_JBOSS_START_SCRIPT} does not exist."
rc_status -s
exit 6
fi
# Check for installation errors
if [ ! -h "/usr/sbin/rcnovell-idm" ]; then
ln -s "/etc/init.d/novell-idm" "/usr/sbin/rcnovell-idm"
fi
case "$1" in
start)
echo "Starting Novell IDM Applications"
$NOVL_MYSQL_START_SCRIPT start && sleep $startdelay && $NOVL_JBOSS_START_SCRIPT start $2
rc_status
;;
stop)
echo "Stopping Novell IDM Applications"
$NOVL_JBOSS_START_SCRIPT stop $2 && $NOVL_MYSQL_START_SCRIPT stop
rc_status
;;
restart)
$0 stop $2
sleep $startdelay
$0 start $2
rc_status
;;
status)
echo "Checking for Novell IDM Applications"
$NOVL_JBOSS_START_SCRIPT status $2 && $NOVL_MYSQL_START_SCRIPT status
rc_status
;;
* ) echo "Usage: $0 {start|stop|status|restart} [debug|nodebug]" && exit 1 ;;
esac
rc_exit
/etc/init.d/novell-mysql
#!/usr/bin/env bash
##############################################################################
# #
# /etc/init.d/novell-mysql #
# and its symbolic link #
# /usr/sbin/rcnovell-mysql #
# #
# Author: Bob Brandt (projects@brandt.ie) #
# #
# This init.d script is used to control the Novell IDM MySQL Service and is #
# based on the standard SuSE init.d scripts. #
# #
##############################################################################
#
### BEGIN INIT INFO
# Provides: novell-mysql
# Required-Start: $network
# Required-Stop:
# Default-Start: 3 5
# Default-Stop: 0 1 6
# Description: Start Novell IDM MySQL Service
### END INIT INFO
# First reset status of this service
. /etc/rc.status
rc_reset
# Return values acc. to LSB for all commands but status:
# 0 - success
# 1 - generic or unspecified error
# 2 - invalid or excess argument(s)
# 3 - unimplemented feature (e.g. "reload")
# 4 - insufficient privilege
# 5 - program is not installed
# 6 - program is not configured
# 7 - program is not running
# Set default options
NOVL_MYSQL_BASE_FOLDER=${NOVL_MYSQL_BASE_FOLDER:="/opt/novell/idm/mysql"}
NOVL_MYSQL_BINARY=${NOVL_MYSQL_BINARY:="${NOVL_MYSQL_BASE_FOLDER}/bin/mysqld_safe"}
NOVL_MYSQLADMIN_BINARY=${NOVL_MYSQLADMIN_BINARY:="${NOVL_MYSQL_BASE_FOLDER}/bin/mysqladmin"}
NOVL_MYSQL_MY_CNF_FILE=${NOVL_MYSQL_MY_CNF_FILE:="${NOVL_MYSQL_BASE_FOLDER}/my.cnf"}
NOVL_MYSQL_USERNAME=${NOVL_MYSQL_USERNAME:="mysql"}
export NOVL_MYSQL_BASE_FOLDER
export NOVL_MYSQL_BINARY
export NOVL_MYSQLADMIN_BINARY
export NOVL_MYSQL_MY_CNF_FILE
export NOVL_MYSQL_USERNAME
# Check for installation errors
if [ ! -d ${NOVL_MYSQL_BASE_FOLDER} ]; then
echo -n "Novell MySQL Directory, ${NOVL_MYSQL_BASE_FOLDER} does not exist."
rc_status -s
exit 6
fi
if [ ! -f ${NOVL_MYSQL_BINARY} ]; then
echo -n "Novell MySQL binary file, ${NOVL_MYSQL_BINARY} does not exist."
rc_status -s
exit 6
fi
if ! id $NOVL_MYSQL_USERNAME > /dev/null 2>&1
then
echo -n "The ${NOVL_MYSQL_USERNAME} user does not exist."
rc_status -s
exit 6
fi
# If the Symbolic link is not present, create it.
if [ ! -h "/usr/sbin/rcnovell-mysql" ]; then
ln -s "/etc/init.d/novell-mysql" "/usr/sbin/rcnovell-mysql"
fi
case "$1" in
start)
echo -n "Starting Novell MySQL Application"
$0 status > /dev/null 2>&1 || $NOVL_MYSQL_BASE_FOLDER/start-mysql.sh start
rc_status -v
;;
stop)
echo -n "Stopping Novell MySQL Application"
$0 status > /dev/null 2>&1 && $NOVL_MYSQL_BASE_FOLDER/stop-mysql.sh stop
rc_status -v
;;
restart)
$0 stop
sleep 1s
$0 start
rc_status
;;
status)
echo -n "Checking for Novell MySQL Application"
checkproc "$NOVL_MYSQL_BINARY"
rc_status -v
;;
*) echo "Usage: $0 {start|stop|status|restart}" && exit 1 ;;
esac
rc_exit
/etc/init.d/novell-jboss
#!/usr/bin/env bash
##############################################################################
# #
# /etc/init.d/novell-jboss #
# and its symbolic link #
# /usr/sbin/rcnovell-jboss #
# #
# Author: Bob Brandt (projects@brandt.ie) #
# #
# This init.d script is used to control the Novell IDM JBoss Service and is #
# based on the standard SuSE init.d scripts. #
# #
##############################################################################
#
### BEGIN INIT INFO
# Provides: novell-jboss
# Required-Start: $network $novell-mysql
# Required-Stop:
# Default-Start: 3 5
# Default-Stop: 0 1 6
# Description: Start Novell IDM JBoss Service
### END INIT INFO
# First reset status of this service
. /etc/rc.status
rc_reset
# Return values acc. to LSB for all commands but status:
# 0 - success
# 1 - generic or unspecified error
# 2 - invalid or excess argument(s)
# 3 - unimplemented feature (e.g. "reload")
# 4 - insufficient privilege
# 5 - program is not installed
# 6 - program is not configured
# 7 - program is not running
# Set default options
NOVL_JAVA_HOME=${NOVL_JAVA_HOME:="/opt/novell/idm/jre"}
NOVL_IDM_BASE_FOLDER=${NOVL_IDM_BASE_FOLDER:="/opt/novell/idm"}
NOVL_JBOSS_BASE_FOLDER=${NOVL_JBOSS_BASE_FOLDER:="/opt/novell/idm/jboss"}
NOVL_APPLICATION_NAME=${NOVL_APPLICATION_NAME:="IDMProv"}
NOVL_JBOSS_WFLOW_ENGINE=${NOVL_JBOSS_WFLOW_ENGINE:=""}
export NOVL_JAVA_HOME
export NOVL_JBOSS_BASE_FOLDER
export NOVL_APPLICATION_NAME
export NOVL_JBOSS_WFLOW_ENGINE
# Check for installation errors
if [ ! -d ${NOVL_JAVA_HOME} ]; then
rc_status -s
exit 6
fi
if [ ! -d ${NOVL_IDM_BASE_FOLDER} ]; then
echo -n "Novell IDM Directory, ${NOVL_IDM_BASE_FOLDER} does not exist."
rc_status -s
exit 6
fi
if [ ! -d ${NOVL_JBOSS_BASE_FOLDER} ]; then
echo -n "Novell JBoss Directory, ${NOVL_JBOSS_BASE_FOLDER} does not exist."
rc_status -s
exit 6
fi
if [ ! -d ${NOVL_JBOSS_BASE_FOLDER}/server/${NOVL_APPLICATION_NAME} ]; then
echo -n "Novell JBoss Application Directory, ${NOVL_APPLICATION_NAME} does not exist."
rc_status -s
exit 6
fi
# If the Symbolic link is not present, create it.
if [ ! -h "/usr/sbin/rcnovell-jboss" ]; then
ln -s "/etc/init.d/novell-jboss" "/usr/sbin/rcnovell-jboss"
fi
case "$1" in
start)
# Although, the JBoss application is not fully started until the output
# says "Stared in xxs:xxxms" we cheat and just say that as long as the
# script returns a success return code the application is started
# successfully.
echo -n "Starting Novell JBoss Application (${NOVL_APPLICATION_NAME})"
$0 status > /dev/null 2>&1 || $NOVL_IDM_BASE_FOLDER/control-jboss.sh start $2
rc_status -v
;;
stop)
# After issuing the stop command to the Java VM, we should wait for the
# output to say "Halted VM", however we cheat and loop once every second
# (for 60 seconds) and check to see if the Java VM is still running. If
# the shutdown process takes longer than 60 seconds, we forcefully kill
# the Java Applications (being careful not to kill any other Java Apps.
echo -n "Stopping Novell JBoss Application (${NOVL_APPLICATION_NAME})"
if $0 status > /dev/null 2>&1
then
$NOVL_IDM_BASE_FOLDER/control-jboss.sh stop $2
# Wait until the application is actually stopped or 60 seconds has passed.
value="true"
declare -i loop=0
while [ "$value" = "true" ];
do
sleep 1
if ! $0 status > /dev/null || [ $((++loop)) -gt 60 ]
then
value="false"
fi
done
# Get the specific PIDs for our applications
javapid=`ps -eo pid,args | grep "$NOVL_JAVA_HOME/bin/java -Dprogram.name=run.sh" | grep -v "grep" | cut -f1 -d" " | tail -n 1`
runshpid=`ps -eo pid,args | grep "$NOVL_JBOSS_BASE_FOLDER/bin/run.sh -c $NOVL_APPLICATION_NAME" | grep -v "grep" | cut -f1 -d" " | tail -n 1`
if [ -n "$javapid" ]; then
kill -9 $javapid > /dev/null 2>&1
kill -9 $runshpid > /dev/null 2>&1
fi
fi
rc_status -v
;;
force-restart)
$0 stop $2
$0 start $2
rc_status
;;
status)
echo -n "Checking for Novell JBoss Application (${NOVL_APPLICATION_NAME})"
checkproc "$NOVL_JBOSS_BASE_FOLDER/bin/run.sh"
rc_status -v
;;
*) echo "Usage: $0 {start|stop|status|force-restart} [debug|nodebug]" && exit 1 ;;
esac
rc_exit
/opt/novell/idm/mysql/start-mysql.sh
#!/usr/bin/env bash
##############################################################################
# #
# start-mysql.sh (projects@brandt.ie) #
# #
# This script is rewrite of the original start-mysql.sh script that came #
# with mysql. #
# #
# I wrote this script because the default script I was faced with had #
# strange errors. However I will admit that these errors seemed to be cause #
# by cut/paste problems. #
# I also modified the script to use environment variables. And also to #
# return codes based on successful starts. #
# #
##############################################################################
NOVL_MYSQL_BASE_FOLDER=${NOVL_MYSQL_BASE_FOLDER:="/opt/novell/idm/mysql"}
NOVL_MYSQL_BINARY=${NOVL_MYSQL_BINARY:="${NOVL_MYSQL_BASE_FOLDER}/bin/mysqld_safe"}
NOVL_MYSQL_USERNAME=${NOVL_MYSQL_USERNAME:="mysql"}
NOVL_MYSQL_MY_CNF_FILE=${NOVL_MYSQL_MY_CNF_FILE:="${NOVL_MYSQL_BASE_FOLDER}/my.cnf"}
export NOVL_MYSQL_MY_CNF_FILE
export NOVL_MYSQL_BASE_FOLDER
export NOVL_MYSQL_BINARY
export NOVL_MYSQL_USERNAME
cd $NOVL_MYSQL_BASE_FOLDER
$NOVL_MYSQL_BINARY --defaults-file=$NOVL_MYSQL_MY_CNF_FILE --user=$NOVL_MYSQL_USERNAME > "$NOVL_MYSQL_BASE_FOLDER/mysql.log" 2>&1 &
sleep 2s
# I think this is very sloppy and that there is a much better way of doing this
# (perhaps with a debugPipe function?!), however this is not my start script!
ready=`grep "Aborting" "$NOVL_MYSQL_BASE_FOLDER/mysql.log"`
if [ $? -eq 0 ]; then
echo "Unable to start MySQL server, see $NOVL_MYSQL_BASE_FOLDER/mysql.log." > "$NOVL_MYSQL_BASE_FOLDER/mysql_not_running"
exit 1
fi
if [ -f "$NOVL_MYSQL_BASE_FOLDER/mysql_not_running" ]; then
rm "$NOVL_MYSQL_BASE_FOLDER/mysql_not_running"
fi
exit 0
/opt/novell/idm/mysql/stop-mysql.sh
#!/usr/bin/env bash
##############################################################################
# #
# stop-mysql.sh (projects@brandt.ie) #
# #
# This script is rewrite of the original stop-mysql.sh script that came with #
# mysql. #
# #
# I wrote this script because the default script I was faced with had #
# strange errors. However I will admit that these errors seemed to be cause #
# by cut/paste problems. #
# I also modified the script to use environment variables. And also to #
# return codes based on successful stops. #
# One last modification was to remove all the username/password crap. This #
# script is meant to be automated! If the local admin needs to run the #
# mysqladmin command manually, then he can run it manually! #
# #
##############################################################################
NOVL_MYSQL_BASE_FOLDER=${NOVL_MYSQL_BASE_FOLDER:="/opt/novell/idm/mysql"}
NOVL_MYSQLADMIN_BINARY=${NOVL_MYSQLADMIN_BINARY:="${NOVL_MYSQL_BASE_FOLDER}/bin/mysqladmin"}
NOVL_MYSQL_MY_CNF_FILE=${NOVL_MYSQL_MY_CNF_FILE:="${NOVL_MYSQL_BASE_FOLDER}/my.cnf"}
export NOVL_MYSQL_MY_CNF_FILE
export NOVL_MYSQL_BASE_FOLDER
export NOVL_MYSQLADMIN_BINARY
# Just be sure to safeguard the Root Password!
"$NOVL_MYSQLADMIN_BINARY" --defaults-file=$NOVL_MYSQL_MY_CNF_FILE --user=root --password=RootPassword shutdown
exit $?
/opt/novell/idm/control-jboss.sh
#!/usr/bin/env bash
##############################################################################
# #
# control-jboss.sh (projects@brandt.ie) #
# #
# This script is a front end wrapper for the standard JBoss control scripts. #
# #
# This script was created to fix two problems: #
# 1. That there is no way standard way to automatically start JBoss on boot. #
# 2. That when you do start JBoss, it vomits debug code at you. #
# #
##############################################################################
NOVL_IDM_BASE_FOLDER=${NOVL_IDM_BASE_FOLDER:-"/opt/novell/idm"}
NOVL_JBOSS_DEBUG_LOG=${NOVL_JBOSS_DEBUG_LOG:-"/var/log/jboss"}
NOVL_JAVA_HOME=${NOVL_JAVA_HOME:-"/opt/novell/idm/jre"}
# If the second parameter is "debug" then force debug, if anything else, force
# debug off.
if [ "$2" = "debug" ]; then
DEBUG="true"
elif [ -n "$2" ]; then
DEBUG="false"
else
DEBUG=${DEBUG:-"false"}
fi
# Export Variables
export DEBUG
export NOVL_IDM_BASE_FOLDER
export NOVL_JBOSS_DEBUG_LOG
# I grabbed this little bit of code from "IEs4Linux" by http://tatanka.com.br/ies4linux
# and modified it for my purposes.
debugPipe() {
while read line;
do
[ "$DEBUG" = "true" ] && echo $line
echo $line >> $NOVL_JBOSS_DEBUG_LOG
# These next lines are part of future enhancements
# if echo $line | grep " Started in "
# then
# echo "Signal that JBoss has started successfully!"
# fi
# if echo $line | grep "Halted VM"
# then
# echo "Signal that JBoss has stopped successfully!"
# fi
done
}
case "$1" in
"start" ) ($NOVL_IDM_BASE_FOLDER/start-jboss.sh 2>&1 | debugPipe) & ;;
"stop" ) ($NOVL_IDM_BASE_FOLDER/stop-jboss.sh 2>&1 | debugPipe) & ;;
* ) echo "Usage: $0 {start|stop} [debug|nodebug]" && exit 1 ;;
esac
exit $?
/opt/novell/idm/start-jboss.sh
#!/usr/bin/env bash
##############################################################################
# #
# start-jboss.sh (projects@brandt.ie) #
# #
# This script is slight rewrite of the original start-jboss.sh script that #
# came with jboss. #
# #
# I wrote this script because the default script I was faced with had #
# strange errors. However I will admit that these errors seemed to be cause #
# by cut/paste problems. #
# #
##############################################################################
NOVL_JAVA_HOME=${NOVL_JAVA_HOME:-"/opt/novell/idm/jre"}
JAVA_HOME=$NOVL_JAVA_HOME
NOVL_JBOSS_BASE_FOLDER=${NOVL_JBOSS_BASE_FOLDER:-"/opt/novell/idm/jboss"}
NOVL_APPLICATION_NAME=${NOVL_APPLICATION_NAME:-"IDMProv"}
NOVL_JBOSS_WFLOW_ENGINE=${NOVL_JBOSS_WFLOW_ENGINE:-""}
export NOVL_JAVA_HOME
export JAVA_HOME
export NOVL_JBOSS_BASE_FOLDER
export NOVL_APPLICATION_NAME
export NOVL_JBOSS_WFLOW_ENGINE
# The heap size values here have been optimized for your system.
# In order to use these settings, you need to uncomment the setting
# of JAVA_OPTS.
#
# If you specified it, we have also added a setting for your cluster,
# "workflow engine id".
#
# Make sure that our JRE is picked up first.
PATH="${NOVL_JAVA_HOME}/bin:$PATH"
export PATH
JAVA_OPTS="-server -Xms256M -Xmx256M -XX:MaxPermSize=128m ${NOVL_JBOSS_WFLOW_ENGINE}"
export JAVA_OPTS
exec "${NOVL_JBOSS_BASE_FOLDER}/bin/run.sh" -c $NOVL_APPLICATION_NAME -b 0.0.0.0
exit $?
/opt/novell/idm/stop-jboss.sh
#!/usr/bin/env bash
##############################################################################
# #
# stop-jboss.sh (projects@brandt.ie) #
# #
# This script is slight rewrite of the original stop-jboss.sh script that #
# came with jboss. #
# #
# I wrote this script because the default script I was faced with had #
# strange errors. However I will admit that these errors seemed to be cause #
# by cut/paste problems. #
# #
##############################################################################
NOVL_JBOSS_BASE_FOLDER=${NOVL_JBOSS_BASE_FOLDER:-"/opt/novell/idm/jboss"}
NOVL_JAVA_HOME=${NOVL_JAVA_HOME:-"/opt/novell/idm/jre"}
JAVA_HOME=$NOVL_JAVA_HOME
export JAVA_HOME
export NOVL_JBOSS_BASE_FOLDER
export NOVL_JAVA_HOME
exec $NOVL_JBOSS_BASE_FOLDER/bin/shutdown.sh -S
exit $?
/etc/logrotate.d/jboss (Change as desired)
/var/log/jboss.log {
compress
dateext
daily
rotate 7
size 1M
notifempty
missingok
copytruncate
}
References: |