From db1415b09d131dc6569e95484c33bc5739895595 Mon Sep 17 00:00:00 2001 From: Stephen Gran Date: Sun, 12 Jan 2014 20:27:25 +0000 Subject: [PATCH] actually add script ... Signed-off-by: Stephen Gran --- modules/debian-org/files/check_for_updates | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100755 modules/debian-org/files/check_for_updates diff --git a/modules/debian-org/files/check_for_updates b/modules/debian-org/files/check_for_updates new file mode 100755 index 00000000..7894da48 --- /dev/null +++ b/modules/debian-org/files/check_for_updates @@ -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 $? -- 2.39.2