Removing obsolete settings.
[privoxy.git] / junkbuster.init
1 #!/bin/sh
2 #  ********************************************************************
3
4 #  File        :  $Source: /cvsroot/ijbswa/current/junkbuster.init,v $
5
6 #  Purpose     :  This shell script takes care of starting and stopping
7 #                 junkbuster.
8 #                 This works only correctly if the user `nobody' is allowed
9 #                 to be in the directory where this file is called 
10 #                 (for example: /root is NOT ok)
11
12 #  Copyright   :  Written by and Copyright (C) 2001 the SourceForge
13 #                 IJBSWA team.  http://ijbswa.sourceforge.net
14
15 #                 Based on the Internet Junkbuster originally written
16 #                 by and Copyright (C) 1997 Anonymous Coders and
17 #                 Junkbusters Corporation.  http://www.junkbusters.com
18
19 #                 This program is free software; you can redistribute it
20 #                 and/or modify it under the terms of the GNU General
21 #                 Public License as published by the Free Software
22 #                 Foundation; either version 2 of the License, or (at
23 #                 your option) any later version.
24
25 #                 This program is distributed in the hope that it will
26 #                 be useful, but WITHOUT ANY WARRANTY; without even the
27 #                 implied warranty of MERCHANTABILITY or FITNESS FOR A
28 #                 PARTICULAR PURPOSE.  See the GNU General Public
29 #                 License for more details.
30
31 #                 The GNU General Public License should be included with
32 #                 this file.  If not, you can view it at
33 #                 http://www.gnu.org/copyleft/gpl.html
34 #                 or write to the Free Software Foundation, Inc., 59
35 #                 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
36
37 #  Revisions   :
38 #     $Log: junkbuster.init,v $
39 #     Revision 1.2  2001/05/24 07:52:24  swa
40 #     added header. removed ^M.
41 #
42
43 # ********************************************************************/
44
45 # These lines are needed so Redhat's config tools will "see" this script:
46 # chkconfig: 35 84 09
47 # description: Blocks annoying ads from the internet, along with cookies \
48 #              and a few other privacy features.      
49 # processname: junkbuster
50 # config: /etc/junkbuster/config
51
52 # ---------------------------------------------------------------------------
53 #
54 # SuSE only
55 # FIXME: I need to be updated using the latest skeleton script from SuSE
56 #
57 # ---------------------------------------------------------------------------
58 if [ -f /etc/rc.config ]; then
59
60 # Author: Daniel Bischof <daniel@suse.de>, 1999
61 # Adjustment: Axel Braun <doc.b@gmx.de>, 17.08.2000 
62 . /etc/rc.config
63 #base=${0##*/}
64 #link=${base#*[SK][0-9][0-9]}
65 #test $link = $base && START_IJB=yes
66 #test "$START_IJB" = "yes" || exit 0
67 return=$rc_done
68 case "$1" in
69     start)
70         echo -n "Starting The Internet Junkbuster"
71         su - nobody -c 'nohup /usr/sbin/junkbuster /etc/junkbuster/config < /dev/null > /dev/null &'         
72         sleep 1
73         echo -e "$return"
74         ;;
75     stop)
76         echo -n "Shutting down The Internet Junkbuster"
77         killproc -TERM /usr/sbin/junkbuster || return=$rc_failed
78         echo -e "$return"
79         ;;
80     restart|reload)
81         echo -n "Reload The Internet Junkbuster"
82         killproc -HUP /usr/sbin/junkbuster || return=$rc_failed
83         echo -e "$return"
84         ;;
85     status)
86         checkproc /usr/sbin/junkbuster && echo OK || echo No process
87         ;;
88     *)
89         echo "Usage: $0 {start|restart|status|stop}"
90         exit 1
91 esac
92 test "$return" = "$rc_done" || exit 1
93 exit 0
94
95 else
96 # ---------------------------------------------------------------------------
97 #
98 # RedHat only
99 #
100 # ---------------------------------------------------------------------------
101
102 # Source function library.
103 if [ -f /etc/rc.d/init.d/functions ]; then
104 . /etc/rc.d/init.d/functions
105 fi
106
107 if [ -f /etc/sysconfig/network ]; then
108 . /etc/sysconfig/network
109 fi
110
111 #  Check that networking is up.
112 [ ${NETWORKING} = "no" ] && exit 0
113
114 [ -f /etc/junkbuster/config ] || exit 0
115
116 [ -f /usr/sbin/junkbuster ] || exit 0
117
118 RETVAL=0
119
120 # See how we were called.
121 case "$1" in
122
123    start)
124            # abort if already started
125       pid=`pidofproc junkbuster`
126       [ -n "$pid" ] && ps h $pid >/dev/null 2>&1 && \
127       echo -n "Already started: " && status junkbuster && \
128       exit 0
129
130       # Start daemon.
131       echo -n "Starting junkbuster:" && RETVAL=1
132       ulimit -c 0
133                 su - nobody -s /bin/sh -c '/usr/sbin/junkbuster /etc/junkbuster/config' &
134       sleep 1
135       pid=`pidofproc junkbuster`
136       [ -n "$pid" ] && ps h $pid >/dev/null 2>&1 && RETVAL=0 && echo_success && touch /var/lock/subsys/junkbuster
137       [ $RETVAL -eq 1 ] && echo_failure
138       echo
139       ;;
140
141    stop)
142       # Stop daemon.
143       echo -n "Shutting down junkbuster:"
144                 killproc junkbuster
145       RETVAL=$?
146       [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/junkbuster
147       echo
148       ;;
149
150    status)
151       status junkbuster
152       RETVAL=$?
153       ;;
154
155    restart|reload)
156                 $0 stop && $0 start
157       ;;
158
159    *)
160       echo "Usage: junkbuster {start|stop|status|restart|reload}"
161       exit 1
162 esac
163
164 exit $RETVAL
165
166 fi
167