[Jboss-cvs] JBossAS SVN: r57105 - branches/Branch_4_0/server/src/bin
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sat Sep 23 10:09:29 EDT 2006
Author: dimitris at jboss.org
Date: 2006-09-23 10:09:27 -0400 (Sat, 23 Sep 2006)
New Revision: 57105
Modified:
branches/Branch_4_0/server/src/bin/jboss_init_hpux.sh
Log:
JBAS-3641 - Updated bin/jboss_init_hpux.sh script
Modified: branches/Branch_4_0/server/src/bin/jboss_init_hpux.sh
===================================================================
--- branches/Branch_4_0/server/src/bin/jboss_init_hpux.sh 2006-09-23 14:08:15 UTC (rev 57104)
+++ branches/Branch_4_0/server/src/bin/jboss_init_hpux.sh 2006-09-23 14:09:27 UTC (rev 57105)
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# $Id:$
+# $Id$
#
# JBoss Control Script for HP-UX
#
@@ -112,6 +112,36 @@
read isJBossRunningPid junk
}
+#USAGE: isUserOK
+# prints any problems on standard error and returns with a non-zero status
+# returns a 0 status if all is OK
+isUserOK()
+{
+ # check if the user exists
+ id ${JBOSS_USER[i]} >/dev/null 2>&1
+ if (($?!=0)); then
+ echo "ERROR: The user ${JBOSS_USER[i]} does not exist." 1>&2
+ return 1
+ fi
+
+ # check if the user has write permission on the jboss instance directory
+ su ${JBOSS_USER[i]} -c "test -w ${JBOSS_HOME[i]}/server/${SERVER_NAME[i]}" >/dev/null 2>&1
+ if (($?!=0)); then
+ echo "ERROR: The user ${JBOSS_USER[i]} does not have write access to ${JBOSS_HOME[i]}/server/${SERVER_NAME[i]}" 1>&2
+ return 2
+ fi
+
+ # user must have JAVA_HOME defined
+ su - ${JBOSS_USER[i]} -c 'whence java || [[ -d $JAVA_HOME ]]' >/dev/null 2>&1
+ if (($?!=0)); then
+ echo "ERROR: The user \"${JBOSS_USER[i]}\" does not have \$JAVA_HOME defined; either define \$JAVA_HOME for this user or ensure that a path to \"java\" exists." 1>&2
+ return 3
+ fi
+
+ # user looks good so far
+ return 0
+}
+
# Usage: startJBoss <index>
startJBoss()
{
@@ -119,30 +149,39 @@
(( ${JBOSS_START[i]} != 1 )) && return 0
+ # make sure the console log exists with appropriate permissions for JBOSS_USER[i]
if [[ ! -d ${JBOSS_CONSOLE[i]%/*} ]]; then
mkdir -p ${JBOSS_CONSOLE[i]%/*}
chmod 0755 ${JBOSS_CONSOLE[i]%/*}
chown ${JBOSS_USER[i]} ${JBOSS_CONSOLE[i]%/*}
fi
+ # do some basic error checking
if [[ ! -d ${JBOSS_HOME[i]} ]]; then
- echo "ERROR: JBOSS_HOME[i] is not a valid directory : ${JBOSS_HOME[i]}" 1>&2
+ echo "ERROR: JBOSS_HOME[$i] is not a valid directory : ${JBOSS_HOME[i]}" 1>&2
return 1
fi
+ isUserOK || return 2
+
isJBossRunning ${JBOSS_USER[i]} ${JBOSS_HOME[i]} ${SERVER_NAME[i]}
if (( $? == 0 )); then
echo "JBoss AS is already running for user ${JBOSS_USER[i]} at ${JBOSS_HOME[i]} with instance ${SERVER_NAME[i]}" 1>&2
- return 1
+ return 3
fi
- # keeps last version of the console log around
+ # keep last version of the console log around
[[ -f ${JBOSS_CONSOLE[i]} ]] && mv ${JBOSS_CONSOLE[i]} ${JBOSS_CONSOLE[i]}.old
# JBoss is not running, start it up
CMD_START="${JBOSS_HOME[i]}/bin/run.sh -c ${SERVER_NAME[i]}"
- nohup su - ${JBOSS_USER[i]} -c "$CMD_START" >${JBOSS_CONSOLE[i]} 2>&1 &
- echo "Starting JBoss AS for user ${JBOSS_USER[i]} at ${JBOSS_HOME[i]} with instance ${SERVER_NAME[i]}"
+ nohup su - ${JBOSS_USER[i]} -c "sh $CMD_START" >${JBOSS_CONSOLE[i]} 2>&1 &
+ echo "Starting JBoss AS for user ${JBOSS_USER[i]} at ${JBOSS_HOME[i]} with instance ${SERVER_NAME[i]}."
+
+ # wait a few seconds then check if it started ok
+ #isJBossRunning ${JBOSS_USER[i]} ${JBOSS_HOME[i]} ${SERVER_NAME[i]} || sleep 2 ||
+ #isJBossRunning ${JBOSS_USER[i]} ${JBOSS_HOME[i]} ${SERVER_NAME[i]} || sleep 3 ||
+ #echo "... server not started yet. Check the log files for errors"
}
# Usage: stopJBoss <index>
@@ -157,16 +196,11 @@
# SIGTERM does a gracefull shutdown like ^C
echo "Stopping JBoss AS PID $isJBossRunningPid for user ${JBOSS_USER[i]} at ${JBOSS_HOME[i]} with instance ${SERVER_NAME[i]}"
kill -s SIGTERM $isJBossRunningPid
-}
-stopWaitJBoss()
-{
- typeset -i i=$1
- stopJBoss $*
# wait for up to 30 seconds for the process to terminate gracefully
- isJBossRunning ${JBOSS_USER[i]} ${JBOSS_HOME[i]} ${SERVER_NAME[i]} && printf "please wait " && sleep 10 &&
+ isJBossRunning ${JBOSS_USER[i]} ${JBOSS_HOME[i]} ${SERVER_NAME[i]} && printf "please wait " && sleep 5 &&
isJBossRunning ${JBOSS_USER[i]} ${JBOSS_HOME[i]} ${SERVER_NAME[i]} && printf "." && sleep 10 &&
- isJBossRunning ${JBOSS_USER[i]} ${JBOSS_HOME[i]} ${SERVER_NAME[i]} && printf "." && sleep 10 &&
+ isJBossRunning ${JBOSS_USER[i]} ${JBOSS_HOME[i]} ${SERVER_NAME[i]} && printf "." && sleep 15 &&
isJBossRunning ${JBOSS_USER[i]} ${JBOSS_HOME[i]} ${SERVER_NAME[i]} &&
echo "NOT Terminated! Wait a moment then check to see if the process has shut down gracefully, or terminate it now with\n \"kill -s SIGKILL $isJBossRunningPid\"" >&2
}
@@ -211,11 +245,8 @@
stop)
doAll stopJBoss
;;
- stopwait)
- doAll stopWaitJBoss
- ;;
restart)
- $0 stopwait
+ $0 stop
$0 start
;;
*)
More information about the jboss-cvs-commits
mailing list