Guest User

Untitled

a guest
Mar 21st, 2013
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.23 KB | None | 0 0
  1. #edit /etc/default/apache2 to change this.$
  2. HTCACHECLEAN_RUN=auto$
  3. HTCACHECLEAN_MODE=daemon$
  4. HTCACHECLEAN_SIZE=300M$
  5. HTCACHECLEAN_DAEMON_INTERVAL=120$
  6. HTCACHECLEAN_PATH=/var/cache/apache2$DIR_SUFFIX/mod_disk_cache$
  7. HTCACHECLEAN_OPTIONS=""$
  8. $
  9. APACHE_HTTPD=$(. $APACHE_ENVVARS && echo $APACHE_HTTPD)$
  10. if [ -z "$APACHE_HTTPD" ] ; then$
  11. ^IAPACHE_HTTPD=/usr/sbin/apache2$
  12. fi$
  13. if [ ! -x $APACHE_HTTPD ] ; then$
  14. ^Iecho "No apache MPM package installed"$
  15. ^Iexit 0$
  16. fi$
  17. $
  18. . /lib/lsb/init-functions$
  19. $
  20. test -f /etc/default/rcS && . /etc/default/rcS$
  21. $
  22. if [ -f /etc/default/apache2$DIR_SUFFIX ] ; then$
  23. ^I. /etc/default/apache2$DIR_SUFFIX$
  24. elif [ -f /etc/default/apache2 ] ; then$
  25. ^I. /etc/default/apache2$
  26. fi$
  27. $
  28. APACHE2CTL="$ENV /usr/sbin/apache2ctl"$
  29. HTCACHECLEAN="$ENV /usr/sbin/htcacheclean"$
  30. $
  31. PIDFILE=$(. $APACHE_ENVVARS && echo $APACHE_PID_FILE)$
  32. if [ -z "$PIDFILE" ] ; then$
  33. ^Iecho ERROR: APACHE_PID_FILE needs to be defined in $APACHE_ENVVARS >&2$
  34. ^Iexit 2$
  35. fi$
  36. $
  37. $
  38. check_htcacheclean() {$
  39. ^I[ "$HTCACHECLEAN_MODE" = "daemon" ] || return 1$
  40. $
  41. ^I[ "$HTCACHECLEAN_RUN" = "yes" ] && return 0$
  42. $
  43. ^IMODSDIR=$(. $APACHE_ENVVARS && echo $APACHE_MODS_ENABLED)$
  44. ^I[ "$HTCACHECLEAN_RUN" = "auto" \$
  45. ^I -a -e ${MODSDIR:-$APACHE_CONFDIR/mods-enabled}/disk_cache.load ] && \$
  46. ^I^Ireturn 0$
  47. ^I$
  48. ^Ireturn 1$
  49. }$
  50. <Directory "/var/www/statys?tyki/">$
  51. $
  52. Options Indexes FollowSymLinks$
  53. $
  54. AllowOverride All$
  55. $
  56. Order allow,deny$
  57. $
  58. Allow from all$
  59. $
  60. </Directory>$
  61. start_htcacheclean() {$
  62. ^Iif [ ! -d "$HTCACHECLEAN_PATH" ] ; then$
  63. ^I^Iecho "... directory $HTCACHECLEAN_PATH does not exist!" >&2$
  64. ^I^Ireturn 1$
  65. ^Ifi^I$
  66. ^I$HTCACHECLEAN $HTCACHECLEAN_OPTIONS -d$HTCACHECLEAN_DAEMON_INTERVAL \$
  67. ^I^I^I-i -p$HTCACHECLEAN_PATH -l$HTCACHECLEAN_SIZE$
  68. }$
  69. $
  70. stop_htcacheclean() {$
  71. ^Ipkill -P 1 -f "htcacheclean.* -p$HTCACHECLEAN_PATH " 2> /dev/null || echo ...not running$
  72. }$
  73. $
  74. pidof_apache() {$
  75. ^I# if there is actually an apache2 process whose pid is in PIDFILE,$
  76. ^I# print it and return 0.$
  77. ^Iif [ -e "$PIDFILE" ]; then$
  78. ^I^Iif pidof apache2 | tr ' ' '\n' | grep -w $(cat $PIDFILE); then$
  79. ^I^I^Ireturn 0$
  80. ^I^Ifi$
  81. ^Ifi$
  82. ^Ireturn 1$
  83. }$
  84. $
  85. apache_stop() {$
  86. ^Iif $APACHE2CTL configtest > /dev/null 2>&1; then$
  87. ^I^I# if the config is ok than we just stop normaly$
  88. $APACHE2CTL stop 2>&1 | grep -v 'not running' >&2 || true$
  89. ^Ielse$
  90. ^I^I# if we are here something is broken and we need to try$
  91. ^I^I# to exit as nice and clean as possible$
  92. ^I^IPID=$(pidof_apache) || true$
  93. $
  94. ^I^Iif [ "${PID}" ]; then$
  95. ^I^I^I# in this case it is everything nice and dandy and we kill apache2$
  96. ^I^I^Iecho$
  97. ^I^I^Ilog_warning_msg "The apache2$DIR_SUFFIX configtest failed, so we are trying to kill it manually. This is almost certainly suboptimal, so please make sure your system is working as you'd expect now!"$
  98. kill $PID$
  99. ^I^Ielif [ "$(pidof apache2)" ]; then$
  100. ^I^I^Iif [ "$VERBOSE" != no ]; then$
  101. echo " ... failed!"$
  102. ^I^I^I echo "You may still have some apache2 processes running. There are"$
  103. ^I^I^I echo "processes named 'apache2' which do not match your pid file,"$
  104. ^I^I^I echo "and in the name of safety, we've left them alone. Please review"$
  105. ^I^I^I echo "the situation by hand."$
  106. fi$
  107. return 1$
  108. ^I^Ifi$
  109. ^Ifi$
  110. }$
  111. $
  112. apache_wait_stop() {$
  113. ^I# running ?$
  114. ^IPIDTMP=$(pidof_apache) || true$
  115. ^Iif kill -0 "${PIDTMP:-}" 2> /dev/null; then$
  116. ^I PID=$PIDTMP$
  117. ^Ifi$
  118. $
  119. ^Iapache_stop$
  120. $
  121. ^I# wait until really stopped$
  122. ^Iif [ -n "${PID:-}" ]; then$
  123. ^I^Ii=0$
  124. ^I^Iwhile kill -0 "${PID:-}" 2> /dev/null; do$
  125. ^I^Iif [ $i = '60' ]; then$
  126. ^I^I^Ibreak;$
  127. ^I ^Ielse$
  128. ^I^I^Iif [ $i = '0' ]; then$
  129. ^I^I^Iecho -n " ... waiting "$
  130. ^I^I^Ielse$
  131. ^I ^I^Iecho -n "."$
  132. ^I^I ^Ifi$
  133. ^I^I^Ii=$(($i+1))$
  134. ^I^I^Isleep 1$
  135. ^I fi$
  136. ^I^I done$
  137. ^Ifi$
  138. }$
  139. $
  140. case $1 in$
  141. ^Istart)$
  142. ^I^Ilog_daemon_msg "Starting web server" "apache2"$
  143. ^I^Iif $APACHE2CTL start; then$
  144. ^I^I^Iif check_htcacheclean ; then$
  145. ^I^I^I^Ilog_progress_msg htcacheclean$
  146. ^I^I^I^Istart_htcacheclean || log_end_msg 1$
  147. ^I^I^Ifi$
  148. log_end_msg 0$
  149. else$
  150. log_end_msg 1$
  151. fi$
  152. ^I;;$
  153. ^Istop)$
  154. ^I^Iif check_htcacheclean ; then$
  155. ^I^I^Ilog_daemon_msg "Stopping web server" "htcacheclean"$
  156. ^I^I^Istop_htcacheclean$
  157. ^I^I^Ilog_progress_msg "apache2"$
  158. ^I^Ielse$
  159. ^I^I^Ilog_daemon_msg "Stopping web server" "apache2"$
  160. ^I^Ifi$
  161. ^I^Iif apache_wait_stop; then$
  162. log_end_msg 0$
  163. else$
  164. log_end_msg 1$
  165. fi$
  166. ^I;;$
  167. ^Igraceful-stop)$
  168. ^I^Iif check_htcacheclean ; then$
  169. ^I^I^Ilog_daemon_msg "Stopping web server" "htcacheclean"$
  170. ^I^I^Istop_htcacheclean$
  171. ^I^I^Ilog_progress_msg "apache2"$
  172. ^I^Ielse$
  173. ^I^I^Ilog_daemon_msg "Stopping web server" "apache2"$
  174. ^I^Ifi$
  175. ^I^Iif $APACHE2CTL graceful-stop; then$
  176. log_end_msg 0$
  177. else$
  178. log_end_msg 1$
  179. fi$
  180. ^I;;$
  181. ^Ireload | force-reload | graceful)$
  182. ^I^Iif ! $APACHE2CTL configtest > /dev/null 2>&1; then$
  183. $APACHE2CTL configtest || true$
  184. log_end_msg 1$
  185. exit 1$
  186. fi$
  187. log_daemon_msg "Reloading web server config" "apache2"$
  188. ^I^Iif pidof_apache > /dev/null ; then$
  189. if $APACHE2CTL graceful $2 ; then$
  190. log_end_msg 0$
  191. else$
  192. log_end_msg 1$
  193. fi$
  194. fi$
  195. ^I;;$
  196. ^Irestart)$
  197. ^I^Iif ! $APACHE2CTL configtest > /dev/null 2>&1; then$
  198. ^I^I $APACHE2CTL configtest || true$
  199. ^I^I log_end_msg 1$
  200. ^I^I exit 1$
  201. ^I^Ifi$
  202. ^I^Iif check_htcacheclean ; then$
  203. ^I^I^Ilog_daemon_msg "Restarting web server" "htcacheclean"$
  204. ^I^I^Istop_htcacheclean$
  205. ^I^I^Ilog_progress_msg apache2$
  206. ^I^Ielse$
  207. ^I^I^Ilog_daemon_msg "Restarting web server" "apache2"$
  208. ^I^Ifi$
  209. ^I^IPID=$(pidof_apache) || true$
  210. ^I^Iif ! apache_wait_stop; then$
  211. log_end_msg 1 || true$
  212. fi$
  213. ^I^Iif $APACHE2CTL start; then$
  214. ^I^I^Iif check_htcacheclean ; then$
  215. ^I^I^I^Istart_htcacheclean || log_end_msg 1$
  216. ^I^I^Ifi$
  217. log_end_msg 0$
  218. else$
  219. log_end_msg 1$
  220. fi$
  221. ^I;;$
  222. ^Istart-htcacheclean)$
  223. ^I^Ilog_daemon_msg "Starting htcacheclean"$
  224. ^I^Istart_htcacheclean || log_end_msg 1$
  225. ^I^Ilog_end_msg 0$
  226. ^I;;$
  227. ^Istop-htcacheclean)$
  228. ^I^Ilog_daemon_msg "Stopping htcacheclean"$
  229. ^I^I^Istop_htcacheclean$
  230. ^I^I^Ilog_end_msg 0$
  231. ^I;;$
  232. ^Istatus)$
  233. ^I^IPID=$(pidof_apache) || true$
  234. ^I^Iif [ -n "$PID" ]; then$
  235. ^I^I^Iecho "Apache2$DIR_SUFFIX is running (pid $PID)."$
  236. ^I^I^Iexit 0$
  237. ^I^Ielse$
  238. ^I^I^Iecho "Apache2$DIR_SUFFIX is NOT running."$
  239. ^I^I^Iif [ -e "$PIDFILE" ]; then$
  240. ^I^I^I^Iexit 1$
  241. ^I^I^Ielse$
  242. ^I^I^I^Iexit 3$
  243. ^I^I^Ifi$
  244. ^I^Ifi$
  245. ^I;;$
  246. ^I*)$
  247. ^I^Ilog_success_msg "Usage: /etc/init.d/apache2$DIR_SUFFIX {start|stop|graceful-stop|restart|reload|force-reload|start-htcacheclean|stop-htcacheclean|status}"$
  248. ^I^Iexit 1$
  249. ^I;;$
  250. esac$
Advertisement
Add Comment
Please, Sign In to add comment