Article View: comp.mail.misc
Article #4820My script for mapfiles/pathalias updating
From: j eric townsend
Date: Sat, 25 Jun 1988 07:59
Date: Sat, 25 Jun 1988 07:59
73 lines
2950 bytes
2950 bytes
Several people have asked about automating their mapfiles/pathalias
stuff. I finally got around to commenting my script for uploading.
I run it with a cron entry of:
30 2 * * * /bin/su root -c "/u/bin/demap.sh | mail erict"
It has a whole *TWO* debugging status statements. The first states
that the script has run (and gives the date/time), the second
only gets sent if the pathalias database was updated. I just
mail 'em to myself for fun and profit. :-)
Here it is:
(Shar? Who needs a shar?)
# History:
# demap.sh 7Jun88 JET -- wrote initial script
# 20Jun88 JET -- fixed the stupid find statement for pathalias database.
# 25Jun88 JET -- commented the script so others would be able to follow.
# erict@flatline.UUCP
# A really kludgey version that probably takes forever to run...
# but it was quick n dirty to write...
echo "demap.sh run at" `date`
cd /usr/lib/mail/maps
# This pulls the maps from their spool/news directory, cleans them
# up, and puts them into the map directory...
# LastCheck is an empty file that I use as a date-keeper for the
# last time the spool directory was checked for new maps.
for i in `find /usr/spool/news/comp/mail/maps -type f \
-newer /usr/lib/mail/maps/LastCheck -print`
do
sed -e "/^From: /D" -e "/^Path: /D" -e "/^Newsgroups: /D" -e "/^From /D" -e "/^Subject: /D" -e "/^Message-ID: /D" -e "/^Date: /D" -e "/^Expires: /D" -e "/^Sender: /D" -e "/^Lines: /D" -e "/^Approved: /D" -e "/^Supersedes: /D" $i \
| sh
done
touch /usr/lib/mail/maps/LastCheck
# do pathalias stuff
# thanks to apt@uhnix2.uh.edu (Alan Pfeiffer-Traum) for the find trick.
# this will rebuild the pathalias/smail database *if*, and only *if*
# new map files were processed.
latest_files=`find /usr/lib/mail/maps/[d,u]* -newer /usr/lib/mail/paths -print`
if [ -n "$latest_files" ]
then
echo "Updating pathalias database."
cd /usr/lib/mail/maps
cat dir.form d.* u.* | pathalias -l flatline > /tmp/pathalias
cd /usr/lib/mail
mv paths paths.old
sort /tmp/pathalias > paths
chmod a+r paths
rm /tmp/pathalias
fi
Anyone who thinks they can do this better, please post your script.
Again, this is most definately a mondo-jock kludge. But, it works. :-)
--
Skate UNIX or go home, boogie boy...
"But why should I type "rm -r $HOME" if I want to play trek???"
J. Eric Townsend ->uunet!nuchat!flatline!erict smail:511Parker#2,Hstn,Tx,77007
..!bellcore!tness1!/
Technical Details
Message-ID:
<957@flatline.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!ames!killer!tness7!tness1!flatline!erictShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!ames!killer!tness7!tness1!flatline!erict From: erict@flatline.UUCP (j eric townsend) Newsgroups: comp.mail.misc,news.sysadmin Subject: My script for mapfiles/pathalias updating Keywords: pathalias, maps, update, script Message-ID: <957@flatline.UUCP> Date: 25 Jun 88 07:59:58 GMT Organization: a flat near the Montrose, Houston, Tx. Lines: 73