]> git.donarmstrong.com Git - dsa-puppet.git/commitdiff
actually add script ...
authorStephen Gran <steve@lobefin.net>
Sun, 12 Jan 2014 20:27:25 +0000 (20:27 +0000)
committerStephen Gran <steve@lobefin.net>
Sun, 12 Jan 2014 20:27:25 +0000 (20:27 +0000)
Signed-off-by: Stephen Gran <steve@lobefin.net>
modules/debian-org/files/check_for_updates [new file with mode: 0755]

diff --git a/modules/debian-org/files/check_for_updates b/modules/debian-org/files/check_for_updates
new file mode 100755 (executable)
index 0000000..7894da4
--- /dev/null
@@ -0,0 +1,19 @@
+#!/bin/bash
+
+parse_dates () {
+       while read url file junk; do
+               url=$(echo $url | sed -e "s/'//g")
+               url_time=$(date -d "$(curl -sqI ${url} | grep Last-Modified: | sed -e 's/Last-Modified: //')" +%s)
+               if [ ! -f "/var/lib/apt/lists/${file}" ]; then
+                       return 0
+               fi
+               file_time=$(stat -c %Y /var/lib/apt/lists/${file})
+               if [ $url_time -gt $file_time ]; then
+                       return 0
+               fi
+       done
+       return 1
+}
+
+su nobody -c 'apt-get update -s --print-uris' | grep 'Release ' | parse_dates
+exit $?