321f7113cce89ab3b5555fe2e7a1f677deadaf61
max
  Fri Apr 11 07:40:07 2014 -0700
Committing all config files for the browserbox, refs #11957
diff --git src/browserbox/root/urlIsNotNewerThanFile src/browserbox/root/urlIsNotNewerThanFile
new file mode 100755
index 0000000..7106d9f
--- /dev/null
+++ src/browserbox/root/urlIsNotNewerThanFile
@@ -0,0 +1,41 @@
+#!/usr/bin/env python
+import urllib2, time, os, datetime, optparse, sys
+
+parser = optparse.OptionParser("""usage: %prog [options] URL filename - compare modification time of file on http server against mtime of file on disk, return exit 0 if it is newer, exit with 1 if not newer.
+example:
+if [ ! %prog http://hgdownload.cse.ucsc.edu/admin/hgcentral.sql lastUpdateTime.flag ]; then
+    echo skip update
+    exit
+fi
+""")
+
+(options, args) = parser.parse_args()
+
+if len(args)==0:
+    parser.print_help()
+    sys.exit(1)
+
+URL, flagFname = args
+
+# little helper class to download only the http HEAD
+class HeadRequest(urllib2.Request):
+    def get_method(self):
+        return "HEAD"
+
+
+# get the mtime of the file on the server
+response = urllib2.urlopen(HeadRequest(URL))
+timeStr = response.headers.getheader("Last-Modified")
+serverTime = datetime.datetime.fromtimestamp(time.mktime(time.strptime(timeStr, "%a, %d %b %Y %H:%M:%S GMT")))
+
+# get the mtime of the flag file
+localTime = datetime.datetime.fromtimestamp(0)
+if os.path.isfile(flagFname):
+    t = os.path.getmtime(flagFname)
+    localTime = datetime.datetime.fromtimestamp(t)
+
+if serverTime > localTime:
+    print "file was updated on server"
+    sys.exit(1)
+else:
+    sys.exit(0)