From 34fcc231839487cc5bf6936a5088570a223fe4a2 Mon Sep 17 00:00:00 2001 From: Jesus Alvarez Date: Thu, 15 Aug 2013 00:40:34 -0700 Subject: [PATCH] scraper.sh: The script works as expected --- scraper.sh | 59 ++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 53 insertions(+), 6 deletions(-) diff --git a/scraper.sh b/scraper.sh index 9ed5f10..8505ab7 100755 --- a/scraper.sh +++ b/scraper.sh @@ -1,17 +1,64 @@ #!/bin/bash -REPO_BASEPATH="/data/pacman/repo" -REMOTE_LOGIN="jalvarez@jalvarez.webfactional.com" - source "lib.sh" +source "conf.sh" check_webpage() { # $1: The url to scrape # $2: The Perl regex to match with # $3: Expect match # Sends a message on mismatch - MSTR=$(curl -s "$1" | grep -Po "$2") - if [[ $MSTR != "$3" ]]; then - error "Checking \"$1\" expected \"$3\" got \"$MSTR\"" + SCRAPED_STRING=$(curl -s "$1" | grep -Po "$2") + if [[ $SCRAPED_STRING != "$3" ]]; then + error "Checking \"$1\" expected \"$3\" got \"$SCRAPED_STRING\"" + return 1 fi } + +# +# Check archiso kernel version (this will change when the archiso is updated) +# +msg "Checking archiso download page for linux kernel version changes..." + +check_webpage "https://www.archlinux.org/download/" \ + "(?<=Included Kernel: )[\d\.]+" $LINUX_ARCHISO + +if [[ $? != 0 ]]; then + msg2 "Sending notification..." + send_email "Push the required packages to the archiso repo!" \ + "The archiso has been changed!" +else + msg2 "The archiso kernel version is current." +fi + +# +# Check linux kernel version +# +msg "Checking the online package database for linux kernel version changes..." + +check_webpage "https://www.archlinux.org/packages/core/i686/linux/" \ + "(?<=

linux )[\d\.-]+(?=

)" $LINUX_PKG_VER + +if [[ $? != 0 ]]; then + msg2 "Sending notification..." + send_email "Update the archzfs repository!" \ + "The linux package has been changed!" +else + msg2 "The linux kernel package is current." +fi + +# +# Check ZFSonLinux.org +# +msg "Checking zfsonlinux.org for new versions..." + +check_webpage "http://zfsonlinux.org/" \ + "(?<=zfsonlinux/spl/spl-)[\d\.]+(?=.tar.gz)" $ZOL_VER + +if [[ $? != 0 ]]; then + msg2 "Sending notification..." + send_email "Update the archzfs repository!" \ + "The ZOL packages have been changed!" +else + msg2 "The ZOL sources are current." +fi