]>
Commit | Line | Data |
---|---|---|
d56fc335 MT |
1 | #!/bin/sh |
2 | # Begin $rc_base/init.d/squid | |
3 | ||
4 | . /etc/sysconfig/rc | |
5 | . $rc_functions | |
6 | ||
18322edf CS |
7 | chown -R squid:squid /var/log/squid |
8 | chown -R squid:squid /var/log/squidGuard | |
9 | ||
d56fc335 MT |
10 | transparent() { |
11 | DEVICE=$1 | |
12 | ||
13 | eval $(/usr/local/bin/readhash /var/ipfire/ethernet/settings) | |
14 | eval $(/usr/local/bin/readhash /var/ipfire/proxy/settings) | |
15 | ||
16 | # If the proxy port is not set we set the default to 800. | |
17 | if [ -z $PROXY_PORT ]; then | |
18 | PROXY_PORT=800 | |
19 | fi | |
20 | ||
21 | LOCALIP=`cat /var/ipfire/red/local-ipaddress | tr -d \n` | |
22 | if [ -z $LOCALIP ]; then | |
23 | boot_mesg "Couldn't read local-ipaddress" ${FAILURE} | |
24 | exit 1 | |
25 | fi | |
26 | ||
27 | COUNT=1 | |
28 | FILE=/var/ipfire/vpn/config | |
29 | ||
30 | while read LINE; do | |
31 | let COUNT=$COUNT+1 | |
32 | CONN_TYPE=`echo "$LINE" | awk -F, '{ print $5 }'` | |
33 | if [ "$CONN_TYPE" != "net" ]; then | |
34 | continue | |
35 | fi | |
36 | iptables -t nat -A SQUID -i $1 -p tcp -d `echo "$LINE" | awk -F, '{ print $13 }'` --dport 80 -j RETURN | |
37 | done < $FILE | |
38 | ||
39 | if [ "$RED_TYPE" == "STATIC" ]; then | |
40 | iptables -t nat -A SQUID -i $1 -p tcp -d $RED_NETADDRESS/$RED_NETMASK --dport 80 -j RETURN | |
41 | fi | |
42 | ||
43 | iptables -t nat -A SQUID -i $1 -p tcp -d $LOCALIP --dport 80 -j RETURN | |
44 | ||
45 | iptables -t nat -A SQUID -i $1 -p tcp --dport 80 -j REDIRECT --to-port $PROXY_PORT | |
46 | } | |
47 | ||
48 | case "$1" in | |
49 | start) | |
8b202790 CS |
50 | getpids "squid" |
51 | ||
52 | if [ -n "${pidlist}" ]; then | |
53 | echo -e "Squid is already running with Process"\ | |
54 | "ID(s) ${pidlist}.${NORMAL}" | |
55 | evaluate_retval | |
56 | exit | |
57 | fi | |
d56fc335 | 58 | if [ -e /var/ipfire/proxy/enable -o -e /var/ipfire/proxy/enable_blue ]; then |
203c2787 | 59 | boot_mesg "Starting Squid Proxy Server..." |
d56fc335 MT |
60 | loadproc /usr/sbin/squid -D -z >/dev/null 2>&1 |
61 | loadproc /usr/sbin/squid -D | |
62 | fi | |
63 | ||
64 | eval $(/usr/local/bin/readhash /var/ipfire/ethernet/settings) | |
65 | ||
66 | if [ -e /var/ipfire/proxy/transparent ]; then | |
67 | transparent $GREEN_DEV | |
68 | fi | |
69 | if [ -e /var/ipfire/proxy/transparent_blue ]; then | |
70 | transparent $BLUE_DEV | |
71 | fi | |
72 | ;; | |
73 | ||
74 | stop) | |
a332b303 | 75 | iptables -t nat -F SQUID |
af95dec5 | 76 | if [ -e /var/run/squid.pid ]; then |
09b58b25 | 77 | boot_mesg "Stopping Squid Proxy Server..." |
09b58b25 CS |
78 | squid -k shutdown >/dev/null 2>&1 |
79 | evaluate_retval | |
80 | killproc /usr/bin/squidGuard >/dev/null | |
81 | killproc /usr/sbin/updxlrator >/dev/null | |
82 | killproc /usr/sbin/squid >/dev/null | |
a332b303 | 83 | rm -rf /var/run/squid.pid |
09b58b25 | 84 | fi |
d56fc335 MT |
85 | ;; |
86 | ||
87 | restart) | |
88 | $0 stop | |
186e3d2c | 89 | sleep 5 |
d56fc335 MT |
90 | $0 start |
91 | ;; | |
92 | ||
fe1656d2 CS |
93 | reconfigure) |
94 | /usr/sbin/squid -k reconfigure | |
95 | ;; | |
96 | ||
d56fc335 MT |
97 | status) |
98 | statusproc /usr/sbin/squid | |
99 | statusproc /usr/lib/squid/unlinkd | |
100 | ;; | |
101 | ||
102 | flush) | |
103 | $0 stop | |
104 | echo > /var/log/cache/swap.state | |
105 | chown squid.squid /var/log/cache/swap.state | |
106 | sleep 1 | |
107 | $0 start | |
108 | ;; | |
2b5b6b9e CS |
109 | setperms) |
110 | chown -R nobody.squid /var/updatecache/ | |
111 | ;; | |
d56fc335 MT |
112 | |
113 | *) | |
114 | echo "Usage: $0 {start|stop|restart|status|flush}" | |
115 | exit 1 | |
116 | ;; | |
117 | esac | |
118 | ||
119 | # End $rc_base/init.d/squid |