[Server-devel] [PATCH] Squid: Now clients can request 'schoolserver' and it will work correctly

martin.langhoff at gmail.com martin.langhoff at gmail.com
Mon Jun 16 12:47:35 EDT 2008


From: Martin Langhoff <martin at laptop.org>

This patch fixes squid so that it appends the search domain properly.
---
 fsroot.olpc.img/etc/squid/squid.conf               |   14 ++++++++
 .../sysconfig/olpc-scripts/domain_config.d/squid   |   36 ++++++++++++++++++++
 2 files changed, 50 insertions(+), 0 deletions(-)
 create mode 100755 fsroot.olpc.img/etc/sysconfig/olpc-scripts/domain_config.d/squid

diff --git a/fsroot.olpc.img/etc/squid/squid.conf b/fsroot.olpc.img/etc/squid/squid.conf
index 2922326..d94b4e6 100644
--- a/fsroot.olpc.img/etc/squid/squid.conf
+++ b/fsroot.olpc.img/etc/squid/squid.conf
@@ -30,6 +30,20 @@ acl CONNECT method CONNECT
 acl QUERY urlpath_regex cgi-bin \?
 acl apache rep_header Server ^Apache
 
+###############
+#
+#  Append the search domain
+# 
+# This means that requests for 'http://schoolserver/'
+# get resolved the way you would expect (using the same
+# search domain that laptops and the XS have defined in
+# resolv.conf
+#
+# NOTE: it must start with a dot
+#
+append_domain .random.xs.laptop.org
+
+
 ###############################
 #  Cache controls
 # The default is to cache everything
diff --git a/fsroot.olpc.img/etc/sysconfig/olpc-scripts/domain_config.d/squid b/fsroot.olpc.img/etc/sysconfig/olpc-scripts/domain_config.d/squid
new file mode 100755
index 0000000..342ec74
--- /dev/null
+++ b/fsroot.olpc.img/etc/sysconfig/olpc-scripts/domain_config.d/squid
@@ -0,0 +1,36 @@
+#!/bin/sh -e
+#  This file is called when the domain name is changed, to change any
+#  named configuration files affected.
+#
+#  The first argument is the old domain name,
+#  the second argument is the new domain name
+
+#  Copyright 2008, One Laptop per Child
+#  Author: John Watlington <wad at laptop.org>
+#  License: GPL v2
+
+#  This is the name of the service (for stopping and restarting)
+SERVICE_NAME=squid
+
+#  This is a list of files related to this service which will have
+#  the domain name globally replaced inside them
+CONFIG_LIST="/etc/squid/squid.conf"
+
+#  This is the suffix which original versions of modified files will have
+BACKUP_SUFFIX=old
+
+old_name=$1
+new_name=$2
+
+# echo Changing $SERVICE_NAME config from $old_name to $new_name
+
+service $SERVICE_NAME stop
+
+for config in $CONFIG_LIST;
+do
+  mv $config $config.$BACKUP_SUFFIX
+  sed -e s/$old_name/$new_name/ $config.$BACKUP_SUFFIX > $config ;
+done
+
+service $SERVICE_NAME start
+
-- 
1.5.4.34.g053d9



More information about the Server-devel mailing list