File c-icap.init of Package c-icap
#!/bin/sh
#
# This library is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or (at
# your option) any later version.
#
# This library is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#
# /etc/init.d/c-icap
# and its symbolic link
# /usr/sbin/rcc-icap
### BEGIN INIT INFO
# Provides: c-icap
# Required-Start: $network $remote_fs
# Should-Start: squid
# Required-Stop: $network $remote_fs
# Should-Stop: squid
# Default-Start: 3 5
# Default-Stop: 0 1 2 6
# Short-Description: Implementation of an ICAP server
# Description: This implementation of an ICAP server can be used
# together with HTTP proxies like squid that support the ICAP protocol
# to implement content adaptation and filtering services.
### END INIT INFO
# Check for missing binaries (stale symlinks should not happen)
# Note: Special treatment of stop for LSB conformance
ICAP_BIN='/usr/bin/c-icap'
test -x "$ICAP_BIN" || { echo "$ICAP_BIN not installed";
if [ "$1" = "stop" ]; then exit 0;
else exit 5; fi; }
ICAP_CONF='/etc/c-icap/c-icap.conf'
test -r "$ICAP_CONF" || { echo "$ICAP_CONF not existing or readable";
if [ "$1" = "stop" ]; then exit 0;
else exit 6; fi; }
function get_config {
set -- `grep ^$1 "$ICAP_CONF" | sed 's@[[:space:]]@ @' | tr -d '[:cntrl:]'`
shift # remove first ARG => search-string
echo $*
}
PIDFILE=$(get_config PidFile)
: ${PIDFILE:=/var/run/c-icap/c-icap.pid}
ICAP_USER=$(get_config User)
: ${ICAP_USER:=c-icap}
ICAP_GROUP=$(get_config Group)
: ${ICAP_GROUP:=c-icap}
ICAP_SOCKET=$(get_config CommandsSocket)
: ${ICAP_SOCKET:=/var/run/c-icap/c-icap.ctl}
PIDDIR=$(dirname "$PIDFILE")
# Shell functions sourced from /etc/rc.status:
. /etc/rc.status
# Reset status of this service
rc_reset
case "$1" in
start)
echo -n "Starting c-icap "
test -d "$PIDDIR" || install -d -m755 -o "$ICAP_USER" -g "$ICAP_GROUP" "$PIDDIR"
/sbin/startproc $ICAP_BIN
rc_status -v
;;
stop)
echo -n "Shutting down c-icap "
/sbin/killproc -TERM $ICAP_BIN
rc_status -v
;;
try-restart|condrestart)
if test "$1" = "condrestart"; then
echo "${attn} Use try-restart ${done}(LSB)${attn} rather than condrestart ${warn}(RH)${norm}"
fi
$0 status
if test $? = 0; then
$0 restart
else
rc_reset # Not running is not a failure.
fi
rc_status
;;
restart)
$0 stop
$0 start
rc_status
;;
force-reload)
echo -n "Reload service c-icap "
/sbin/killproc -HUP $ICAP_BIN
rc_status -v
;;
reload)
echo -n "Reload service c-icap "
if [ -S "$ICAP_SOCKET" ]; then
echo -n 'reconfigure' > "$ICAP_SOCKET"
else
/sbin/killproc -HUP $ICAP_BIN
fi
rc_status -v
;;
status)
echo -n "Checking for service c-icap "
rc_status -v
;;
relog)
echo -n "Re-opening the c-icap log files: "
if [ -S "$ICAP_SOCKET" ]; then
echo -n 'relog' > "$ICAP_SOCKET"
echo "done"
else
echo "no socket found at $ICAP_SOCKET"
rc_failed 7
fi
rc_status -v
;;
*)
echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|probe|relog}"
exit 1
;;
esac
rc_exit