[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 #!/bin/bash -e 2 ### BEGIN INIT INFO 3 # Provides: apache2se 4 # Required-Start: $local_fs $remote_fs $network $syslog 5 # Required-Stop: $local_fs $remote_fs $network $syslog 6 # Default-Start: 2 3 4 5 7 # Default-Stop: 0 1 6 8 # Short-Description: Start/stop apache2 web server 9 ### END INIT INFO 10 11 # 12 # apache2 This init.d script is used to start apache2. 13 # It basically just calls apache2ctl. 14 15 ENV="env -i LANG=C PATH=/usr/local/bin:/usr/bin:/bin" 16 17 #[ `ls -1 /etc/apache2/sites-enabled/ | wc -l | sed -e 's/ *//;'` -eq 0 ] && \ 18 #echo "You haven't enabled any sites yet, so I'm not starting apache2." && \ 19 #echo "To add and enable a host, use addhost and enhost." && exit 0 20 21 #edit /etc/default/apache2 to change this. 22 NO_START=0 23 24 set -e 25 if [ -x /usr/sbin/apache2 ] ; then 26 HAVE_APACHE2=1 27 else 28 exit 0 29 fi 30 31 test -f /etc/default/rcS && . /etc/default/rcS 32 test -f /etc/default/apache2se && . /etc/default/apache2se 33 if [ "$NO_START" != "0" -a "$1" != "stop" ]; then 34 [ "$VERBOSE" != no ] && echo "Not starting apache2 - edit /etc/default/apache2se and change NO_START to be 0."; 35 exit 0; 36 fi 37 38 APACHE2="$ENV /usr/sbin/apache2" 39 APACHE2CTL="$ENV /usr/sbin/apache2ctlse" 40 41 apache_stop() { 42 PID="" 43 PIDFILE="" 44 # let's try to find the pid file 45 # apache2 allows more than PidFile entry in the config but only 46 # the last found in the config is used 47 for PFILE in `grep ^PidFile /etc/apache2se/* -r | awk '{print $2}'`; do 48 PIDFILE="$PFILE" 49 if [ -e "$PIDFILE" ]; then 50 PID=`cat $PIDFILE` 51 fi 52 done 53 54 if `APACHE_RUN_USER=www-se3 APACHE_RUN_GROUP=www-se3 apache2 -t > /dev/null 2>&1`; then 55 # if the config is ok than we just stop normaly 56 if [ -e "$PIDFILE" ] 57 then 58 PID=`cat $PIDFILE` 59 60 $APACHE2 -f /etc/apache2se/apache2.conf -k stop 61 62 CNT=0 63 while [ 1 ] 64 do 65 CNT=$(expr $CNT + 1) 66 67 [ ! -d /proc/$PID ] && break 68 69 if [ $CNT -gt 60 ] 70 then 71 echo " ... failed!" 72 echo "Apache2se failed to honor the stop command, please investigate the situation by hand." 73 exit 1 74 fi 75 76 sleep 1 77 done 78 else 79 echo -n " ... no pidfile found! not running?" 80 fi 81 82 else 83 # if we are here something is broken and we need to try 84 # to exit as nice and clean as possible 85 86 # if pidof is null for some reasons the script exits automagically 87 # classified as good/unknown feature 88 PIDS=`pidof apache2se` || true 89 90 REALPID=0 91 # if there is a pid we need to verify that belongs to apache2 92 # for real 93 for i in $PIDS; do 94 if [ "$i" = "$PID" ]; then 95 # in this case the pid stored in the 96 # pidfile matches one of the pidof apache 97 # so a simple kill will make it 98 REALPID=1 99 fi 100 done 101 102 if [ $REALPID = 1 ]; then 103 # in this case it is everything nice and dandy 104 # and we kill apache2 105 kill $PID 106 else 107 # this is the worst situation... just kill all of them 108 #for i in $PIDS; do 109 # kill $i 110 #done 111 # Except, we can't do that, because it's very, very bad 112 echo " ... failed!" 113 echo "You may still have some apache2 processes running. There are" 114 echo "processes named 'apache2' which do not match your pid file," 115 echo "and in the name of safety, we've left them alone. Please review" 116 echo "the situation by hand." 117 fi 118 fi 119 } 120 121 # Stupid hack to keep lintian happy. (Warrk! Stupidhack!). 122 case $1 in 123 start) 124 [ -f /etc/apache2se/httpd.conf ] || touch /etc/apache2se/httpd.conf 125 #ssl_scache shouldn't be here if we're just starting up. 126 [ -f /var/run/apache2se/ssl_scache ] && rm -f /var/run/apache2se/*ssl_scache* 127 echo -n "Starting web server: Apache2se" 128 $APACHE2CTL startssl 129 echo "." 130 ;; 131 stop) 132 echo -n "Stopping web server: Apache2se" 133 apache_stop 134 echo "." 135 ;; 136 reload) 137 echo -n "Reloading web server config..." 138 $APACHE2CTL graceful $2 139 echo "done." 140 ;; 141 restart | force-reload) 142 echo -n "Forcing reload of web server: Apache2se" 143 apache_stop 144 $APACHE2CTL startssl 145 echo "." 146 ;; 147 *) 148 echo "Usage: /etc/init.d/apache2se start|stop|restart|reload|force-reload" 149 ;; 150 esac
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Tue Mar 17 22:47:18 2015 | Cross-referenced by PHPXref 0.7.1 |