1#!/bin/bash
2#
3# Licensed to the Apache Software Foundation (ASF) under one or more
4# contributor license agreements.  See the NOTICE file distributed with
5# this work for additional information regarding copyright ownership.
6# The ASF licenses this file to You under the Apache License, Version 2.0
7# (the "License"); you may not use this file except in compliance with
8# the License.  You may obtain a copy of the License at
9#
10#     http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS,
14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15# See the License for the specific language governing permissions and
16# limitations under the License.
17#
18#
19# htcacheclean    Startup script for the Apache cache cleaner
20#
21# chkconfig: - 85 15
22# description: The Apache htcacheclean daemon maintains and prunes the
23#              size of the mod_cache_disk cache directory.
24# processname: htcacheclean
25# pidfile: /var/log/httpd/htcacheclean.pid
26# config: /etc/sysconfig/htcacheclean
27#
28### BEGIN INIT INFO
29# Provides: htcacheclean
30# Required-Start: $local_fs $remote_fs $network
31# Required-Stop: $local_fs $remote_fs $network
32# Should-Start: httpd
33# Short-Description: start and stop Apache htcacheclean
34# Description: The Apache htcacheclean daemon maintains a mod_cache_disk
35### END INIT INFO
36
37# Source function library.
38. /etc/rc.d/init.d/functions
39
40# What were we called? Multiple instances of the same daemon can be
41# created by creating suitably named symlinks to this startup script
42prog=$(basename $0 | sed -e 's/^[SK][0-9][0-9]//')
43
44if [ -f /etc/sysconfig/${prog} ]; then
45        . /etc/sysconfig/${prog}
46fi
47
48# Path to htcacheclean, server binary, and short-form for messages.
49htcacheclean=${HTTPD-/usr/sbin/htcacheclean}
50lockfile=${LOCKFILE-/var/lock/subsys/${prog}}
51pidfile=/var/run/${prog}.pid
52interval=${INTERVAL-10}
53cachepath=${CACHEPATH-/var/cache/httpd/cache-root}
54limit=${LIMIT-100M}
55RETVAL=0
56
57start() {
58        echo -n $"Starting $prog: "
59        daemon --pidfile=${pidfile} $htcacheclean -d "$interval" -p "$cachepath" -l "$limit" -P "$pidfile" $OPTIONS
60        RETVAL=$?
61        echo
62        [ $RETVAL = 0 ] && touch ${lockfile}
63        return $RETVAL
64}
65stop() {
66	echo -n $"Stopping $prog: "
67	killproc -p ${pidfile} $htcacheclean
68	RETVAL=$?
69	echo
70	[ $RETVAL = 0 ] && rm -f ${lockfile}
71}
72
73# See how we were called.
74case "$1" in
75  start)
76	start
77	;;
78  stop)
79	stop
80	;;
81  status)
82        status -p ${pidfile} $htcacheclean
83	RETVAL=$?
84	;;
85  restart)
86	stop
87	start
88	;;
89  condrestart)
90	if status -p ${pidfile} $htcacheclean >&/dev/null; then
91		stop
92		start
93	fi
94	;;
95  *)
96	echo $"Usage: $prog {start|stop|restart|condrestart|status|help}"
97	exit 1
98esac
99
100exit $RETVAL
101