1. Add the script glassfish below to /etc/init.d
Name of file = glassfish- e.g., glassfish-domain1
-chmod a+x /etc/init.d/glassfish-
2. To support service, the script must fulfill the below criteria:
-3 functions: start, stop, restart
-chkconfig level
3. debug script # bash -x glassfish-
4. to have glassfish start during boot (and stop during halt)
run level: 2345
start priority:64
stop priority:36
ln -s /etc/init.d/glassfish- /etc/rc0.d/K36glassfish-
ln -s /etc/init.d/glassfish- /etc/rc1.d/K36glassfish-
ln -s /etc/init.d/glassfish- /etc/rc2.d/S64glassfish-
ln -s /etc/init.d/glassfish- /etc/rc3.d/S64glassfish-
ln -s /etc/init.d/glassfish- /etc/rc4.d/S64glassfish-
ln -s /etc/init.d/glassfish- /etc/rc5.d/S64glassfish-
ln -s /etc/init.d/glassfish- /etc/rc6.d/K36glassfish-
5. reboot
Linux command to chkconfig service start on boot
#: ntsysv
ps U
service glassfish- status
service glassfish- start
************glassfish****************************
#!/bin/bash
# chkconfig: 2345 64 36
# description: GlassFish is a Java Application Server.
# processname: glassfish
# pidfile: /var/run/glassfish.pid
# filename glassfish-
# source function library
. /etc/init.d/functions
RETVAL=0
GLASSFISH_BIN="/opt/glassfish/bin"
PASSWORDPATH="/opt/glassfish/domains/dsss/config/startup-password"
GFUSER="atworld"
# Basename works with symbolic links.
NAME="$(basename $0)"
unset ISBOOT
# Trim off the Sxx/Kxx prefix
if [ "${NAME:0:1}" = "S" -o "${NAME:0:1}" = "K" ]; then
NAME="${NAME:3}"
ISBOOT="1"
fi
# Trim off the glassfish- prefix
NAME=${NAME:10}
# /etc/init.d/glassfish should never be called directly.
if [ -z $NAME ]; then
echo -n $"Cannot start Glassfish without specifying a domain."
failure
echo
exit 1
fi
start() {
echo -n $"Starting Glassfish V2 domain $NAME: "
daemon --user $GFUSER --pidfile /var/run/glassfish-$NAME.pid
"$GLASSFISH_BIN/asadmin start-domain --passwordfile $PASSWORDPATH $NAME"
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
PID=`ps U $GFUSER | grep $NAME | awk '{ print $1}'`
echo $PID > /var/run/glassfish-$NAME.pid
touch /var/lock/subsys/glassfish-$NAME
fi
echo
}
stop() {
echo -n $"Shutting down Glassfish V2 domain $NAME: "
$GLASSFISH_BIN/asadmin stop-domain $NAME
RETVAL=$?
[ $RETVAL -eq 0 ]
rm -f /var/lock/subsys/glassfish-$NAME
rm -f /var/run/glassfish-$NAME success || failure
echo
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload)
stop
start
;;
condrestart)
if [ -f /var/lock/subsys/glassfish-$NAME ]; then
stop
start
fi
;;
status)
status glassfish-$NAME
RETVAL=$?
;;
*)
echo $"Usage: $0 {start|stop|restart|condrestart|status}"
exit 1
esac
exit $RETVAL
****************************************************
References:
http://www.thelinuxblog.com/adding-a-service-on-fedora/
http://computingwithjasper.blogspot.com/2008/01/installing-glassfish-2-on-ubuntu-710.html
http://www.cyberciti.biz/faq/rhel5-update-rcd-command/
http://www.linux.com/feature/46892
http://www.linuxjournal.com/article/4445
http://www.comptechdoc.org/os/linux/startupman/linux_surcsysinit.html
http://www.vias.org/linux-knowhow/fwpx_appendix_a_03.html
http://www.cricalix.net/archives/2008/07/22/autostarting-glassfish-on-centos/
http://www.linuxhomenetworking.com/wiki/index.php/Quick_HOWTO_:_Ch07_:_The_Linux_Boot_Process
http://www.zimbra.com/forums/installation/10553-solved-sudo-sorry-you-must-have-tty-run-sudo.html
http://www.linuxmanpages.com/man5/sudoers.5.php#lbAM
http://www.yolinux.com/TUTORIALS/LinuxTutorialInitProcess.html
posted on 2009-06-10 14:37
Blog of JoJo 阅读(316)
评论(0) 编辑 收藏 所属分类:
每日一记