Tomcat Unix init.d Script (start,stop,status,restart,kill...)
#!/bin/bash # description: $zTomcatName Start Stop Restart # processname: $zTomcatName # chkconfig: 234 20 80 JAVA_HOME="/usr/java/default" export JAVA_HOME PATH=$JAVA_HOME/bin:$PATH export PATH CATALINA_HOME="/opt/tomcat-demo" zSystemTomcatName="tomcat.name=demo" zTomcatName="demo" zCommand="" # Source function library. . /etc/init.d/functions [ -f $START_TOMCAT ] || exit 0 [ -f $STOP_TOMCAT ] || exit 0 RETVAL=0 umask 077 start() { echo -n $"Starting $zTomcatName Java server: " sh $CATALINA_HOME/bin/startup.sh } start.jpda() { echo -n $"Starting $zTomcatName Java server: " sh $CATALINA_HOME/bin/catalina.sh jpda start } stop() { echo -n $"Shutting down $zTomcatName Java server: " sh $CATALINA_HOME/bin/shutdown.sh } version() { echo -n $"Version of $zTomcatName Java server: " sh $CATALINA_HOME/bin/version.sh } restart() { echo -n $"Restarting $zTomcatName Java server: " stop echo "" echo "" start } restart.log() { echo -n $"Restarting $zTomcatName Java server: " stop echo "" echo "" start echo "" echo "" log } status() { sh /bin/custom/zzGetStatus.sh $zSystemTomcatName } status.ps() { ps -ef --cols 2000 | grep -v grep | grep "$zSystemTomcatName" } kill() { echo "Killing tomcat." sh /bin/custom/zzKill.sh "$zSystemTomcatName" } log.tomcat() { echo "Tailing logs." tail -f $CATALINA_HOME/logs/catalina.out } log.app() { zCommand="tail -f /home/applications/$zTomcatName/log/debug" echo "$zCommand" $zCommand } log.clear() { echo "" > $CATALINA_HOME/logs/catalina.out echo "Logs cleared." } log.nginx() { zCommand="tail -f /var/log/nginx/*.demo.biskinler.com.log" echo "$zCommand" $zCommand echo "" } view() { echo "Showing logs." vim + $CATALINA_HOME/logs/catalina.out } view.nginx() { zCommand="vim + /var/log/nginx/*.demo.biskinler.com.log" echo "$zCommand" $zCommand echo "" } edit.setenv() { echo -n $"Edit $CATALINA_HOME/bin/setenv.sh" vim + $CATALINA_HOME/bin/setenv.sh echo "" } edit.services() { zCurrentFile=$0 echo -n $"Edit $zCurrentFile" vim + $zCurrentFile echo "" } edit.project-config.properties() { zCommand="vim /home/applications/$zTomcatName/conf/project-config.properties" echo "$zCommand" $zCommand } edit.catalina.properties() { echo -n $"Edit $CATALINA_HOME/bin/setenv.sh" vim + $CATALINA_HOME/conf/catalina.properties echo "" } change_directory() { zCommand="cd $CATALINA_HOME" echo "$zCommand" $zCommand zCommand="mc" echo "$zCommand" $zCommand echo "" } case "$1" in start ) start ;; start.jpda ) start.jpda ;; stop ) stop ;; restart|reload ) restart ;; restart.log ) restart.log ;; version ) version ;; status ) status ;; status.ps ) status.ps ;; log|log.tomcat ) log.tomcat ;; log.app ) log.app ;; log.clear ) log.clear ;; log.nginx ) log.nginx ;; view ) view ;; view.nginx ) view.nginx ;; kill ) kill ;; edit.services ) edit.services ;; edit.project-config.properties|edit.pp ) edit.project-config.properties ;; edit.setenv ) edit.setenv ;; edit.catalina.properties|edit.ca ) edit.catalina.properties ;; cd ) change_directory ;; *) echo $"Usage: $0 " echo $" start " echo $" start.jpda " echo $" stop " echo $" restart|reload " echo $" restart.log " echo $" version " echo $" status " echo $" status.ps " echo $" kill " echo $" log|log.tomcat " echo $" log.app " echo $" log.nginx " echo $" log.clear " echo $" view " echo $" view.nginx " echo $" edit.services " echo $" edit.project-config.properties|edit.pp " echo $" edit.setenv " echo $" edit.catalina.properties|edit.ca " echo $" cd " echo $"" exit 1 esac exit $?
Created 8 years ago by Ahmet Faruk Bişkinler
Last Updated 8 years ago by Ahmet Faruk Bişkinler