added header. removed ^M.
[privoxy.git] / junkbuster.init
1 #!/bin/sh
2 #  ********************************************************************
3
4 #  File        :  $Source: /cvsroot/ijbswa/current/loaders.c,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: loaders.c,v $
39
40 # ********************************************************************/
41
42 # These lines are needed so Redhat's config tools will "see" this script:
43 # chkconfig: 35 84 09
44 # description: Blocks annoying ads from the internet, along with cookies \
45 #              and a few other privacy features.      
46 # processname: junkbuster
47 # config: /etc/junkbuster/config
48
49 # ---------------------------------------------------------------------------
50 #
51 # SuSE only
52 #
53 # ---------------------------------------------------------------------------
54 if [ -f /etc/rc.config ]; then
55
56 # Author: Daniel Bischof <daniel@suse.de>, 1999
57 # Adjustment: Axel Braun <doc.b@gmx.de>, 17.08.2000 
58 . /etc/rc.config
59 #base=${0##*/}
60 #link=${base#*[SK][0-9][0-9]}
61 #test $link = $base && START_IJB=yes
62 #test "$START_IJB" = "yes" || exit 0
63 return=$rc_done
64 case "$1" in
65     start)
66         echo -n "Starting The Internet Junkbuster"
67         su - nobody -c 'nohup /usr/sbin/junkbuster /etc/junkbuster/config < /dev/null > /dev/null &'         
68         sleep 1
69         echo -e "$return"
70         ;;
71     stop)
72         echo -n "Shutting down The Internet Junkbuster"
73         killproc -TERM /usr/sbin/junkbuster || return=$rc_failed
74         echo -e "$return"
75         ;;
76     restart|reload)
77         echo -n "Reload The Internet Junkbuster"
78         killproc -HUP /usr/sbin/junkbuster || return=$rc_failed
79         echo -e "$return"
80         ;;
81     status)
82         checkproc /usr/sbin/junkbuster && echo OK || echo No process
83         ;;
84    # )
85         echo "Usage: $0 {start|restart|status|stop}"
86         exit 1
87 esac
88 test "$return" = "$rc_done" || exit 1
89 exit 0
90
91 else
92 # ---------------------------------------------------------------------------
93 #
94 # RedHat only
95 #
96 # ---------------------------------------------------------------------------
97
98 # Source function library.
99 if [ -f /etc/rc.d/init.d/functions ]; then
100 . /etc/rc.d/init.d/functions
101 fi
102
103 if [ -f /etc/sysconfig/network ]; then
104 . /etc/sysconfig/network
105 fi
106
107 #  Check that networking is up.
108 [ ${NETWORKING} = "no" ] && exit 0
109
110 [ -f /etc/junkbuster/config ] || exit 0
111
112 [ -f /usr/sbin/junkbuster ] || exit 0
113
114 RETVAL=0
115
116 # See how we were called.
117 case "$1" in
118
119    start)
120            # abort if already started
121       pid=`pidofproc junkbuster`
122       [ -n "$pid" ] && ps h $pid >/dev/null 2>&1 && \
123       echo -n "Already started: " && status junkbuster && \
124       exit 0
125
126       # Start daemon.
127       echo -n "Starting junkbuster:" && RETVAL=1
128       ulimit -c 0
129                 su - nobody -s /bin/sh -c '/usr/sbin/junkbuster /etc/junkbuster/config' &
130       sleep 1
131       pid=`pidofproc junkbuster`
132       [ -n "$pid" ] && ps h $pid >/dev/null 2>&1 && RETVAL=0 && echo_success && touch /var/lock/subsys/junkbuster
133       [ $RETVAL -eq 1 ] && echo_failure
134       echo
135       ;;
136
137    stop)
138       # Stop daemon.
139       echo -n "Shutting down junkbuster:"
140                 killproc junkbuster
141       RETVAL=$?
142       [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/junkbuster
143       echo
144       ;;
145
146    status)
147       status junkbuster
148       RETVAL=$?
149       ;;
150
151    restart|reload)
152                 $0 stop && $0 start
153       ;;
154
155   # )
156       echo "Usage: junkbuster {start|stop|status|restart|reload}"
157       exit 1
158 esac
159
160 exit $RETVAL
161
162 fi
163