lbgm
geoff at desint.UUCP
geoff at desint.UUCP
Sat Dec 15 01:54:45 AEST 1984
From: geoff at desint.UUCP
I have discovered some other problems with the lbgm stuff. Please hold off
posting the stuff I sent yesterday. [ Oops - sorry, already posted - john]
Geoff Kuenning
...!ihnp4!desint!geoff
---------------------------------------------------------------------------
My problem with lbgm was directory permissions -- it hangs in an infinite
loop if /usr/lbgm doesn't have world write permission.
Following this message will be a shar of a fixed version of lbgm. This one
features a check for the infinite loop (it will send you mail if it can't
create the file after 100 tries) and an install script so people won't
make the same stupid mistake I make. Both have been tested.
-------------------------- cut here ---------------------------------------
: This is a shar archive. Extract with sh, not csh.
: The rest of this file will extract:
:
: README install lbgm zap.so lbgmX X
:
echo extracting - README
sed 's/^-//' > README << '/*EOF'
This directory contains a source-archiving system called "lbgm" (Little
Bird Gave Me). Responsible parties are:
lbgm Alan S. Watt
lbgmX Jim Ziobro
X "
zap.so "
csh protection Larry Wall
I have cleaned it up a bit to be more flexible and robust, and added an
installation script.
To install:
Run this shar archive to extract the programs.
If your system doesn't take #! syntax, edit the scripts to force /bin/sh
Define LBGMDIR and LBGMRM (see below) in your environment, or edit lbgmX
to define them the way you want them.
Run the install script.
LBGMDIR should be the directory you save sources in: default is /usr/lbgm if
nothing else is specified. LBGMRM is the program to remove unwanted sources;
define this to X (or a similar script/program) if you have delayed-deletion
facilities. It defaults to "/bin/rm -f" if unspecified.
That's all. You should not have to edit anything else, no matter what your
system is or where you keep news. News will be saved in the directory
you specify, and cataloged (by the Usenet header) in 'save.log'.
If garbage shows up on net.sources, simply type "s | zap.so" from readnews or
rn. When you exit, run $HOME/tozap to actually delete the articles (this
takes a while). Don't forget to remove tozap when you are done.
Geoff Kuenning
...!ihnp4!trwrb!desint!geoff
======================================================================
Alan Watt's comments [edited to change the script name to lbgm]:
I don't have space to save all news forever, but I decided some time
ago that net.sources was worth keeping around, hence "lbgm".
Usage is from you news "sys" file:
SOURCES:net.sources:B:/usr/lib/news/lbgm [ srcdir ]
where <srcdir> is where you want the stuff to go. In there will
appear the file "save.log", which contains the news header of
every news article saved, and files of the form:
${month}_${day}.${unique}
(as in "Apr_8.4552"), each file containing an article. The log
file will point to the saved article. There is a lockout against
concurrent runnings of lbgm.
You have to periodically go in by hand and delete obvious junk
(discussions and requests for stuff), and also to weed out which
version you want to keep if something is posted several times.
I have everything posted on net.sources since August 15th of last
year.
- Alan S. Watt
{decvax,duke,purdue,lbl-csam}!ittvax!swatt
======================================================================
Jim Ziobro's comments:
For those who keep archives of stuff from net.sources using an
Alan Watt lbgm (little bird gave me) style archive then you might
want a convenient way to delete the junk that may get saved there.
I have written some small scripts which make that job easier.
When you come across junk simply pipe the offending article into
zap.so and it creates a script which will remove the article from
your lbgm archive. After your finished reading news just invoke tozap
which was created by zap.so.
I have include Alan Watt's original article. As always please
keep me informed of enhancements or bugs.
/*EOF
chmod +x README
echo extracting - install
sed 's/^-//' > install << '/*EOF'
:
#! /bin/sh
export PATH || (echo "OOPS, this isn't sh. Desperation time. I will feed myself to sh."; sh $0; kill $$)
cat <<'EOF'
Installation script for the lbgm package.
You will have to provide the following information:
(1) Name of directory to save news in
(2) Name of news library directory
(3) Name of your bin directory
(4) Who to notify if problems occur
EOF
lbgmdir=${LBGMDIR:-/usr/lbgm}
echo 'Enter name of the directory news will be saved in ['"$lbgmdir"']:'
read lbgmdir
case X$lbgmdir in
X)
lbgmdir=/usr/lbgm
;;
*)
;;
esac
echo 'Enter name of the news library directory [/usr/lib/news]:'
read libdir
case X$libdir in
X)
libdir=/usr/lib/news
;;
*)
;;
esac
echo 'Enter the name of your bin directory ['"$HOME/bin"']:'
read bindir
case X$bindir in
X)
bindir="$HOME/bin"
;;
*)
;;
esac
NOTIFY=${USER:-"${LOGNAME:-root}"}
echo 'Who should be notified in case of trouble ['"$NOTIFY"']?'
read notify
case X$notify in
X)
notify="$NOTIFY"
;;
*)
;;
esac
echo 'End of questions. Installation begins.'
if test ! -d $lbgmdir
then
mkdir $lbgmdir || (echo Trouble creating $lbgmdir 1>&2; kill $$)
fi
set X `ls -ld $lbgmdir`
case $2 in
drwxrwxrwx)
;;
*)
chmod a+rwx $lbgmdir || \
(echo "Couldn't set modes for $lbgmdir" 1>&2; kill $$)
;;
esac
touch $lbgmdir/save.log || chmod a+rw $lbgmdir/save.log || \
(echo "Couldn't create $lbgmdir/save.log" 1>&2; kill $$)
(cp lbgm $libdir && chmod a+rx $libdir/lbgm) || \
(echo "Trouble installing lbgm in $libdir" 1>&2; kill $$)
(cp lbgmX zap.so $bindir && chmod a+rx $bindir/lbgmX $bindir/zap.so) || \
(echo "Trouble installing utilities in $bindir" 1>&2; kill $$)
grep '^SOURCES:' $libdir/sys >/tmp/ins$$
if test ! -s /tmp/ins$$
then
cat >> $libdir/sys <<EOF
#
# Automatic archiving of sources
#
SOURCES:mod.sources,net.sources:B:$libdir/lbgm $lbgmdir $notify
EOF
fi
echo 'Installation completed.'
echo ''
case $lbgmdir in
/usr/lbgm)
;;
*)
case X$LBGMDIR in
X)
cat <<'EOF'
You will have to add LBGMDIR to your environment before zap.so will work.
Use the following line:
EOF
case X$SHELL in
*/csh)
echo " setenv LBGMDIR $lbgmdir"
;;
*)
echo " LBGMDIR=$lbgmdir; export LBGMDIR"
;;
esac
;;
*)
;;
esac
;;
esac
case X$LBGMRM in
X)
cat <<EOF
If you have delayed-deletion facilities, you may also want to define LBGMRM
in your environment to be the name of the delayed-deletion facility. If you
do not have delayed deletion right now, but want it, put X into $bindir
EOF
cat <<'EOF'
and define LBGMRM to be X in your environment, and add the following line to
-/usr/lib/crontab:
45 4 * * * find / -name '#*' -atime +3 -print -exec rm -f {} \;
EOF
;;
*)
;;
esac
/*EOF
chmod +x install
echo extracting - lbgm
sed 's/^-//' > lbgm << '/*EOF'
#! /bin/sh
export PATH || (echo "OOPS, this isn't sh. Desperation time. I will feed myself to sh."; sh $0; kill $$)
: '/*********************************************************************
lbgm
Save sources sent over net.sources.
Called as a news forwarding program from inews
Alan S. Watt
Slightly modified by Geoff Kuenning
Sccsid="@(#)lbgm 1.1 8/15/82 (ITT) [hacked]"
usage:
lbgm [ savedir [ notify ] ]
arguments:
savedir Directory area to save sources (default
is /usr/lbgm).
notify User to notify in case of trouble (default
is root).
history:
08/15/82 original version
12/04/84 name changed
12/05/84 infinite loop check added, save.log set to a+w
*********************************************************************/'
: 'Public source directory (Little Bird Gave Me)'
sourcedir=${1-"/usr/lbgm"}
notify=${2-"root"}
: 'format of date command: "Sun Aug 15 15:56:06 EDT 1982"'
set `date`
mon=$2
day=$3
uniq=$$
tmp=LBGM.$$.tmp
logfile=save.log
: 'Lock the save source file and dump standard input there'
cd $sourcedir
>$tmp
limit=`expr $$ + 100`
while savefile="${mon}_${day}.$uniq"
do
if ln $tmp $savefile 2>&-
then
break
fi
uniq=`expr $uniq + 1`
if [ $uniq -gt $limit ]
then
(echo 'Trouble with lbgm - check directory permissions.
File header of unsaved article follows:
' ; sed -n '1,/^$/s/^/ /p') \
| mail $notify
exit 1
fi
done
cat >${savefile}
rm -f $tmp
: 'Dump the news header in a log file (up to a blank line)'
header="$savefile:
`sed -n '1,/^$/s/^/ /p' ${savefile}`"
echo "${header}" >>$logfile
chmod a+w $logfile
/*EOF
chmod +x lbgm
echo extracting - zap.so
sed 's/^-//' > zap.so << '/*EOF'
#!/bin/sh
export PATH || (echo "OOPS, this isn't sh. Desperation time. I will feed myself to sh."; sh $0; kill $$)
: Extract a Message-Id from a news file and prepend an lbgmX
: used to help keep lbgm archives clean
: called from readnews or rn with "s | zap.so"
: outputs a file $HOME/tozap
: archive can then be cleaned by invoking tozap
: "HISTORY"
: " 06-Sep-84 z at XEROX Henrietta "
: " Created by Jim Ziobro "
: " 04-Dec-84 geoff "
: " Add csh bulletproofing and protection against multiple message id's "
:
: extract Message-Id
awk 'BEGIN { FS = ":" }\
\
-/^[Mm][eE][sS][sS][aA][gG][eE]-[Ii][Dd]/ {\
printf("lbgmX \"%s\"\n", $2) ;\
exit;\
}\
'\
>> $HOME/tozap
chmod +x $HOME/tozap
/*EOF
chmod +x zap.so
echo extracting - lbgmX
sed 's/^-//' > lbgmX << '/*EOF'
#!/bin/sh
export PATH || (echo "OOPS, this isn't sh. Desperation time. I will feed myself to sh."; sh $0; kill $$)
: "lbgmX - X (remove) file with a message-id of $1 from a lbgm archive"
: "HISTORY"
: " 06-Sep-84 z at XEROX Henrietta "
: " Created by Jim Ziobro "
: " 04-Dec-84 geoff "
: " Made lbgmdir and RM overrideable from the environment, made "
: " default RM be /bin/rm -f. "
: " 05-Dec-84 geoff "
: " Made sure save.log is world-writeable "
:
lbgmdir=${LBGMDIR:-/usr/lbgm}
RM=${LBGMRM:-"/bin/rm -f"}
: lbgmdir is archive location
cd $lbgmdir
: get filename from Message-Id
filenam=`awk 'BEGIN { filid = "" ; FS = ":" }\
\
{\
if ( filid == "" ) filid = $1 ;\
if ( $0 ~ /^[ ]*$/ ) filid = "" ;
# line following blank has filename
}\
\
\
-/^ [Mm][eE][sS][sS][aA][gG][eE]-[Ii][Dd]:/ {\
if ( $2 == "'"$1"'" )\
print filid ;\
}\
' < save.log `
: "$filenam is filename to be purged from lbgm archive"
: remove the files
$RM *save.log
sed -e /$filenam"/,/^ $/d" < \#save.log > save.log
chmod a+w save.log
$RM $filenam
/*EOF
chmod +x lbgmX
echo extracting - X
sed 's/^-//' > X << '/*EOF'
#!/bin/sh
export PATH || (echo "OOPS, this isn't sh. Desperation time. I will feed myself to sh."; sh $0; kill $$)
:
: Simple delayed-deletion shell script
:
: Usage:
:
: X files
:
: You must also have a crontab entry of the form
:
: 45 4 * * * find / -name '#*' -atime +3 -print -exec rm -f {} \;
:
: to make sure the files get removed at a later date.
:
for i do mv $i \#$i; done
/*EOF
chmod +x X
exit
More information about the Mod.sources
mailing list