On 02/09/11 02:04, SJP Lists wrote:
On 9 February 2011 12:37, woolsherpahat<woolsherpa...@gmail.com>  wrote:
On 6 February 2011 05:23, Alessandro Baggi<alessandro.ba...@gmail.com>  wrote:
Hi List, i had registered me to the security list:
security-annou...@openbsd.org since 9 Genuary 2011, but any email come on my
account. Some that had security list subscribtion, can tell me if since
09/01/2001 at today there are mails?

I use a script which scrapes http://www.openbsd.org/errata48.html
daily and emails me the changes as they occur.


Shane

That sounds pretty cool... any chance you would be willing to share?

Okay, I'm probably not doing this the best way, so as embarrassing as
this is, it might hopefully get improved by someone...

#!/bin/sh
#
# OpenBSD_errata48.sh
#
# Check for any changes to the OpenBSD 4.8 Errata list and email
# an alert if so.


# Move the lastest successful OpenBSD errata grab so that is becomes
# the previous successful grab.

mv /home/scripts/OpenBSD_errata48_latest.txt \
    /home/scripts/OpenBSD_errata48_previous.txt

# Use lynx to just output to stdout the text of the OpenBSD Errata
# page, without a URL list.  Output the status to an error file so
# that sending bogus emails due to server being unavailable does not
# occur.
#
# Then filter out everything but the errata detail lines and output
# to a temporary file that will only be used if the web server status
# is "200 OK".

lynx -dump -nolist -error_file=/home/scripts/OBSD_errata48_err.txt \
  http://www.openbsd.org/errata48.html | egrep "^     \* ?|       ?" \
  >  /home/scripts/OpenBSD_errata48_current.txt

# Check the error status file to make sure the file was successfully
# retrieved.  If successful, procede with comparison between the
# current and previous errata, to determine whether an email should
# be sent.

if egrep " 200 OK" /home/scripts/OBSD_errata48_err.txt
then
     mv /home/scripts/OpenBSD_errata48_current.txt \
        /home/scripts/OpenBSD_errata48_latest.txt
     if ! diff /home/scripts/OpenBSD_errata48_latest.txt \
               /home/scripts/OpenBSD_errata48_previous.txt>  /dev/null
     then
         diff /home/scripts/OpenBSD_errata48_latest.txt \
              /home/scripts/OpenBSD_errata48_previous.txt \
              | egrep "^\<" | sed 's/\<       //g' \
              | tr -d "\n" | perl -pe 's/\* /\n\n/g' \
              | sed 's/  */ /g' \
              | mail -s "OpenBSD 4.8 Errata!" y...@yourdomain.net
     fi
else rm /home/scripts/OpenBSD_errata48_current.txt
fi

rm /home/scripts/OBSD_errata48_err.txt



Why not reuse existing functionality? Add your lynx command (which downloads file) to a crontab; then add filename to /etc/changelist

I've sometimes thought it would be nice to have the 'changelist' code extracted from /etc/security to a separate script so user-defined changes could be emailed to users other than root. Coding this is beyond my capabilities. I think this new script would need three parameters:
        - /etc/changelist       [list of files]
        - /var/backups          [dir for .backup and .current files]
        - root                  [user to receive email notifications]

For an adventurous coder; perhaps /etc/changelist would allow url's to monitor remote webpages.

Reply via email to