So, I then created the following script called weblogic and whacked it into the /etc/init.d spot:
remember to chmod 700, as I have some secret squirrel passwords in it.
It’s a bit fancy, and I attribute the fanciness to BP who works with me. You know who you are, thanks!
#!/bin/sh
#
# /etc/rc.d/init.d/weblogic
#
# A start/stop script for weblogic on Oracle Unbreakable Linux x86_64
#
# chkconfig: 2 99 1
# description: Starts and stops weblogic
## Settings and initialisation.
SERVICE="weblogic"
DESCRIPTION="weblogic and notemanager"
SETCOLOR_TITLE="echo -en \\033[0;36m"
RETVAL=0# Service defaults
WLSUSER="oracle"
RUNWLS="/bin/su ${WLSUSER} -lc"
WLSPROJ="/u01/app/oracle/Middleware/user_projects/domains/my_domain"
WLSSVR="/u01/app/oracle/Middleware/wlserver_10.3/server"
WLS_USER=weblogic
WLS_PW=**Your weblogic user password”
# Source function library.
if [ -f /etc/init.d/functions ] ; then
. /etc/init.d/functions
elif [ -f /etc/rc.d/init.d/functions ] ; then
. /etc/rc.d/init.d/functions
else
exit 1
fi# Avoid using root's TMPDIR
unset TMPDIRstart() {
echo -n $"Starting ${DESCRIPTION} services: "
echo
RETVAL=0echo ; $SETCOLOR_TITLE ; echo "weblogic:" ; $SETCOLOR_NORMAL
${RUNWLS} "export WLS_USER=$WLS_USER;export WLS_PW=$WLS_PW; ${WLSPROJ}/bin/startWebLogic.sh &2>1 &"
RETVAL_WLS=$?
# sleep 60echo ; $SETCOLOR_TITLE ; echo "weblogic node manager:" ; $SETCOLOR_NORMAL
${RUNWLS} "${WLSSVR}/bin/startNodeManager.sh &2>1 &"
RETVAL_WLSNM=$?
# sleep 60RETVAL=`expr $RETVAL_WLS + $RETVAL_WLSNM`
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/${SERVICE} || RETVAL=1return $RETVAL
}stop() {
echo -n $"Shutting down ${DESCRIPTION} services: "
echo
RETVAL=0echo ; $SETCOLOR_TITLE ; echo "weblogic:" ; $SETCOLOR_NORMAL
${RUNWLS} "${WLSPROJ}/bin/stopWebLogic.sh $WLS_USER $WLS_PW &"
RETVAL_WLS=$?kill -9 `ps -ef |grep -i "jdk Weblogic.nodemanager" |grep -v grep | awk '{print $2}'`
RETVAL=`expr $RETVAL_WLS`
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/${SERVICE}
return $RETVAL
}
status() {echo ; $SETCOLOR_TITLE ; echo "${DESCRIPTION} weblogic Status:" ; $SETCOLOR_NORMAL
ps -ef|grep startWebLogic.sh|grep -vE 'grep|ps -ef|-sh|awk|sort|uniq|ksh|su'|awk '{print $2, $9, $10, $11, $12, $13}'
echo ; $SETCOLOR_TITLE ; echo "${DESCRIPTION} weblogic node manager Status:" ; $SETCOLOR_NORMAL
ps -ef|grep startNodeManager.sh|grep -vE 'grep|ps -ef|-sh|awk|sort|uniq|ksh|su'|awk '{print $2,$9}'
}case "$1" in
start)
start
;;
status)
status
;;
stop)
stop
;;
*)
echo $"Usage: $0 {start|status}"
exit 2
esacexit $?
Despite being a little verbose, the above script is working!
[root@vsydwls01 init.d]# chkconfig weblogic --add
[root@vsydwls01 init.d]# chkconfig --level 5 weblogic on
[root@vsydwls01 init.d]# chkconfig --level 3 weblogic on
[root@vsydwls01 init.d]# chkconfig weblogic --list
weblogic 0:off 1:off 2:on 3:on 4:off 5:on 6:off
What do those level numbers mean: (thanks Wikipedia). 3 & 5 are very common choices.
Code | Information |
---|---|
0 | Halt |
1 | Single-User mode |
2 | Multi-user mode console logins only (without networking) |
3 | Multi-User mode, console logins only |
4 | Not used/User-definable |
5 | Multi-User mode, with display manager as well as console logins (X11) |
6 | Reboot |
No comments:
Post a Comment