$ ! N E W S S K I M . C O M - DECUS UUCP Distribution version $ SET NOVERIFY $ SET PROCESS/NAME="news_skim" $ ON ERROR THEN GOTO ABORT $ GOTO START $ ! $ ! NEWSSKIM - the daily news management code. This code is submitted into $ ! the batch queues under the "news manager"'s account by news_systartup.com, $ ! and resubmits itself. The current code will resubmit for after 6 hours $ ! when run between 6 AM and 6 PM, and every hour at other times of the day. $ ! YOU MAY WISH TO MODIFY THE FINAL LINES OF THIS PROCEDURE TO VARY THE $ ! SUBMISSION TIMES AND INTERVALS. $ ! $ ! The code performs the following actions: $ ! 1 - read all items MAILED to RNEWS or NEWSMAIL, and add them $ ! 2 - delete (skim) all expired news items and expired newsgroups (daily) $ ! 3 - Generate IHAVE control messages to down stream sites as appropriate $ ! 4 - Distribute posted items to remote sites $ ! a) COPY post items to NEWSMGR proxies on remote DECNET nodes $ ! b) UUX_RNEWS via UUCP to send post items to adjacent UUCP sites $ ! 5 - If new UUCP maps have arrived, process them into a new paths $ ! database for proper mail routing (daily) $ ! 6 - resubmit for next run $ ! 7 - rebuilds the news index files on Sunday nights. (mornings) $ ! $ ! Author: $ ! G Huston $ ! Computer Services Centre $ ! Australian National University $ ! $ ! Version: $ ! V1.0 17-Jul-1986 $ ! V2.0 16-Jul-1987 $ ! V4.3 12-Jan-1987 GIH $ ! V5.2 26-Apr-1988 GIH $ ! V5.6 3-Nov-1988 GIH $ ! V5.7 12-Feb-1989 Mark Pizzolato - mark@infopiz.UUCP $ ! V5.7A 15-Apr-1989 Jamie Hanrahan - jeh@simpact.UUCP $ ! V5.7A-1 31-May-1989 Mark Pizzolato - mark@infopiz.UUCP $ ! V5.8 1-Jul-1989 Mark Pizzolato - mark@infopiz.UUCP $ ! V5.9 15-Oct-1989 Mark Pizzolato - mark@infopiz.UUCP $ ! V5.9B 2-Dec-1989 Mark Pizzolato - mark@infopiz.UUCP $ ! V5.9C 20-Dec-1989 Mark Pizzolato - mark@infopiz.UUCP $ ! Jamie Hanrahan - jeh@simpact.com $ ! Terry Poot - tp@mccall.com $ ! V6.0 30-Mar-1990 Geoff Huston - gih900@sao.aarnet.edu.au $ ! $ !********************************************************************** $ ! start code $ $ START: $ say = "write sys$output" $ say "NEWSSKIM starting at ''f$time()'" $ $ if f$search("news_manager:last_skim.time").eqs."" $ then $ new_day = "Y" ! file missing, assume first run ever $ else $ new_day = f$cvtime(,,"DAY") .nes. - f$cvtime(f$file("news_manager:last_skim.time","CDT"),,"DAY") $ endif $ ! $ ! Log the time ... $ ! $ copy nla0: news_manager:last_skim.time $ purge news_manager:last_skim.time $ rename news_manager:last_skim.time ;1 $ $ NEWS = "$NEWS_ROOT:NEWS" $ execqual = "" $ IF (f$logi("NEWS_EXECUTE_CONTROL")) THEN execqual = "/EXECUTE" $ cregrpqual = "" $ IF (f$logi("NEWS_AUTO_CREGRP")) THEN cregrpqual = "/CREGRP" $ $ oldprv = f$setprv("SYSPRV") $ if .not. f$privilege("SYSPRV") then exit $ start_time = f$time() $ set output_rate = :00:15 ! Allow a close watch to be kept $ $ ! $ ! Read all and remove locally addressed mail to NEWSMGR $ ! $ set noon $ say "Looking for items mailed to RNEWS or NEWSMAIL" $ mail set folder newmail extract/all news_manager:newmail.mail delete/all exit $ ! $ ! Place all extracted mail into the news data base $ ! $ if ((f$search("news_manager:news.batch").eqs."").and. - (f$search("news_manager:newmail.mail").eqs."")) then goto local_done $ rename news_manager:news.batch;* newmail.mail $ say "...Adding mailed and forwarded items to news file" $ news/noscreen Add Batch/delete'execqual' 'cregrpqual' news_manager:newmail.mail;* $ news/noscreen Add Batch/delete'execqual' 'cregrpqual' news_manager:news.batch;* $ local_done: $ say "Processing of mailed/forwarded items complete" $ $ ! ------------------- $ ! This section sets the default itemhold to 3 days, sets all groups to the $ ! default, and then sets all the groups that are actually registered to by $ ! users at this site to 7 days (with exceptions as shown). $ ! $ ! **** LOCAL CUSTOMIZATIONS ARE RECOMMENDED. **** $ ! $ ! This code will likely have problems if you're running an NNTP news server $ ! with clients at remote nodes. To disable this code, just change the $ ! first assignment to say "enable_this = 0" . $ ! $ ! Adapted from SET_ITEMHOLD.COM, written by $ ! Terry Poot (800)255-2762, in Kansas (913)776-4041 $ ! The McCall Pattern Company, 615 McCall Rd., Manhattan, KS 66502, USA $ ! UUCP: rutgers!ksuvax1!mccall!tp $ ! Internet: tp%mccall@ksuvax1.cis.ksu.edu $ $ enable_this = 0 $ if (enable_this .and. new_day .and. f$search("UUCP_BIN:SED.EXE") .nes. "") $ then $ $ ! make a couple of temp file names $ packtime = f$cvtime(,,"time")-":"-":"-"." $ temp = f$getjpi(0,"pid")+"."+packtime $ t1 = "t1"+temp $ t2 = "t2"+temp $ $ ! The following code must be able to find all the NEWSRC. files on your $ ! system. Adjust the filespec accordingly. If necessary, do several $ ! SEARCH commands and append the results together $ $ search USER_DISK:[*...]newsrc. "(1)"/noheaders/output='t1' $ sed :== "$uucp_bin:sed" $ define/user sys$output 't2' $ sed "s/:.*//" 't1' $ sort/noduplicates 't2' 't2' $ define/user sys$output 't1' $ $ ! *** Change the 7 to the number of days you want to keep groups to $ ! *** which people are registered at your site. $ $ sed "s/.*/SET NEWSGROUP ""&"" \/ITEMHOLD=7/" 't2' $ $ ! t1 now has the commands for the "registered" groups. We now put the $ ! commands to invoke news and set default itemholds in front of this... $ ! $ ! Change the 3 in the set newsgroup default command to the number of $ ! days you want to keep unregistered groups. $ $ create 't2' $ deck $ news/noscreen set newsgroup default/itemhold=3 ! Default item retention of 3 days set newsgroup */itemhold=0 ! Set all groups to use default $ eod $ append 't1' 't2' ! t2 now has "universal default" $ ! followed by special cases for $ ! registered groups. Next we add $ ! our own special cases. $ $ create 't1' ! set comp.mail.maps to 1 day, because it all gets extracted into uucp_path_data set newsgroup "comp.mail.maps"/itemhold=1 set newsgroup "comp.os.vms"/itemhold=14 ! keep this stuff for a bit longer set newsgroup "news.software.anu-news"/itemhold=* ! these we keep forever set newsgroup "vmsnet.*"/itemhold=* ! since we're working on this stuff exit $ eod $ append 't1' 't2' $ @'t2' $ delete 't1';* $ delete 't2';* $ $ endif $ $ ! --------------------- $ ! Skim -- remove expired items (the function for which this proc was $ ! originally named). $ ! It is a waste of time to perform more than 1 skim of the NEWS files per $ ! day (since the skim operation is solely concerned with deleting expired $ ! items, and items only expire based on time kept in whole days). $ $ if (new_day) $ then $ say "Skim Beginning at ''f$time()'" $ news/noscreen skim $ say "Skim Completed at ''f$time()'" $ endif $ $ ! --------------------- $ ! If it's close to the end of the month, run the arbitron and inpaths $ ! programs and mail the results to decwrl. $ $ host = f$logi("uucp_host_name") $ this_mo = f$cvtime(,"ABSOLUTE","MONTH") $ mmm_yyyy = f$edit(this_mo,"LOWERCASE")+" "+f$cvtime(,"ABSOLUTE","YEAR") $ $ ! Are we close enough to the end of the month? Find out how far away $ ! decwrl is (in hops), assume one day per hop, and see if that many $ ! days added to the current time would take us into the next month. $ $ uupath = "$uucp_bin:checkaddr" $ define/user sys$output temp.txt $ uupath foo@decwrl.dec.com $ open/read pathfile temp.txt $ read pathfile pathline $ close pathfile $ delete temp.txt; $ path = f$element(2, " ", pathline) $ if path.eqs."Can't" $ then $ day_of_month_ok = 0 ! no path to decwrl, can't do this stuff $ else $ nhops = 0 $count_bangs: $ if path .eqs. path - "!" then goto no_more $ nhops = nhops + 1 $ path = path - "!" $ goto count_bangs $no_more: $ ndays = f$string(nhops) ! assume one day per hop $ day_of_month_ok = this_mo .nes. - f$cvtime("+''ndays'-0:0:0", "ABSOLUTE", "MONTH") $ endif $ $ ! Have we done arbitron this month already? $ $ if (f$search("news_log:arbitron.out").eqs."") $ then $ ! ok if haven't done it before, at all. $ month_ok = 1 $ else $ ! ok if last month run is different from current month. $ month_ok = this_mo .nes. - f$cvtime(f$file("news_log:arbitron.out","CDT"),"ABSOLUTE","MONTH") $ endif $ $ if (day_of_month_ok .and. month_ok) $ then $ say "Arbitron Beginning at ''f$time()'" $ run uucp_bin:arbitron $ rename arbitron.out news_log: $ purge news_log:arbitron.out $ mail news_log:arbitron.out - /subj="Arbitron stats from site: ''host' for ''mmm_yyyy'" - uucp%"""netsurvey@decwrl.dec.com""",usenet $ say "Arbitron Completed at ''f$time()'" $ endif $ $ ! Pretty much the same for inpaths. File handling is slightly different. $ ! Have we done inpaths this month already? $ $ if (f$search("news_log:inpaths.out").eqs."") $ then $ ! ok if haven't done it before, at all. $ month_ok = 1 $ else $ ! ok if last month run is different from current month. $ month_ok = this_mo .nes. - f$cvtime(f$file("news_log:inpaths.out","CDT"),"ABSOLUTE","MONTH") $ endif $ $ if (day_of_month_ok .and. month_ok) $ then $ say "Inpaths beginning at ''f$time()'" $ inpaths := $uucp_bin:inpaths $ define/user sys$output news_log:inpaths.out $ inpaths 'host' $ purge news_log:inpaths.out $ mail/subject="INPATHS report from site: ''host' for ''mmm_yyyy'" - news_log:inpaths.out uucp%"""pathsurvey@decwrl.dec.com""",usenet $ say "Inpaths completed at ''f$time()'" $ endif $ $ ! --------------------- $ ! Check for errors in yesterday's rnews batch log files, mail results to $ ! local news manager $ ! $ if (new_day) $ then $ search news_log:rnews*.log/since=yesterday/before=today - "cannot open", "error:" - /outp=news_log:temp.txt $ if $status .eq. 1 $ then $ mail news_log:temp.txt usenet - /subject="Errors adding yesterday's news batches" $ endif $ delete news_log:temp.txt; $ endif $ $ ! --------------------- $ ! Post IHAVE, SENDME Control messages to other sites $ ! $ say "Looking for IHAVE control messages to send to other sites" $ mynode = f$trnlnm("NEWS_NODE") $ isearch_1: $ nodedir = f$search("news_manager:ihave_*.dir",2) $ if nodedir .eqs. "" then goto ihave_done $ node = f$parse(nodedir,,,"NAME","SYNTAX_ONLY") - "IHAVE_" $ savedfiles = "news_manager_dev:[ihave_" + node + "]*.*;*" $ isearch_2: $ file = f$search(savedfiles,4) $ if file .eqs. "" then goto isearch_1 $ cfile = f$element(0,";",file) $ say "...Posting 'ihave' messages in ''file' to newsgroup to.''node'" $ on error then goto isearch_2 $ on error then goto ino_copy_2 $ NEWS/NOSCREEN POST/NEWS=to.'node'/SUBJ="ihave ''mynode'" - /NOEDIT/CONTROL="ihave ''mynode'" 'file YES YES $ delete 'file $ ino_copy_2: $ goto isearch_2 $ ihave_done: $ say "IHAVE scan complete" $ ! $ !********************************************************************** $ ! Copy news items to other sites $ ! $ ! Search for all directories of the form: $ ! news_manager:post_.dir $ ! Copy all items in the node specific directory to the remote node $ ! Once all post directories have been found, delete all items in the $ ! post directory. this code assumes that for DECnet copies, proxies exist $ ! on remote nodes. $ ! $ ! The currently supported transmission modes are: $ ! a) Default - DECNET ala Base ANU NEWS distribution $ ! b) DECNET - Same as above, but explicitly stated. $ ! in both of the above cases, 'node' is the DECnet nodename. $ ! c) UUCP - UUCP copies to 'rnews' on the remote site. $ ! d) UUCP$CMPRS - Compressed batch UUCP copies to 'rnews' on the $ ! remote site. $ ! in both of the above cases, 'node' is the uucp hostname. $ ! e) COMMAND - Local site provided transport implemented by the $ ! file NEWS_TRANSPORT.COM in the directory $ ! NEWS_MANAGER_DEV:[POST_COMMAND_node]. This $ ! procedure is invoked with two arguments: $ ! P1 = node $ ! P2 = file to transport $ ! f) MAIL - Used for mail based feeds. The appropriate logical $ ! name must be defined in NEWSSKIM_LOGICALS.COM $ ! for the mail address of the news_manager account on $ ! the remote system. $ ! g) MLIST - Used for mailling list gateways. The appropriate $ ! logical name must be defined in NEWSSKIM_LOGICALS.COM $ ! for the mail address of the mailling list. $ ! in both of the above cases, 'node' is the uucp hostname. $ ! $ say "Searching for items to forward to other sites" $ set on $ compress = "$uucp_bin:compress" $ uux_rnews = "$uucp_bin:uux_rnews" $ if f$search("uucp_bin:gatenews.exe").nes."" then - gatenews = "$uucp_bin:gatenews" $ if f$search("news_manager:newsskim_logicals.com").nes."" then - @news_manager:newsskim_logicals $ $ search_1: $ nodedir = f$search("news_manager:post_*.dir",2) $ if nodedir .eqs. "" then goto transport_done $ $ node = f$parse(nodedir,,,"NAME","SYNTAX_ONLY") - "POST_" $ savedfiles = "news_manager_dev:[post_" + node + "]*.*;*" $ method = f$element(0,"_",node) + "_" $ node = node - method $ file = f$search(savedfiles,4) $ if file .eqs. "" then goto search_1 $ $ cfile = f$element(0,";",file) $ versions = f$integer(f$parse(file,,,"VERSION","SYNTAX_ONLY")-";") $ ver = 0 $ $ search_2: $ ver = ver + 1 $ if (ver.gt.versions) then goto search_1 $ $ file = cfile + ";" + f$string(ver) $ if f$search(file).eqs."" then goto search_2 $ $ say "...forwarding items in ''file' to ''node' via ''method'" $ on error then goto search_2 $ on error then goto no_copy_2 $ goto 'method'METHOD $ $ _METHOD: ! Default (Original ANU NEWS) Method is DECnet $ DECNET_METHOD: $ copy/log 'file 'node'::; $ goto delete_it $ $ UUCP$CMPRS_METHOD: ! Compressed UUCP NEWS batch $ compressed_file = file - f$parse(file,,,"VERSION") + "-COMPRESSED" $ compress -fcpv 'file' >'compressed_file' $ uux_rnews 'node' 'compressed_file' $ delete 'compressed_file'; $ goto delete_it $ $ UUCP_METHOD: ! Uncompressed UUCP NEWS batch $ compressed_file = file - f$parse(file,,,"VERSION") + "-COMPRESSED" $ uux_rnews 'node' 'file' $ goto delete_it $ $ COMMAND_METHOD: ! User Supplied Command file to effect delivery $ command = "NEWS_MANAGER_DEV:[POST_COMMAND_" + NODE + "]NEWS_TRANSPORT.COM" $ if f$search(command).nes."" $ then $ @'command' 'node' 'file' $ else $ say "No Delivery procedure NEWS_TRANSPORT.COM for ''NODE'" $ say "''file' preserved" $ goto no_copy_2 $ endif $ goto delete_it $ $ MAIL_METHOD: ! Outgoing mail based feeds $ mail/subject=newsfeed/noedit/noself 'file' 'node' $ say "News batch in ''file' mailed to ''node'" $ goto delete_it $ $ MLIST_METHOD: ! Outgoing news gateway to mailing lists $ if f$search("uucp_bin:gatenews.exe").nes."" $ then $ gatenews 'file' 'node' $ else $ say "No news/mlist gateway (uucp_bin:gatenews.exe) found" $ say "''file' preserved" $ goto no_copy_2 $ endif $ goto delete_it $ $ delete_it: $ delete 'file $ $ no_copy_2: $ goto search_2 $ $ transport_done: $ say "Item forwarding scan complete" $ $ ! ------------------- $ ! This section deals with the special case news group comp.mail.maps $ ! and assumes that an entry exists in the NEWS.SYS file of the following $ ! form: $ ! $ ! mapsink:world,na,usa,comp.mail.maps:B:NEWS_MANAGER_DEV/[UUCP_MAPS]mapsaver^M $ ! $ ! A related entry must exist in NEWS.DISTRIBUTION: (See the comments in $ ! both files) $ ! $ ! node_we_get_maps_from mapsink $ ! $ ! If no such entries exist, then this code is a noop. $ ! $ ! We only do the maps once a day, since rebuilding paths. is such a big job; $ ! it seems silly to do it when more maps might arrive later the same day. $ ! If maps arrive after the day's paths. build our paths. will be at most $ ! a day "old". Since it takes days or weeks for new map entries to filter $ ! through rutgers, to the regional map coordinators, back to rutgers, and $ ! finally through innumerable uucp news links to us, this is a non-problem. $ $ if .not. new_day then goto map_done $ ! $ ! any maps to do? $ ! $ if f$search("NEWS_MANAGER_DEV:[UUCP_MAPS]mapsaver.*").eqs."" - then goto map_cleanup $ ! $ ! $ say "Processing New UUCP Map Entries ", f$time() $ !! on warning then goto map_done $ on warning then goto map_error ! <- Point to map_error on warning. EFA $ ! $ ! Extract the newly arrived newsgroup entries (comp.mail.maps) into $ ! the UUCP_PATH_DATA directory. $ ! $ mapsaver := $uucp_bin:mapsaver $ mapsaver -vdnews_manager_dev:[uucp_maps] news_manager_dev:[uucp_maps]mapsaver.txt;* $ delete news_manager_dev:[uucp_maps]mapsaver.txt;* $ copy news_manager_dev:[uucp_maps]*.* uucp_path_data: $ delete news_manager_dev:[uucp_maps]*.*;* $ goto make_paths ! <- Add this line to jump around following code. EFA $ ! $ ! If the mapsaver function exits with an error, send a message to the $ ! postmaster informing him of this. EFA $ ! $ map_error: $ create temp.txt An error has occured during processing of the UUCP maps. Please check the files in news_manager_dev:[uucp_maps] to see what the problem was and correct it. Most likely an Unexpected EOF on input file has occured. $ mail temp.txt uucp_postmaster - /subj="UUCP map processing error" $ delete temp.txt; $ goto map_done $ ! $ ! Rebuild the PATHS database considering the new map entry data $ ! just provided. $ ! $ make_paths: ! <- Add this label. EFA $ say "...starting MAKEPATHS at ", f$time() $ @uucp_bin:makepaths $ say "...MAKEPATHS complete at ", f$time() $ ! what I really want to do is DIR /excl=;0, but that never finds ANY $ ! files for some reason. $ directory/outp=temp.txt uucp_data:paths,uucp_path_data:*.*;-1,;-2,;-3,;-4,;-5,;-6/dates/size $ set noon $ assign/user nla0: sys$output $ assign/user nla0: sys$error $ if f$search("uucp_log:pathalias.log").nes."" then - append uucp_log:pathalias.log temp.txt $ if f$search("uucp_log:pathalias.log").nes."" then - delete uucp_log:pathalias.log; $ set on $ mail temp.txt uucp_postmaster - /subj="Obsolete uucp maps; purge if no errors reported herein" $ delete temp.txt; $ $ ! adjust retention period of map entries in the newsgroup so they'll be $ ! deleted by tomorrow's SKIM. (They arrive with an Expires: header and will $ ! stick around for a long time otherwise, and they've already been $ ! "forwarded" to the map collection mechanism, and we don't need TWO $ ! copies of the maps!) We intentionally do this here, under control $ ! of the "on warning then goto map_done", so that if there are any $ ! problems in the map processing we won't delete any maps from the newsgroup $ ! until after the problems are fixed. $ $ map_cleanup: $ if f$search("news_device:[comp.mail.maps]*.itm") .nes. "" $ then $ news/noscreen select comp.mail.maps set item/hold=1 * exit $ endif $ $ map_done: $ $ on error then goto abort $ ! $ ! delete log files that are more than four days old. $ ! $ $ delete/log news_log:rnews*.*;*/before="-4-0:0:0" $ purge/log news_log:newsskim.log/before="-4-0:0:0" $ $ ! $ ! On Sunday nights, we clean up the index file structures by rebuilding them. $ ! $ ! never do this except on the first run of the day. $ ! force it to be done if we haven't done it for three weeks (in case $ ! system has been down on weekends, or something). $ ! under normal conditions, do this on the first run on sunday . $ $ if ( (f$cvtime(f$file_attributes("news_root:news.groups","CDT")).les. - f$cvtime("-21-00:00:00")) .or. - (f$cvtime("TODAY",,"WEEKDAY") .eqs. "Sunday") ) .and. - new_day $ then $ say "Starting rebuild of indexed files ", f$time() $ convert = "convert" $ ! Take a temp copy of news.groups and work on it $ backup/ign=interlock news_root:news.groups news_root:news.groupswork $ analyze/rms/fdl/output=news_root:newsgroups.fdl news_root:news.groupswork $ edit/fdl/analyze=news_root:newsgroups.fdl/nointer news_root:newsgroups.fdl $ convert/reclaim news_root:news.groupswork $ convert/fdl=news_root:newsgroups - news_root:news.groupswork news_root:news.groupswork $ rename news_root:news.groupswork news_root:news.groups $ delete news_root:news.groupswork;* $ purge news_root:news.groups $ purge news_root:newsgroups.fdl $ ! Take a temp copy of news.items and work on it $ backup/ign=interlock news_root:news.items news_root:news.itemswork $ analyze/rms/fdl/output=news_root:newsitems.fdl news_root:news.itemswork $ edit/fdl/analyze=news_root:newsitems.fdl/nointer news_root:newsitems.fdl $ convert/reclaim news_root:news.itemswork $ convert/fdl=news_root:newsitems.fdl - news_root:news.itemswork news_root:news.itemswork $ rename news_root:news.itemswork news_root:news.items $ delete news_root:news.itemswork;* $ purge news_root:news.items $ purge news_root:newsitems.fdl $ ! Take a temp copy of history.v60 and work on it $ backup/ign=interlock news_root:history.v60 news_root:history.v60work $ convert news_root:history.v60work news_root:history.v60work $ convert/reclaim news_root:history.v60work $ rename news_root:history.v60work news-root:history.v60 $ delete news_root:history.v60work;* $ purge news_root:history.v60 $ say "Indexed file rebuild complete ", f$time() $ endif $ $ abort: $ ! $ ! Normal and error exit - schedule next run $ ! $ ! SITE SPECIFIC CODE - MODIFY THIS ... for the desired interval $ ! $ ! This code will resubmit with a 6-hour delay when run $ ! between 6 AM and 6 PM, and every hour at other times of the day. $ ! $ Next_Time = f$cvtime("''start_time'+06:00:00","ABSOLUTE") $ if ((f$cvtime(start_time,,"HOUR").ge.18).or. - (f$cvtime(start_time,,"HOUR").lt.6)) then - Next_Time = f$cvtime("''f$time()'+01:00:00","ABSOLUTE") $ submit/noprint/log=NEWS_LOG:- /queue=NEWS_BATCH_QUEUE/after="''Next_Time'" - news_manager:newsskim.com $ exit