Created
July 13, 2015 04:28
-
-
Save apisznasdin/5525f3c72a711d0c801a to your computer and use it in GitHub Desktop.
Apache rc init script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/sbin/sh | |
# | |
# Copyright 2008 Sun Microsystems, Inc. All rights reserved. | |
# Use subject to license terms. | |
# | |
#ident "@(#)apache.sh 1.6 08/04/04 SMI" | |
APACHE_HOME=/usr/apache | |
CONF_FILE=/etc/apache/httpd.conf | |
RUNDIR=/var/run/apache | |
PIDFILE=${RUNDIR}/httpd.pid | |
TOMCAT_CF=/var/apache/tomcat/conf/server.xml | |
TOMCAT55_CF=/var/apache/tomcat55/conf/server.xml | |
if [ ! -f ${CONF_FILE} ]; then | |
exit 0 | |
fi | |
if [ ! -d ${RUNDIR} ]; then | |
/usr/bin/mkdir -p -m 755 ${RUNDIR} | |
fi | |
# see if we need to start/stop tomcat also | |
CF=`egrep '^[ \t]*include[ \t]*/etc/apache/tomcat.conf' $CONF_FILE` | |
if [ -n "$CF" -a -f $TOMCAT55_CF ]; then | |
TOMCAT=yes55 | |
TC_USER=`egrep '^[ \t]*User[ \t]' $CONF_FILE | nawk '{print $2}'` | |
elif [ -n "$CF" -a -f $TOMCAT_CF ]; then | |
TOMCAT=yes | |
TC_USER=`egrep '^[ \t]*User[ \t]' $CONF_FILE | nawk '{print $2}'` | |
else | |
TOMCAT=no | |
fi | |
case "$1" in | |
start|startssl|sslstart|start-SSL) | |
/bin/rm -f ${PIDFILE} | |
cmdtext="starting" | |
if [ "x$TOMCAT" = xyes55 ]; then | |
(CATALINA_HOME=${APACHE_HOME}/tomcat55; export CATALINA_HOME; \ | |
CATALINA_BASE=/var/apache/tomcat55; export CATALINA_BASE; \ | |
JAVA_HOME=/usr/java; export JAVA_HOME; \ | |
/bin/su $TC_USER -c \ | |
"$CATALINA_HOME/bin/startup.sh") \ | |
>/dev/null 2>&1 | |
elif [ "x$TOMCAT" != xno ]; then | |
(CATALINA_HOME=${APACHE_HOME}/tomcat; export CATALINA_HOME; \ | |
CATALINA_BASE=/var/apache/tomcat; export CATALINA_BASE; \ | |
JAVA_HOME=/usr/java; export JAVA_HOME; \ | |
/bin/su $TC_USER -c \ | |
"$CATALINA_HOME/bin/startup.sh") \ | |
>/dev/null 2>&1 | |
fi | |
;; | |
restart) | |
cmdtext="restarting" | |
;; | |
stop) | |
cmdtext="stopping" | |
if [ "x$TOMCAT" = xyes55 ]; then | |
(CATALINA_HOME=${APACHE_HOME}/tomcat55; export CATALINA_HOME; \ | |
CATALINA_BASE=/var/apache/tomcat55; export CATALINA_BASE; \ | |
JAVA_HOME=/usr/java; export JAVA_HOME; \ | |
/bin/su $TC_USER -c \ | |
"$CATALINA_HOME/bin/shutdown.sh") \ | |
>/dev/null 2>&1 | |
elif [ "x$TOMCAT" != xno ]; then | |
(CATALINA_HOME=${APACHE_HOME}/tomcat; export CATALINA_HOME; \ | |
CATALINA_BASE=/var/apache/tomcat; export CATALINA_BASE; \ | |
JAVA_HOME=/usr/java; export JAVA_HOME; \ | |
/bin/su $TC_USER -c \ | |
"$CATALINA_HOME/bin/shutdown.sh") \ | |
>/dev/null 2>&1 | |
fi | |
;; | |
*) | |
echo "Usage: $0 {start|stop|restart}" | |
exit 1 | |
;; | |
esac | |
echo "httpd $cmdtext." | |
/bin/sh -c "${APACHE_HOME}/bin/apachectl $1" 2>&1 & | |
status=$? | |
if [ $status != 0 ]; then | |
echo "exit status $status" | |
exit 1 | |
fi | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment