]> git.pld-linux.org Git - packages/dansguardian.git/blame - dansguardian.init
- cosmetics
[packages/dansguardian.git] / dansguardian.init
CommitLineData
fc270497 1#!/bin/sh
2#
3# Startup script for dansguardian
4#
8000c908 5# chkconfig: 35 92 08
6b620faf 6# description: A web content filtering plugin for web \
7# proxies, developed to filter using lists of \
8# banned phrases, MIME types, filename \
9# extensions and PICS labelling.
10# processname: dansguardian
11# pidfile: /var/run/dansguardian.pid
12# config: /etc/dansguardian/dansguardian.conf
fc270497 13
14CONFFILELOCATION=/etc/dansguardian/
15BINARYLOCATION=/usr/sbin/
16PIDDIR=/var/run/
17
6b620faf 18# Source function library
19. /etc/rc.d/init.d/functions
20
fc270497 21# File includes changes by Thomas Jarosch
22function wait_for_pid()
23{
24 local PID=$1
25 local RET=0
1af0e619 26
fc270497 27 if [ $PID -eq 0 ] ; then
28 return $RET
29 fi
1af0e619 30
fc270497 31 # give 60 secs then KILL
32 local COUNTDOWN=60
33
34 while [ -d /proc/${PID} ] && [ $COUNTDOWN -gt 0 ] ; do
35 sleep 1
36 COUNTDOWN=$[$COUNTDOWN-1]
37 done
38
39 if [ -d /proc/${PID} ]; then
40 COMMAND=`ps h -o command ${PID}`
41 logger "dansguardian: timeout waiting for PID ${PID}: ${COMMAND}; sending SIGKILL"
42 kill -KILL $PID >/dev/null 2>&1
43 RET=1
44 fi
1af0e619 45
fc270497 46 return $RET
47}
48
49# See how we were called.
50
51case "$1" in
6b620faf 52 start)
53 # Check if the service is already running?
54 if [ ! -f /var/lock/subsys/dansguardian ]; then
55 if [ -f ${BINARYLOCATION}dansguardian ] &&
56 [ -f ${CONFFILELOCATION}dansguardian.conf ]; then
57 msg_starting dansguardian
58 run_cmd ${BINARYLOCATION}dansguardian 2>/dev/null
59 RETVAL=$?
60 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/dansguardian
61 fi
62 else
63 msg_already_running dansguardian
64 fi
65 ;;
66 stop)
67 if [ -f /var/lock/subsys/dansguardian ]; then
68 msg_stopping dansguardian
69 busy
70 WAITPID=0
71 if [ -f ${PIDDIR}dansguardian.pid ] ; then
72 WAITPID=`cat ${PIDDIR}dansguardian.pid`
73 fi
74 if ${BINARYLOCATION}dansguardian -q 2> /dev/null; then
75 if wait_for_pid $WAITPID ; then
76 ok
77 else
78 fail
79 fi
80 rm -f ${PIDDIR}dansguardian.pid
81 rm -f /tmp/.dguardianipc
82 [ -d /var/lock/subsys ] && /bin/rm -f /var/lock/subsys/dansguardian
83 else
84 fail
85 fi
86 else
87 msg_not_running dansguardian
88 fi
89 ;;
90 restart|force-reload)
91 $0 stop
92 $0 start
fc270497 93 ;;
6b620faf 94 status)
95 if [ -f ${BINARYLOCATION}dansguardian ]; then
96 ${BINARYLOCATION}dansguardian -s
97 fi
98 status dansguardian
99 exit $?
100 ;;
101 *)
102 msg_usage "$0 {start|stop|restart|force-reload|status}"
103 exit 3
fc270497 104esac
105
6b620faf 106exit $RETVAL
This page took 0.063742 seconds and 4 git commands to generate.