]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blame - src/initscripts/init.d/squid
leds: disable all led's at halt.
[people/teissler/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
78e1facf 91 killproc /usr/bin/squidclamav >/dev/null
09b58b25 92 killproc /usr/sbin/squid >/dev/null
a332b303 93 rm -rf /var/run/squid.pid
09b58b25 94 fi
d56fc335
MT
95 ;;
96
97 restart)
98 $0 stop
186e3d2c 99 sleep 5
d56fc335
MT
100 $0 start
101 ;;
102
fe1656d2
CS
103 reconfigure)
104 /usr/sbin/squid -k reconfigure
105 ;;
106
d56fc335
MT
107 status)
108 statusproc /usr/sbin/squid
109 statusproc /usr/lib/squid/unlinkd
110 ;;
111
112 flush)
113 $0 stop
114 echo > /var/log/cache/swap.state
115 chown squid.squid /var/log/cache/swap.state
116 sleep 1
117 $0 start
118 ;;
2b5b6b9e
CS
119 setperms)
120 chown -R nobody.squid /var/updatecache/
121 ;;
d56fc335
MT
122
123 *)
124 echo "Usage: $0 {start|stop|restart|status|flush}"
125 exit 1
126 ;;
127esac
128
129# End $rc_base/init.d/squid