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