blob: 61d9de42dd8b48e185311dbcbe1bfebbceb18a0c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
#!/bin/sh
DAEMON=/usr/sbin/squid
NAME=squid
DESC="Squid HTTP proxy"
PIDFILE=/var/run/squid.pid
SQUID_ARGS="-D -sYC"
test -f $DAEMON || exit 0
grepconf() {
w=" " # space tab
sq=/etc/$NAME.conf
# sed is cool.
res=`sed -ne '
s/^'$1'['"$w"']\+[^'"$w"']\+['"$w"']\+\([^'"$w"']\+\).*$/\1/p;
t end;
d;
:end q' < $sq`
[ -n "$res" ] || res=$2
echo "$res"
}
start() {
owner=nobody
cdr=`grepconf cache_dir /var/spool/$NAME`
if [ ! -d "$cdr/00" ]; then
mkdir -p $cdr
chown $owner $cdr
$DAEMON -z
fi
ldr="/var/log/$NAME"
if [ ! -d "$ldr" ]; then
mkdir -p $ldr
chown $owner $ldr
fi
start-stop-daemon -S -p $PIDFILE -x $DAEMON
}
stop() {
start-stop-daemon -K -p $PIDFILE -x $DAEMON
}
case "$1" in
start)
echo -n "Starting $DESC: $NAME... "
start
echo "done."
;;
stop)
echo -n "Stopping $DESC: $NAME... "
stop
echo "done."
;;
restart)
echo "Restarting $DESC: $NAME... "
stop
sleep 1
start
echo "done."
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
;;
esac
exit 0
|