home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume1 / lbgm < prev    next >
Internet Message Format  |  1986-11-30  |  10KB

  1. Date: 5 Dec 84 16:37:20 CST (Wed)
  2. From: ihnp4!trwrb!desint!geoff
  3. Subject:  lbgm
  4.  
  5. : This is a shar archive.  Extract with sh, not csh.
  6. : The rest of this file will extract:
  7. :      README install lbgm zap.so lbgmX X
  8.  
  9. echo extracting - README
  10. sed 's/^-//' > README << '/*EOF'
  11.  
  12.     This directory contains a source-archiving system called "lbgm" (Little
  13. Bird Gave Me).  Responsible parties are:
  14.  
  15.     lbgm        Alan S. Watt
  16.     lbgmX        Jim Ziobro
  17.     X               "
  18.     zap.so           "
  19.     csh protection    Larry Wall
  20.  
  21. I have cleaned it up a bit to be more flexible and robust, and added an
  22. installation script.
  23.  
  24. To install:
  25.  
  26.     Run this shar archive to extract the programs.
  27.     If your system doesn't take #! syntax, edit the scripts to force /bin/sh
  28.     Define LBGMDIR and LBGMRM (see below) in your environment, or edit lbgmX
  29.       to define them the way you want them.
  30.     Run the install script.
  31.  
  32. LBGMDIR should be the directory you save sources in:  default is /usr/lbgm if
  33. nothing else is specified.  LBGMRM is the program to remove unwanted sources;
  34. define this to X (or a similar script/program) if you have delayed-deletion
  35. facilities.  It defaults to "/bin/rm -f" if unspecified.
  36.  
  37. That's all.  You should not have to edit anything else, no matter what your
  38. system is or where you keep news.  News will be saved in the directory
  39. you specify, and cataloged (by the Usenet header) in 'save.log'.
  40.  
  41. If garbage shows up on net.sources, simply type "s | zap.so" from readnews or
  42. rn.  When you exit, run $HOME/tozap to actually delete the articles (this
  43. takes a while).  Don't forget to remove tozap when you are done.
  44.  
  45.     Geoff Kuenning
  46.     ...!ihnp4!trwrb!desint!geoff
  47. ======================================================================
  48. Alan Watt's comments [edited to change the script name to lbgm]:
  49.  
  50. I don't have space to save all news forever, but I decided some time
  51. ago that net.sources was worth keeping around, hence "lbgm".
  52. Usage is from you news "sys" file:
  53.  
  54.     SOURCES:net.sources:B:/usr/lib/news/lbgm [ srcdir ]
  55.  
  56. where <srcdir> is where you want the stuff to go.  In there will
  57. appear the file "save.log", which contains the news header of
  58. every news article saved, and files of the form:
  59.  
  60.     ${month}_${day}.${unique}
  61.  
  62. (as in "Apr_8.4552"), each file containing an article.  The log
  63. file will point to the saved article.  There is a lockout against
  64. concurrent runnings of lbgm.
  65.  
  66. You have to periodically go in by hand and delete obvious junk
  67. (discussions and requests for stuff), and also to weed out which
  68. version you want to keep if something is posted several times.
  69. I have everything posted on net.sources since August 15th of last
  70. year.
  71.  
  72.     - Alan S. Watt
  73.     {decvax,duke,purdue,lbl-csam}!ittvax!swatt
  74.  
  75. ======================================================================
  76. Jim Ziobro's comments:
  77.  
  78.     For those who keep archives of stuff from net.sources using an
  79. Alan Watt lbgm (little bird gave me) style archive then you might
  80. want a convenient way to delete the junk that may get saved there.
  81.  
  82.     I have written some small scripts which make that job easier.
  83. When you come across junk simply pipe the offending article into
  84. zap.so and it creates a script which will remove the article from
  85. your lbgm archive.  After your finished reading news just invoke tozap
  86. which was created by zap.so.
  87.  
  88.     I have include Alan Watt's original article.  As always please
  89. keep me informed of enhancements or bugs.
  90. /*EOF
  91. chmod +x README
  92. echo extracting - install
  93. sed 's/^-//' > install << '/*EOF'
  94. :
  95. #! /bin/sh
  96.  
  97. export PATH || (echo "OOPS, this isn't sh.  Desperation time.  I will feed myself to sh."; sh $0; kill $$)
  98.  
  99. cat <<'EOF'
  100. Installation script for the lbgm package.
  101.  
  102. You will have to provide the following information:
  103.  
  104. (1) Name of directory to save news in
  105. (2) Name of news library directory
  106. (3) Name of your bin directory
  107. (4) Who to notify if problems occur
  108.  
  109. EOF
  110. lbgmdir=${LBGMDIR:-/usr/lbgm}
  111. echo 'Enter name of the directory news will be saved in ['"$lbgmdir"']:'
  112. read lbgmdir
  113. case X$lbgmdir in
  114.     X)
  115.     lbgmdir=/usr/lbgm
  116.     ;;
  117.     *)
  118.     ;;
  119. esac
  120.  
  121. echo 'Enter name of the news library directory [/usr/lib/news]:'
  122. read libdir
  123. case X$libdir in
  124.     X)
  125.     libdir=/usr/lib/news
  126.     ;;
  127.     *)
  128.     ;;
  129. esac
  130.  
  131. echo 'Enter the name of your bin directory ['"$HOME/bin"']:'
  132. read bindir
  133. case X$bindir in
  134.     X)
  135.     bindir="$HOME/bin"
  136.     ;;
  137.     *)
  138.     ;;
  139. esac
  140.  
  141. NOTIFY=${USER:-"${LOGNAME:-root}"}
  142. echo 'Who should be notified in case of trouble ['"$NOTIFY"']?'
  143. read notify
  144. case X$notify in
  145.     X)
  146.     notify="$NOTIFY"
  147.     ;;
  148.     *)
  149.     ;;
  150. esac
  151.  
  152. echo 'End of questions.  Installation begins.'
  153.  
  154. if test ! -d $lbgmdir
  155. then
  156.     mkdir $lbgmdir  ||  (echo Trouble creating $lbgmdir 1>&2; kill $$)
  157. fi
  158. set X `ls -ld $lbgmdir`
  159. case $2 in
  160.     drwxrwxrwx)
  161.     ;;
  162.     *)
  163.     chmod a+rwx $lbgmdir  ||  \
  164.       (echo "Couldn't set modes for $lbgmdir" 1>&2; kill $$)
  165.     ;;
  166. esac
  167.  
  168. touch $lbgmdir/save.log  ||  chmod a+rw $lbgmdir/save.log  ||  \
  169.   (echo "Couldn't create $lbgmdir/save.log" 1>&2; kill $$)
  170.  
  171. (cp lbgm $libdir  &&  chmod a+rx $libdir/lbgm)  ||  \
  172.   (echo "Trouble installing lbgm in $libdir" 1>&2; kill $$)
  173.  
  174. (cp lbgmX zap.so $bindir  &&  chmod a+rx $bindir/lbgmX $bindir/zap.so)  ||  \
  175.   (echo "Trouble installing utilities in $bindir" 1>&2; kill $$)
  176.  
  177. grep '^SOURCES:' $libdir/sys >/tmp/ins$$
  178. if test ! -s /tmp/ins$$
  179. then
  180.     cat >> $libdir/sys <<EOF
  181. #
  182. #    Automatic archiving of sources
  183. #
  184. SOURCES:mod.sources,net.sources:B:$libdir/lbgm $lbgmdir $notify
  185. EOF
  186. fi
  187.  
  188. echo 'Installation completed.'
  189. echo ''
  190. case $lbgmdir in
  191.     /usr/lbgm)
  192.     ;;
  193.     *)
  194.     case X$LBGMDIR in
  195.         X)
  196.         cat <<'EOF'
  197. You will have to add LBGMDIR to your environment before zap.so will work.
  198. Use the following line:
  199.  
  200. EOF
  201.         case X$SHELL in
  202.             */csh)
  203.             echo "    setenv LBGMDIR $lbgmdir"
  204.             ;;
  205.             *)
  206.             echo "    LBGMDIR=$lbgmdir; export LBGMDIR"
  207.             ;;
  208.         esac
  209.         ;;
  210.         *)
  211.         ;;
  212.     esac
  213.     ;;
  214. esac
  215. case X$LBGMRM in
  216.     X)
  217.     cat <<EOF
  218.  
  219. If you have delayed-deletion facilities, you may also want to define LBGMRM
  220. in your environment to be the name of the delayed-deletion facility.  If you
  221. do not have delayed deletion right now, but want it, put X into $bindir
  222. EOF
  223.     cat <<'EOF'
  224. and define LBGMRM to be X in your environment, and add the following line to
  225. -/usr/lib/crontab:
  226.  
  227.     45 4 * * * find / -name '#*' -atime +3 -print -exec rm -f {} \;
  228. EOF
  229.     ;;
  230.     *)
  231.     ;;
  232. esac
  233. /*EOF
  234. chmod +x install
  235. echo extracting - lbgm
  236. sed 's/^-//' > lbgm << '/*EOF'
  237. #! /bin/sh
  238.  
  239. export PATH || (echo "OOPS, this isn't sh.  Desperation time.  I will feed myself to sh."; sh $0; kill $$)
  240.  
  241. : '/*********************************************************************
  242.     lbgm
  243.         Save sources sent over net.sources.
  244.         Called as a news forwarding program from inews
  245.  
  246.     Alan S. Watt
  247.     Slightly modified by Geoff Kuenning
  248.    
  249.     Sccsid="@(#)lbgm    1.1 8/15/82 (ITT) [hacked]"
  250.  
  251.     usage:
  252.         lbgm [ savedir [ notify ] ]
  253.  
  254.     arguments:
  255.         savedir        Directory area to save sources (default
  256.                 is /usr/lbgm).
  257.         notify        User to notify in case of trouble (default
  258.                 is root).
  259.    
  260.     history:
  261.         08/15/82    original version
  262.         12/04/84    name changed
  263.         12/05/84    infinite loop check added, save.log set to a+w
  264.    *********************************************************************/'
  265.  
  266. : 'Public source directory (Little Bird Gave Me)'
  267. sourcedir=${1-"/usr/lbgm"}
  268. notify=${2-"root"}
  269.  
  270. : 'format of date command: "Sun Aug 15 15:56:06 EDT 1982"'
  271. set `date`
  272. mon=$2
  273. day=$3
  274. uniq=$$
  275. tmp=LBGM.$$.tmp
  276. logfile=save.log
  277.  
  278. : 'Lock the save source file and dump standard input there'
  279. cd $sourcedir
  280. >$tmp
  281. limit=`expr $$ + 100`
  282. while savefile="${mon}_${day}.$uniq"
  283. do
  284.     if ln $tmp $savefile 2>&-
  285.     then
  286.         break
  287.     fi
  288.     uniq=`expr $uniq + 1`
  289.     if [ $uniq -gt $limit ]
  290.     then
  291.         (echo 'Trouble with lbgm - check directory permissions.
  292. File header of unsaved article follows:
  293. ' ; sed -n '1,/^$/s/^/    /p') \
  294.             | mail $notify
  295.         exit 1
  296.     fi
  297. done
  298. cat >${savefile}
  299. rm -f $tmp
  300.  
  301. : 'Dump the news header in a log file (up to a blank line)'
  302. header="$savefile:
  303. `sed -n '1,/^$/s/^/    /p' ${savefile}`"
  304. echo "${header}" >>$logfile
  305. chmod a+w $logfile
  306. /*EOF
  307. chmod +x lbgm
  308. echo extracting - zap.so
  309. sed 's/^-//' > zap.so << '/*EOF'
  310. #!/bin/sh
  311.  
  312. export PATH || (echo "OOPS, this isn't sh.  Desperation time.  I will feed myself to sh."; sh $0; kill $$)
  313.  
  314. : Extract a Message-Id from a news file and prepend an lbgmX
  315. : used to help keep lbgm archives clean
  316. : called from readnews or rn with "s | zap.so"
  317. : outputs a file $HOME/tozap
  318. : archive can then be cleaned by invoking tozap
  319. : "HISTORY"
  320. : " 06-Sep-84  z at XEROX Henrietta "
  321. :    " Created by Jim Ziobro "
  322. : " 04-Dec-84  geoff "
  323. :    " Add csh bulletproofing and protection against multiple message id's "
  324. :
  325.  
  326. : extract Message-Id
  327. awk  'BEGIN { FS = ":" }\
  328. \
  329. -/^[Mm][eE][sS][sS][aA][gG][eE]-[Ii][Dd]/    {\
  330.     printf("lbgmX \"%s\"\n", $2) ;\
  331.     exit;\
  332.     }\
  333.     '\
  334.     >> $HOME/tozap 
  335.  
  336. chmod +x $HOME/tozap
  337. /*EOF
  338. chmod +x zap.so
  339. echo extracting - lbgmX
  340. sed 's/^-//' > lbgmX << '/*EOF'
  341. #!/bin/sh
  342.  
  343. export PATH || (echo "OOPS, this isn't sh.  Desperation time.  I will feed myself to sh."; sh $0; kill $$)
  344.  
  345. : "lbgmX - X (remove) file with a message-id of $1 from a lbgm archive"
  346. : "HISTORY"
  347. : " 06-Sep-84  z at XEROX Henrietta "
  348. :    " Created by Jim Ziobro "
  349. : " 04-Dec-84  geoff "
  350. :    " Made lbgmdir and RM overrideable from the environment, made "
  351. :    " default RM be /bin/rm -f. "
  352. : " 05-Dec-84  geoff "
  353. :    " Made sure save.log is world-writeable "
  354. :
  355.  
  356. lbgmdir=${LBGMDIR:-/usr/lbgm}
  357. RM=${LBGMRM:-"/bin/rm -f"}
  358. : lbgmdir is archive location
  359. cd $lbgmdir
  360.  
  361. : get filename from Message-Id
  362. filenam=`awk  'BEGIN { filid = "" ; FS = ":" }\
  363. \
  364.     {\
  365.     if ( filid == "" ) filid = $1 ;\
  366.     if ( $0 ~ /^[     ]*$/ ) filid = "" ;
  367.     # line following blank has filename
  368.     }\
  369. \
  370. \
  371. -/^    [Mm][eE][sS][sS][aA][gG][eE]-[Ii][Dd]:/    {\
  372.     if ( $2 == "'"$1"'" )\
  373.     print filid ;\
  374.     }\
  375.     ' < save.log `
  376.  
  377. : "$filenam is filename to be purged from lbgm archive"
  378. : remove the files
  379. $RM *save.log
  380. sed -e /$filenam"/,/^    $/d" < \#save.log > save.log
  381. chmod a+w save.log
  382. $RM $filenam
  383. /*EOF
  384. chmod +x lbgmX
  385. echo extracting - X
  386. sed 's/^-//' > X << '/*EOF'
  387. #!/bin/sh
  388.  
  389. export PATH || (echo "OOPS, this isn't sh.  Desperation time.  I will feed myself to sh."; sh $0; kill $$)
  390.  
  391. :
  392. :    Simple delayed-deletion shell script
  393. :
  394. :    Usage:
  395. :
  396. :    X files
  397. :
  398. :    You must also have a crontab entry of the form
  399. :
  400. :    45 4 * * * find / -name '#*' -atime +3 -print -exec rm -f {} \;
  401. :
  402. :    to make sure the files get removed at a later date.
  403. :
  404. for i do mv $i \#$i; done
  405. /*EOF
  406. chmod +x X
  407. exit
  408.  
  409.  
  410.  
  411.  
  412.