John Morton wrote:
Armin Marxer wrote:
The cache_peer directive doesn't appear to be one of the few that require a complete restart, so it may be possible to switch config files (or create by pluging values into a template), then do a reload.I am running Squid (2.5S7, on FC2 Linux) on a notebook machine, a machine
which is used on several networks. One of these networks requires me to
use a parent proxy for Internet access. Is it possible to specify the
parent proxy, if any, outside the squid.conf config file?
Basically I'd like to avoid having to edit the config file depending on the network connected to. Ideally I could specify it via environment variable, but an option on the squid command line would do too.
You could run multiple squid.conf's and depending on which network you were
on, start squid up with the correct squid.conf file. Check out the FAQ on
squid's command-line options.
John
Exactly: 2 (or more) squid.conf files, and a shell script somethign like the following:
(no guarantee that the script is error free, just typing it into thunderbird now...)
#!/bin/bash
SQUID_BIN=/opt/squid/sbin/squid SQUID_CONF_DIR=/opt/squid/etc/
if [ ! -x ${SQUID_BIN} ]; then
echo "Squid-Binary ${SQUID_BIN} is not executable!"
exit 1
ficase "$1" in
work)
cp ${SQUID_CONF_DIR}/squid.work.conf ${SQUID_CONF_DIR}/squid.conf
${SQUID_BIN}-k reconfigure && echo "Squid sucessfully reconfigured fir ${1}" || echo "Squid could not be reconfigured for ${1}."
;;
home)
cp ${SQUID_CONF_DIR}/squid.home.conf ${SQUID_CONF_DIR}/squid.conf
${SQUID_BIN}-k reconfigure && echo "Squid sucessfully reconfigured for ${1}" || echo "Squid could not be reconfigured for ${1}."
;;
*)
echo "Attempting to reconfigure squid for unknown location called ${1}..."
if [ -f ${SQUID_CONF_DIR}/squid.${1}.conf ]; then
cp ${SQUID_CONF_DIR}/squid.${1}.conf ${SQUID_CONF_DIR}/squid.conf && echo "Wow, location ${1} really seems to exist."
else
echo "${1} isn't a real place!"
echo "Usage: /usr/bin/squidswitch {work|home}"
exit 1
;;
esac
exit 0
Obviously the first two options aren't really needed, but if you have good bash completion (i think) it might recognize the select case and complete the options.
Cheers,
Chris
