puflogh300X74.gif

Polarwave's OpenBSD
Tips and Tricks for Newbies

| More Packages |

| Home | Tips and Tricks | Links | News Feeds | Fun | Contact | Blog (Opens in New Page) |


More Packages

Checking for Updated Packages

I used to think the packages for a six month release never changed, but that's not true.
I was reading a while back on the list where packages aren't currently being updated,
but I think it's due to mostly a lack of resources, not anyone just deciding they weren't
going to do it any longer. I do know in OpenBSD 4.1 I updated some packages about two
months ago. So, in the future, when there are again some package updates for whatever
particular version of OpenBSD you're running, you can try this script I kludged together
the other night. Like everything else I put up here, it's been tested. That's not to say
you might not run into problems. I didn't once I ironed out a few mistakes I'd made in it.
I got the idea originally from my favorite BSD guru, Dru Lavigne. The article is at:

Hack #51. Get the Most Out of FTP

Here's my version of ~/.netrc with the email changed to protect the guilty. :-)

machine rt.fm
login anonymous
password your@email
macdef obsd
bin
bell
prompt
cd pub/OpenBSD/4.1/packages/i386/
ls -l pkgdirlistnew.txt
bye
Where it says machine, you can change that to which ever server you prefer to use. Also,
the obsd can be changed to suit your taste. You don't have to have the bell either, I just
did it for the heck of it to learn and experiment with ftp stuff. I found it was much easier
to just cd to the path I wanted to do a listing of, so that's automated there, then the ls -l
command, and then get out with bye.

Below is the script I put together that uses the settings in ~/.netrc:
#!/bin/sh
#
echo $ obsd | ftp rt.fm
infile1=pkgdirlistnew.txt
infile2=pkgdirlist.txt
if [ ! -f $infile ]; then
     echo "Input file [$infile] not found"
     exit
fi
#
diff pkgdirlistnew.txt pkgdirlist.txt > /dev/null 2>&1
if [ $? -eq 0 ]; then
     echo "No Changes Today!"
     exit
fi
     echo "There are changes in directory listing!" && \
diff pkgdirlistnew.txt pkgdirlist.txt > `date +"%Y%m%d"`newchgs.txt
mail -s "`/bin/hostname` Package Changes" username < `date +"%Y%m%d"`newchgs.txt
     echo "Recent package changes in `date +"%Y%m%d"`newchgs.txt"
mv pkgdirlistnew.txt pkgdirlist.txt
So, here's what happens when you run the shell script ftpmac.sh:
Okay, all that being said, you can adapt this script to check on any server that allows
anonymous login and you can adapt it to check whatever you're looking for and testing
against. You just have to change the variables and testing directives. You don't have
to use the file names I've used for examples either, for packages. I just tried to name
them descriptively for examples. If you want to automate the check to be run on a
regular basis, you can run it as a cronjob. The example below would run ftpmac.sh
each Friday at 7:59 A.M.:
59      7     *     *      5     $HOME/bin/ftpmac.sh > /dev/null 2>&1
Back to Tips and Tricks
Home

Delicious Bookmark this on Delicious

No affiliation between this site and the OpenBSD project exists or is implied.

valid-html401.png