blob: 6b6f3288e6a7440b0e0716fb88b11e9379d854fe (
plain) (
blame)
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
#!/bin/bash
. `dirname $0`/functions
option config standard_option /etc/opt/squid/squid.conf
option httpport standard_option
option icpport standard_option
option usesyslog boolean_option 0
option createswap boolean_option 0
option catchsignals boolean_option 1
option dnstest boolean_option 1
option waitrebuild boolean_option 0
option reuseaddr boolean_option 1
option doublecheck boolean_option 0
option vhostaccel boolean_option 0
option bin reserved_option /opt/sbin/squid
option gbin reserved_option /opt/bin/squidGuard
option pidfile reserved_option /var/log/squid/squid.pid
option cmdline reserved_option '$bin -D'
function fct_pre_start {
valueof $opt_config cache_log >/dev/null 2>&1
[ -z "$REPLY" ] && REPLY=/var/log/squid/cache.log
[ ! -d ${REPLY%/*} ] && mkdir -p ${REPLY%/*} \
&& chown -R squid:squid ${REPLY%/*}
valueof $opt_config cache_dir >/dev/null 2>&1
set -- $REPLY ; REPLY=$2
[ -z "$REPLY" ] && REPLY=/var/opt/squid/cache
[ ! -d $REPLY ] && mkdir -p $REPLY \
&& chown -R squid:squid $REPLY \
&& $bin -z
valueof $opt_config redirect_program >/dev/null 2>&1
set -- $REPLY
if [ -n "$1" -a -z "${1//*squidGuard*/}" ] ; then
echo -n "# Preparing squidGuard ... "
[ ! -e /var/log/squidGuard ] && ln -s squid /var/log/squidGuard
if [ ! -d /var/cache/squidGuard ] ; then
mkdir -p /var/cache/squidGuard
do_update_squidguard
fi
echo "done."
fi
}
function do_update_squidguard {
for file in $(find /opt/squidGuard/db/ \
-name "*.tgz" -o -name "*.tar.gz") ; do
tar zxf $file -C /var/cache/squidGuard
done
chown -R squid:squid /var/cache/squidGuard
sudo -u squid $gbin -C all </dev/null
find /var/cache/squidGuard/ -name "*.diff" | while read ; do
cat $REPLY >> ${REPLY%%[.0-9]*.diff}.diff
done
sudo -u squid $gbin -u </dev/null
find /var/cache/squidGuard/ -name "*.diff" | xargs rm -f
find /var/cache/squidGuard/ -name "*.db"|sed 's/\.db$//'|xargs rm -f
}
function fct_end_section {
local chroot
# try to find pidfile from the config file if unspecified
if [ -z "$pidfile" ]; then
valueof ${opt_config:-/etc/opt/squid/squid.conf} chroot >/dev/null 2>&1
chroot=$REPLY
valueof ${opt_config:-/etc/opt/squid/squid.conf} pid_filename >/dev/null 2>&1
pidfile=$chroot/${REPLY:-/var/log/squid.pid}
pidfile=${pidfile//\/\//\/} # clear double slashes
fi
# let's add the options to the command line
cmdline="$cmdline ${opt_config:+-f $opt_config} ${opt_httpport:+-a $opt_httpport}"
cmdline="$cmdline ${opt_icpport:+-u $opt_icpport}"
[ "$opt_usesyslog" = "1" ] && cmdline="$cmdline -s"
[ "$opt_createswap" = "1" ] && cmdline="$cmdline -z"
[ "$opt_catchsignals" != "1" ] && cmdline="$cmdline -C"
[ "$opt_dnstest" != "1" ] && cmdline="$cmdline -D"
[ "$opt_reuseaddr" != "1" ] && cmdline="$cmdline -R"
[ "$opt_waitrebuild" = "1" ] && cmdline="$cmdline -F"
[ "$opt_doublecheck" = "1" ] && cmdline="$cmdline -S"
[ "$opt_vhostaccel" = "1" ] && cmdline="$cmdline -V"
}
load_config
|