on commence avec le script de progfou
authorWilly MANGA <willy.manga@auf.org>
Tue, 8 May 2012 15:32:26 +0000 (16:32 +0100)
committerWilly MANGA <willy.manga@auf.org>
Tue, 8 May 2012 15:32:26 +0000 (16:32 +0100)
scripts/redirectionUrl/squidRedirector [new file with mode: 0644]

diff --git a/scripts/redirectionUrl/squidRedirector b/scripts/redirectionUrl/squidRedirector
new file mode 100644 (file)
index 0000000..2aad6cd
--- /dev/null
@@ -0,0 +1,35 @@
+#!/bin/bash
+# /usr/local/sbin/squid-redirector
+# Auteur : Progfou <jean-christophe.andre@auf.org>
+# Licence : Domaine public
+# Création : 2008-01-14
+# Dépendances : libwww-perl (pour la commande HEAD)
+#
+# TODO: À refaire en Perl ou Python, un jour...
+#
+# URL <SP> client_ip "/" fqdn <SP> user <SP> method <SP> urlgroup <NL>
+#
+# ATTENTION : le miroir est incomplet => ne pas tout rediriger bêtement !!
+#
+MIRROR="cnf.vn.refer.org/mirror"
+while read URL CLIENT USER METHOD GROUP
+do
+  URL2="${URL/:\/\/apt.auf.org\//://${MIRROR}/auf/}"
+  [ "$URL2" = "$URL" ] && URL2="${URL/:\/\/apt.hanoilug.org\/ubuntu\//://${MIRROR}/ubuntu/hanoilug/}"
+  [ "$URL2" = "$URL" ] && URL2="${URL/:\/\/security.ubuntu.com\/ubuntu\//://${MIRROR}/ubuntu/security/}"
+  [ "$URL2" = "$URL" ] && URL2="${URL/:\/\/archive.canonical.com\/ubuntu\//://${MIRROR}/ubuntu/canonical/}"
+  [ "$URL2" = "$URL" ] && URL2="${URL/:\/\/*archive.ubuntu.com\/ubuntu\//://${MIRROR}/ubuntu/archive/}"
+  [ "$URL2" = "$URL" ] && URL2="${URL/:\/\/*packages.medibuntu.org\//://${MIRROR}/ubuntu/medibuntu/}"
+  [ "$URL2" = "$URL" ] && URL2="${URL/:\/\/security.debian.org\/debian-security\//://${MIRROR}/debian/security/}"
+  [ "$URL2" = "$URL" ] && URL2="${URL/:\/\/security.debian.org\//://${MIRROR}/debian/security/}"
+  [ "$URL2" = "$URL" ] && URL2="${URL/:\/\/volatile.debian.org\/debian-volatile\//://${MIRROR}/debian/volatile/}"
+  [ "$URL2" = "$URL" ] && URL2="${URL/:\/\/ftp*.debian.org\/debian\//://${MIRROR}/debian/archive/}"
+  [ "$URL2" = "$URL" ] && URL2="${URL/:\/\/www.backports.org\/debian\//://${MIRROR}/debian/backports/}"
+  if [ "$URL2" != "$URL" ] && HEAD -t5 "$URL2" > /dev/null
+  then
+    echo "!mirror!$URL2"
+  else
+    echo "$URL"
+  fi
+done
+exit 0