1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-02-13 19:52:06 +00:00
iiab/roles/network/templates/squid/iiab-httpcache.j2

42 lines
1.1 KiB
Text
Raw Normal View History

2017-05-27 18:09:50 +00:00
#!/bin/bash
# Turn squid caching on/off
SQUID_CACHEDIR="/library/cache"
SQUID_USER="squid:squid"
if [[ $1 == "enable" ]]; then
# Make sure that the cache directory is present.
# Squid crashes if it isn't (although it will create all subdirs...)
if [ ! -d $SQUID_CACHEDIR ]; then
mkdir $SQUID_CACHEDIR
chown $SQUID_USER $SQUID_CACHEDIR
/usr/sbin/squid -f /etc/squid/squid-iiab.conf -z
2017-05-27 18:09:50 +00:00
fi
# Turn squid on after the next reboot
/sbin/chkconfig --levels 345 squid on
# Turn squid on now
/sbin/service squid start
# Now, copy in a set of iptables that redirects forwarded traffic
# to port 80 to port 3128 on this machine
touch /etc/sysconfig/xs_httpcache_on
/sbin/service iptables restart
elif [[ $1 == "disable" ]]; then
# First, restore a normal set of iptables
if [ -e /etc/sysconfig/xs_httpcache_on ];then
rm /etc/sysconfig/xs_httpcache_on
fi
/sbin/service iptables restart
# Turn it off now
/sbin/service squid stop
# Turn it off after the next reboot
/sbin/chkconfig squid off
else
echo "Unrecognised argument: $1" >&2
exit 1
fi