home *** CD-ROM | disk | FTP | other *** search
/ back2roots/padua / padua.7z / padua / uucp / auucp+-1.02 / fuucp_plus_src.lzh / unsharmap / unsharmap.Z / unsharmap
Encoding:
Text File  |  1990-11-21  |  42.4 KB  |  1,536 lines

  1. Article 1644 of sub.config:
  2. Path: xenon!nadia!doitcr!tmpmbx!mcshh!artcom0!pf
  3. From: pf@artcom0.artcom.north.de (Peter Funk)
  4. Newsgroups: sub.config,dnet.and.sub.general
  5. Subject: REPOST: unpack-map Paket
  6. Summary: unsharmap -- Dank makefile auf Xenix kinderleicht zu installieren
  7. Keywords: Mail-Maps, Automatik, Aktualisierung
  8. Message-ID: <2062@artcom0.artcom.north.de>
  9. Date: 1 Jun 90 00:31:19 GMT
  10. Followup-To: poster
  11. Distribution: sub,dnet
  12. Organization: ArtCom GmbH, Atelier f. Computergrafik, Bremen(FRG)
  13. Lines: 1519
  14. Flames-To: poster
  15.  
  16. Da ich auf meine Ankuendigung kein Gemeckere und nur Zustimmung gehoert
  17. habe, hier der REPOST des 'unsharmap'-Paketes.  Die Installation ist
  18. zumindest unter SCO Xenix 386 kinderleicht.  Wer schon 'nn6.4' laufen
  19. hat, braucht jetzt nur ':unshar' einzutippen und dann in dem 
  20. betreffenden Directory 'make' aufzurufen.
  21.  
  22. Okay, hier isses ...
  23.  
  24. #    Dies ist ein UNIX-Shell Archiv.
  25. #    Loesche alles ueber und einschliesslich der Schnittzeile.
  26. #    Dann lasse den Rest der Datei durch sh laufen.
  27. #----schnitt-----schnippel-----fetz-----reiz-----schnitz----
  28. : /bin/sh
  29. # shar:    UNIX-Shell Archivier-Programm
  30. #    Bei Ausfuehrung dieses Textes durch /bin/sh enstehen die Dateien :
  31. #    README
  32. #    map.daily
  33. #    mkpaths
  34. #    Makefile
  35. #    unsharmap.c
  36. #    install
  37. #    avoid-unido
  38. #    getmap
  39. #    patch.README
  40. # Dieses Archiv wurde erzeugt : Fri Jun  1 02:28:27 1990
  41. echo shar: Extraktion von README
  42. sed 's/^Z //' << \----SHAR-EOF---- > README
  43. Z #  Title    : README - unpack-map
  44. Z #  Version      :       Sat, 26-May-90 / 12:55 / (pf@artcom0)
  45. Z Das Paket 'unpack-map' dient zum automatischen Aktualisieren der
  46. Z EMail-Routing Database (/usr/lib/uucp/paths) anhand der regelmaessigen
  47. Z Postings in 'sub.config.maps'.
  48. Z Ich habe dieses Unsharmap-Paket hier an meine speziellen
  49. Z SCO-Xenix 386 Beduerfnisse und meine Directory-Struktur 
  50. Z angepasst und zwecks leichterer Installation um ein paar
  51. Z Shell-Skripte und ein Makefile erweitert.  Das in der
  52. Z Original-Version mitgelieferte Skript 'getmap' wird
  53. Z hier nicht mehr benoetigt, ist aber aus Gruenden
  54. Z der Vollstaendigkeit dabei belassen.  Wer es so wie
  55. Z ich nicht braucht, kann es einfach loeschen. 
  56. Z Die Installation ist sehr einfach, wenn man sowieso schon 'smail2.5',
  57. Z 'pathalias' und 'news' laufen hat. :
  58. Z     make
  59. Z     make install 
  60. Z     make clobber
  61. Z Danach kann man dieses Directory wieder einpacken und irgendwo
  62. Z verstauen.  Will man die eintrudelden Maps kontrollieren,
  63. Z kann man dies tun, da sie im Verzeichnis /usr/lib/uucp/maps/work
  64. Z stehen bleiben.  Erst durch 'map.daily' werden sie an Ort und
  65. Z Stelle 'gemoved' und dann eine neue 'paths'-Datei generiert.
  66. Z Vertraut man der Moderation von 'sub.config.maps', kann man
  67. Z einfach wie ich das 'map.daily' in die 'root'-crontab eintragen.
  68. Z Wer trotzdem auf Nummer sicher gehen will, kann sich ein Directory
  69. Z /usr/lib/uucp/oldmaps einrichten, in dem man eine gewisse Anzahl
  70. Z von Sicherheitskopien alter (vorhergehender) Maps aufbewahren kann.
  71. Z Details dazu sind in 'map.daily' dokumentiert.
  72. Z Einige Geschmackssachen (oder Portabilitaetsprobleme) :
  73. Z -------------------------------------------------------
  74. Z Ein Veraendern des Paketes auf eine andere Directory-Struktur
  75. Z (bei mir stehen die benutzten Maps alle in /usr/lib/uucp/maps und
  76. Z das Executable in /usr/local/bin) sollte Dank der SHELL-Variablen
  77. Z mit maessigem Editier-Aufwand moeglich sein. 
  78. Z Veraendert werden muessten dazu die Dateien :
  79. Z     install
  80. Z     map.daily
  81. Z     mkpaths
  82. Z Wenn man 'C'-News hat, wird das 'sys'-File vielleicht sonstwo liegen.
  83. Z Dann muss man dies natuerlich auch in 'install' abaendern.
  84. Z --
  85. Z Peter Funk  / ArtCom GmbH, Schwachhauser Heerstr. 78, D-2800 Bremen 1
  86. Z Work at home/ Oldenburger Str.86, D-2875 Ganderkesee 1 /+49 4222 6018 (8am-6pm)
  87. Z pf@artcom0.artcom.north.de
  88. ----SHAR-EOF----
  89. if test 2252 -ne "`wc -c README`"
  90. then
  91. echo shar: Uebertragungsfehler in README '(Soll-Laenge = 2252 Zeichen)'
  92. fi
  93. echo shar: Extraktion von map.daily
  94. sed 's/^Z //' << \----SHAR-EOF---- > map.daily
  95. Z :
  96. Z # ------------------------------------------------------------------
  97. Z #  Title    : map.daily -- automatically install new maps
  98. Z #  Usage    : map.daily [ -v ] [ -V ]
  99. Z #  Options    :     -v : Verbose mode, show up "no op" invocation
  100. Z #            -V : Very Verbose Mode
  101. Z #  Version      :       Sat, 26-May-90 / 11:45 / (root@artcom0)
  102. Z #  Remarks    : You may create a directory /usr/lib/uucp/oldmaps
  103. Z #              with some numerical named subdirectories. e.g.
  104. Z #          /usr/lib/uucp/oldmaps/0
  105. Z #              /usr/lib/uucp/oldmaps/1 ...
  106. Z #          Older maps will be preserved there. 
  107. Z #              These directories should be owned by 'news' and
  108. Z #          should also have write-Permissions, if You don't
  109. Z #          want to run this script here under 'root' !
  110. Z #          If you don't trust new maps, You may also choose
  111. Z #          the '-V' option, and You will get a diff mail,
  112. Z #          whenever there are new maps arrived !
  113. Z # ------------------------------------------------------------------
  114. Z if [ "$1" = "-v" ]
  115. Z then VERBOSE=TRUE
  116. Z      shift
  117. Z else VERBOSE=
  118. Z fi
  119. Z if [ "$1" = "-V" ]
  120. Z then VERBOSE=Talkative
  121. Z      shift
  122. Z fi
  123. Z MAPDIR=/usr/lib/uucp/maps
  124. Z OLDMAPS=/usr/lib/uucp/oldmaps
  125. Z cd $MAPDIR/work
  126. Z # --- Do the installation
  127. Z NEWMAPS=
  128. Z for i in * ; do
  129. Z     if [ "$i" = "*" ]
  130. Z     then if [ "$VERBOSE" ]
  131. Z      then echo "No new maps arrived !"  
  132. Z      fi 
  133. Z      exit 0
  134. Z     fi
  135. Z     # -- preserve old maps 
  136. Z     for olddirnum in 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 ; do
  137. Z     OLDMAPDIR=$OLDMAPS/$olddirnum
  138. Z     if [ -d $OLDMAPDIR ]
  139. Z     then if [ $olddirnum -gt 0 ]
  140. Z          then prevdirnum=`expr $olddirnum - 1`
  141. Z           PREVDIR=$OLDMAPS/$prevdirnum
  142. Z          else PREVDIR=$MAPDIR
  143. Z          fi
  144. Z          if [ -f $PREVDIR/$i ]
  145. Z          then mv $PREVDIR/$i $OLDMAPDIR/$i
  146. Z          fi
  147. Z     fi
  148. Z     done
  149. Z     mv $i $MAPDIR
  150. Z     NEWMAPS="$NEWMAPS $i"
  151. Z done
  152. Z # -- mail significant map changes as diff to the postmaster :
  153. Z if [ "$VERBOSE" = "Talkative" ] && [ -d $OLDMAPS/0 ]
  154. Z then if [ -x /usr/local/bin/gdiff ]
  155. Z      then /usr/local/bin/gdiff -r -c $OLDMAPS/0 $MAPDIR
  156. Z      else cd $MAPDIR
  157. Z       for i in $NEWMAPS ; do
  158. Z           if [ -r $OLDMAPS/0/$i ]
  159. Z           then echo "--- $i Differences: ---"
  160. Z            diff $OLDMAPS/0/$i $i
  161. Z           else echo "--- $i is a new map file ! ---"
  162. Z           fi
  163. Z       done
  164. Z      fi | mail -s "Map Changes" postmaster
  165. Z fi
  166. Z # -- regenerate the paths database :
  167. Z cd $MAPDIR
  168. Z ./mkpaths
  169. ----SHAR-EOF----
  170. if test 2232 -ne "`wc -c map.daily`"
  171. then
  172. echo shar: Uebertragungsfehler in map.daily '(Soll-Laenge = 2232 Zeichen)'
  173. fi
  174. echo shar: Extraktion von mkpaths
  175. sed 's/^Z //' << \----SHAR-EOF---- > mkpaths
  176. Z : use /bin/sh
  177. Z # ------------------------------------------------------------------------------
  178. Z #  Title    : mkpaths -- Create a new paths data base from diverse map files
  179. Z #  Version      :       Sat, 26-May-90 / 11:29 / (pf@artcom0)
  180. Z #  Portability  : Bourne Shell SCO Xenix 2.3
  181. Z #  Usage    : mkpaths [ "test" [ <rechnername> ] ]
  182. Z #    Durch den Aufruf 'mkpaths test kiste' kann man sich die von 'kiste'
  183. Z #    aus generierten Pfade im Pager anschauen.  Das ist manchmal ganz 
  184. Z #    praktisch.
  185. Z # ------------------------------------------------------------------------------
  186. Z PATH="$PATH:/usr/local/bin"
  187. Z MAPDIR=/usr/lib/uucp/maps
  188. Z PATHS=/usr/lib/uucp/paths
  189. Z if [ -x /usr/local/bin/less ]
  190. Z then PAGER="/usr/local/bin/less -e"
  191. Z else PAGER=more
  192. Z fi
  193. Z # --- Es gibt die Konvention, das alle Pathalias Eingabe-Dateien mit 
  194. Z #     'd.' oder 'u.' beginnen. 
  195. Z #     Die Map-Dateien des 'Sub-Netzes' heissen 'u.sub.*'. 
  196. Z #     Lokale Map-Daten sollte man in 'u.local' halten.
  197. Z MAPS="u.* d.*"
  198. Z # --- Wenn kein Rechnername angegeben ist, dann benutze das 'uuname'-Kommando
  199. Z #     (Wie geht das auf NICHT-Xenix Systemen ?)
  200. Z if [ "$2" ]
  201. Z then HOST=$2
  202. Z else HOST=`uuname -l`
  203. Z fi
  204. Z # ---
  205. Z cd $MAPDIR
  206. Z echo ".UUCP    %s" > paths
  207. Z pathalias -l $HOST $MAPS | /bin/sort >> paths
  208. Z if [ "$1" != "test" ]
  209. Z then # -- The following 'cat' will preserve permissions and links to the
  210. Z      #    system path data base, which would have been lost, if we had used
  211. Z      #    a simple 'mv paths $PATHS' ...
  212. Z      cat paths > $PATHS
  213. Z      rm -f paths
  214. Z      # -- The following is just for safety (If 'paths' did not exist before !) :
  215. Z      chown mail $PATHS ; chgrp news $PATHS ; chmod 664 $PATHS 
  216. Z else # -- Don't install 'paths', just view it :
  217. Z      chmod +r paths
  218. Z      $PAGER paths
  219. Z      # You may consider to remove the paths file afterwards :
  220. Z      # rm -f paths 
  221. Z      mv paths /tmp/paths.$HOST
  222. Z      exit 0
  223. Z fi
  224. ----SHAR-EOF----
  225. if test 1826 -ne "`wc -c mkpaths`"
  226. then
  227. echo shar: Uebertragungsfehler in mkpaths '(Soll-Laenge = 1826 Zeichen)'
  228. fi
  229. echo shar: Extraktion von Makefile
  230. sed 's/^Z //' << \----SHAR-EOF---- > Makefile
  231. Z # Makefile for unsharmap under SCO XENIX 386
  232. Z #
  233. Z #  Version      :       Wed, 16-May-90 / 19:11 / (pf@artcom0)
  234. Z #    Documented for net distribution.
  235. Z # Things to do:
  236. Z #    make            make executables
  237. Z #    make all         "       "
  238. Z #    make install        perform XENIX installation
  239. Z #    make clean        cleanup this directory
  240. Z #    make clobber        clean ...and remove executables from this dir
  241. Z #     make shar        create a file 'unpack-map.sha'
  242. Z SHELL=        /bin/sh
  243. Z CFLAGS    =    -O
  244. Z OBJECTS =    unsharmap.o
  245. Z all:        unsharmap
  246. Z unsharmap:    $(OBJECTS)
  247. Z         cc $(CFLAGS) $(OBJECTS) -o unsharmap
  248. Z $(OBJECTS):
  249. Z         cc $(CFLAGS) -c $<
  250. Z clean:
  251. Z         rm -f *.o *.ln a.out core
  252. Z clobber:    clean
  253. Z         rm -f unsharmap 
  254. Z install:    all 
  255. Z         ./install
  256. Z shar:        
  257. Z         shar -cgvp'Z ' README map.daily mkpaths Makefile \
  258. Z                 unsharmap.c install avoid-unido \
  259. Z                 getmap patch.README > unpack-map.sha
  260. ----SHAR-EOF----
  261. if test 801 -ne "`wc -c Makefile`"
  262. then
  263. echo shar: Uebertragungsfehler in Makefile '(Soll-Laenge = 801 Zeichen)'
  264. fi
  265. echo shar: Extraktion von unsharmap.c
  266. sed 's/^Z //' << \----SHAR-EOF---- > unsharmap.c
  267. Z /* @(#)unsharmap.c    1.6 2/5/89 14:14:01 */
  268. Z /*
  269. Z  *    Copyright (C) 1988 Ronald S. Karr and Landon Curt Noll
  270. Z  * 
  271. Z  * See the file COPYING, distributed with smail, for restriction
  272. Z  * and warranty information.
  273. Z  */
  274. Z /*
  275. Z  * unsharmap - unshar a USENET comp.news.maps article
  276. Z  *
  277. Z  * usage:  unsharmap [-d dir] < filelist > log
  278. Z  *
  279. Z  *       -d dir    - cd to 'dir' before unsharing
  280. Z  *       -n newsgroups - colon separated list of allowed newsgroups
  281. Z  *       -p        - use stdin (for piped input from 'sys')
  282. Z  *
  283. Z  * where "filelist" contains a list of files that are in the format below.
  284. Z  *
  285. Z  * The USENET map project distributes files in the following format:
  286. Z  *
  287. Z  * The header, which starts at the firts line and continues up until
  288. Z  * there is a blank line as the follow lins it:
  289. Z  *
  290. Z  *    Newsgroups: comp.mail.maps
  291. Z  *    Subject: UUCP ...
  292. Z  *    Message-ID: ...
  293. Z  *    Date: ...
  294. Z  *    Approved: ...
  295. Z  *
  296. Z  * These lines are not the complete list, nor do they show up in that order.
  297. Z  * After the header is a blank line.  Next comes the shar file preamble
  298. Z  * which consists of a bunch of lines that begin with a :, followed
  299. Z  * by the 2 lines:
  300. Z  *
  301. Z  *    echo shar: extracting THE-FILE-NAME
  302. Z  *    cat << 'SHAR_EOF' > THE-FILE-NAME
  303. Z  *
  304. Z  * what follows is the map data intended to override THE-FILE-NAME in the
  305. Z  * UNSHAR_MAP_DIR directory.  The final 3 lines:
  306. Z  *
  307. Z  *    SHAR_EOF
  308. Z  *    :   End of shell archive
  309. Z  *    exit 0
  310. Z  *
  311. Z  * terminate the shar file, and are not considered a part of the map data.
  312. Z  *
  313. Z  * For each shar file processed, the following information is written
  314. Z  * to stdout:
  315. Z  *
  316. Z  *    filename read
  317. Z  *    filename written
  318. Z  *    subject line
  319. Z  *    message-ID
  320. Z  *    date
  321. Z  *    approved info
  322. Z  *    any error message
  323. Z  *
  324. Z  * All error message lines begin with 'error:'.
  325. Z  *
  326. Z  * exits by 0 if there was no errors, non-0 otherwise.
  327. Z  */
  328. Z  
  329. Z #include <stdio.h>
  330. Z #define HEADER_OK 1            /* the article header is correct */
  331. Z #define HEADER_ERROR 2            /* bad header, skip and log */
  332. Z #define HEADER_SKIP 3            /* not a map shar, ignore file */
  333. Z char *program;                /* our name */
  334. Z char err[BUFSIZ+1];            /* error and log message */
  335. Z char buf[BUFSIZ+1];            /* input buffer */
  336. Z char mapname[BUFSIZ+1];            /* name of the output map file */
  337. Z int lineno = 0;                /* current line number */
  338. Z char *newsgroups = "comp.mail.maps";    /* : list of allowed newsgroups */
  339. Z char *get_date();            /* system dependent date string */
  340. Z void log();                /* write to log and error log */
  341. Z int check_header();            /* check the article header */
  342. Z void skip_article();            /* skip a bad article */
  343. Z void ignore_article();            /* ignore the non-map article */
  344. Z char *check_preamble();            /* check shar preamble, get map name */
  345. Z int write_map();            /* write a map file */
  346. Z char *check_newline();            /* check to be sure we read a '\n' */
  347. Z char *xmalloc();            /* for string.c and strcolon()*/
  348. Z char *xrealloc();            /* for string.c and strcolon() */
  349. Z extern char *strcolon();        /* grap strcolon() from src/string.c */
  350. Z main( argc, argv )
  351. Z     int argc;                /* arg count */
  352. Z     char *argv[];            /* args */
  353. Z {
  354. Z     char filename[BUFSIZ+1];        /* name of the input article */
  355. Z     char *p;                /* pointer */
  356. Z     int c;                /* the option flag */
  357. Z     int header;                /* HEADER_OK,ERROR,SKIP */
  358. Z     int errors=0;            /* number of problems found */
  359. Z     int stdinfile;            /* get just one file from std input */
  360. Z     FILE *article;            /* input article stream */
  361. Z     extern char *optarg;        /* the option argument */
  362. Z     extern int optind;            /* operand index */
  363. Z     /*
  364. Z      * parse args
  365. Z      */
  366. Z     program = argv[0];
  367. Z     while ((c = getopt(argc, argv, "pd:n:")) != EOF) {
  368. Z     switch(c) {
  369. Z     case 'p':
  370. Z         stdinfile = 1;
  371. Z         break;
  372. Z     case 'd':            /* directory to cd to */
  373. Z         if (chdir(optarg) < 0) {
  374. Z         sprintf(err, "error: can not cd to %s\n", optarg);
  375. Z         log(err);
  376. Z         sprintf(err, "exiting: status: 5 -  %s", get_date());
  377. Z         log(err);
  378. Z         exit(5);
  379. Z         }
  380. Z         break;
  381. Z     case 'n':
  382. Z         newsgroups = optarg;
  383. Z         break;
  384. Z     case '?':
  385. Z         sprintf(err,
  386. Z             "error: usage: %s [-d dir] < filelist > log 2> error\n",
  387. Z             program);
  388. Z         log(err);
  389. Z         sprintf(err, "exiting: status: 1 -  %s", get_date());
  390. Z         log(err);
  391. Z         exit(1);
  392. Z         break;
  393. Z     }
  394. Z     }
  395. Z     if (optind != argc) {
  396. Z     sprintf(err, "error: usage: %s [-d dir] < filelist > log 2> error\n",
  397. Z         program);
  398. Z     log(err);
  399. Z     sprintf(err, "exiting: status: 1 -  %s", get_date());
  400. Z     log(err);
  401. Z     exit(1);
  402. Z     }
  403. Z     
  404. Z     /*
  405. Z      * process all file names on input
  406. Z      */
  407. Z     sprintf(err, "starting: %s", get_date());
  408. Z     log(err);
  409. Z     while (stdinfile || fgets(filename, BUFSIZ, stdin) != NULL) {
  410. Z     
  411. Z       if(!stdinfile){
  412. Z     /*
  413. Z      * open the map file
  414. Z      */
  415. Z     lineno = 0;            /* clear the line count */
  416. Z     if ((p = check_newline(filename)) == NULL) {
  417. Z         sprintf(err, "error: filename longer than %d chars\n",
  418. Z             program, BUFSIZ-2);
  419. Z         log(err);
  420. Z         sprintf(err, "exiting: status: 2 -  %s", get_date());
  421. Z         log(err);
  422. Z         exit(2);
  423. Z     }
  424. Z     *p = '\0';    /* remove the newline from the filename */
  425. Z     if ((article = fopen(filename, "r")) == NULL) {
  426. Z         sprintf(err, "error: can not open: %s\n", filename);
  427. Z         log(err);
  428. Z         ++errors;
  429. Z         continue;
  430. Z     }
  431. Z     sprintf(err, "filename: %s\n", filename);
  432. Z     log(err);
  433. Z       } else {
  434. Z     strcpy(filename,"stdin");
  435. Z     article = stdin;
  436. Z       }
  437. Z     /*
  438. Z      * verify the article header
  439. Z      *
  440. Z      * close file if error or skip
  441. Z      */
  442. Z     switch (header = check_header(article)) {
  443. Z     case HEADER_OK:            /* we have a good header */
  444. Z         break;
  445. Z     case HEADER_ERROR:        /* the article is bad, skip & log */
  446. Z         skip_article(article, filename);
  447. Z         ++errors;
  448. Z         break;
  449. Z     case HEADER_SKIP:        /* not a map article, ignore it */
  450. Z         ignore_article(article, filename);
  451. Z         break;
  452. Z     default:            /* how did we get here? */
  453. Z         sprintf(err, "error: check_header returned %d, why?\n", header);
  454. Z         log(err);
  455. Z         sprintf(err, "exiting: status: 3 -  %s", get_date());
  456. Z         log(err);
  457. Z         exit(3);
  458. Z     }
  459. Z     if (header != HEADER_OK) {
  460. Z         continue;            /* try another file */
  461. Z     }
  462. Z     /*
  463. Z      * check the shar preamble, get the shar file name
  464. Z      */
  465. Z     if (check_preamble(article) == NULL) {
  466. Z         skip_article(article, filename);
  467. Z         ++errors;
  468. Z         continue;
  469. Z     }
  470. Z     if(stdinfile) strcpy(filename,mapname);
  471. Z     /*
  472. Z      * write the map, verify final lines
  473. Z      */
  474. Z     if (write_map(article) != 0) {
  475. Z         skip_article(article, filename);
  476. Z         ++errors;
  477. Z         continue;
  478. Z     }
  479. Z     /*
  480. Z      * all done with this article
  481. Z      */
  482. Z     fclose(article);
  483. Z     fflush(stdout);
  484. Z     if(stdinfile)break;
  485. Z     }
  486. Z     /*
  487. Z      * note if everything went ok
  488. Z      */
  489. Z     sprintf(err, "exiting: status: %d -  %s", (errors>0) ? 4 : 0, get_date());
  490. Z     log(err);
  491. Z     exit( (errors>0) ? 4 : 0 );
  492. Z }
  493. Z /*
  494. Z  * get_date - get the date followed by newline in the standard way
  495. Z  *
  496. Z  * returns the date in ctime(3) format
  497. Z  */
  498. Z char *
  499. Z get_date()
  500. Z {
  501. Z     extern long time();
  502. Z     long clock = time((long *)0);   /* seconds since 1-jan-1970 0:00:00 GMT */
  503. Z     char *ctime();            /* convert clock into string */
  504. Z     return(ctime(&clock));
  505. Z }
  506. Z /*
  507. Z  * log - write a message to the log
  508. Z  */
  509. Z void
  510. Z log( msg )
  511. Z     char *msg;                /* the message to write */
  512. Z {
  513. Z     /* write to the log */
  514. Z     fputs(msg, stdout);
  515. Z }
  516. Z /*
  517. Z  * check_header - check the article header
  518. Z  *
  519. Z  * This routine verifies that a article header has the following lines:
  520. Z  *
  521. Z  *    Newsgroups: comp.mail.maps
  522. Z  *    Subject: UUCP ...
  523. Z  *    Message-ID: ...
  524. Z  *    Date: ...
  525. Z  *    Approved: ...
  526. Z  *
  527. Z  * The text of all but the Newsgroups lines are logged.  If the Newsgroups
  528. Z  * line is bad, that too is logged.  The header ends before a blank line.
  529. Z  * The final blank line is read and discarded.
  530. Z  *
  531. Z  * returns HEADER_OK is all 5 header lines were read and were valid,
  532. Z  *         HEADER_ERROR is the header was bad and needs to be skipped & logged,
  533. Z  *       HEADER_SKIP if the file is not a UUCP shar file and should be skipped
  534. Z  */
  535. Z int
  536. Z check_header( article )
  537. Z     FILE *article;            /* the article stream */
  538. Z {
  539. Z     int saw_groups=0;            /* 1 ==> saw Newsgroups: */
  540. Z     int saw_subject=0;            /* 1 ==> saw Subject: */
  541. Z     int saw_message=0;            /* 1 ==> saw Message-ID: */
  542. Z     int saw_date=0;            /* 1 ==> saw Date: */
  543. Z     int saw_approved=0;            /* 1 ==> saw Approved: */
  544. Z     char *p;                /* temp */
  545. Z     /*
  546. Z      * read the header
  547. Z      */
  548. Z     do {
  549. Z     /*
  550. Z      * read the line
  551. Z      */
  552. Z     clearerr(article);
  553. Z     if (fgets(buf, BUFSIZ, article) == NULL) {
  554. Z         if (ferror(article)) {
  555. Z         sprintf(buf, "error: bad header read after line %d\n", lineno);
  556. Z         log(err);
  557. Z         } else {
  558. Z         log("error: EOF while reading the header\n");
  559. Z         }
  560. Z         return(HEADER_ERROR);
  561. Z     }
  562. Z     ++lineno;            /* count this line */
  563. Z     if (! check_newline(buf)) {
  564. Z         sprintf(err, "error: line %d, header line too long\n", lineno);
  565. Z         log(err);
  566. Z         return(HEADER_ERROR);
  567. Z     }
  568. Z     /*
  569. Z      * look for special types
  570. Z      */
  571. Z     switch (buf[0]) {
  572. Z     case 'n':
  573. Z     case 'N':            /* could be Newsgroups: */
  574. Z         if (strncmpic("Newsgroups: ", buf, 12) == 0) {
  575. Z         for (p = strcolon(newsgroups); p; p = strcolon((char *)NULL)) {
  576. Z             if (strncmpic(buf + 12, p, strlen(p)) == 0 &&
  577. Z             buf[12 + strlen(p)] == '\n')
  578. Z             {
  579. Z             break;
  580. Z             }
  581. Z         }
  582. Z         if (p != NULL) {
  583. Z             saw_groups = 1;
  584. Z         } else {
  585. Z             sprintf(err, "error: line %d, bad %s", lineno, buf);
  586. Z             log(err);
  587. Z             return(HEADER_ERROR);
  588. Z         }
  589. Z         }
  590. Z         break;
  591. Z     case 's':
  592. Z     case 'S':            /* Subject: buf */
  593. Z         if (strncmpic("Subject: ", buf, 9) == 0) {
  594. Z         if (strncmpic("Subject: UUCP ", buf, 14) == 0) {
  595. Z             saw_subject = 1;
  596. Z             log("    ");
  597. Z             log(buf);
  598. Z         } else {
  599. Z             log("    ");
  600. Z             log(err);
  601. Z             return(HEADER_SKIP); /* not a shar map file */
  602. Z         }
  603. Z         }
  604. Z         break;
  605. Z     case 'm':
  606. Z     case 'M':            /* Message-ID: buf */
  607. Z         if (strncmpic("Message-ID: ", buf, 12) == 0) {
  608. Z             saw_message = 1;
  609. Z             log("    ");
  610. Z             log(buf);
  611. Z         }
  612. Z         break;
  613. Z     case 'd':
  614. Z     case 'D':            /* Message-ID: buf */
  615. Z         if (strncmpic("Date: ", buf, 6) == 0) {
  616. Z         saw_date = 1;
  617. Z         log("    ");
  618. Z         log(buf);
  619. Z         }
  620. Z         break;
  621. Z     case 'a':
  622. Z     case 'A':            /* Message-ID: buf */
  623. Z         if (strncmpic("Approved: ", buf, 10) == 0) {
  624. Z         saw_approved = 1;
  625. Z         log("    ");
  626. Z         log(buf);
  627. Z         }
  628. Z         break;
  629. Z     }
  630. Z     } while(strcmp("\n", buf) != 0);    /* while heading the header */
  631. Z     /*
  632. Z      * report if er got everything
  633. Z      */
  634. Z     if (saw_groups == 0) {
  635. Z     log("error: no Newsgroups: line\n");
  636. Z     return(HEADER_ERROR);
  637. Z     }
  638. Z     if (saw_subject == 0) {
  639. Z     log("error: no Subject: line\n");
  640. Z     return(HEADER_ERROR);
  641. Z     }
  642. Z     if (saw_message == 0) {
  643. Z     log("error: no Message-ID: line\n");
  644. Z     return(HEADER_ERROR);
  645. Z     }
  646. Z     if (saw_date == 0) {
  647. Z     log("error: no Date: line\n");
  648. Z     return(HEADER_ERROR);
  649. Z     }
  650. Z     if (saw_approved == 0) {
  651. Z     log("error: no Approved: line\n");
  652. Z     return(HEADER_ERROR);
  653. Z     }
  654. Z     return(HEADER_OK);            /* passed all the tests */
  655. Z }
  656. Z /*
  657. Z  * skip_article - skip article, log and close it
  658. Z  */
  659. Z void
  660. Z skip_article( article, filename )
  661. Z     FILE *article;            /* the article stream */
  662. Z     char *filename;            /* the filename we are skipping */
  663. Z {
  664. Z     /*
  665. Z      * log that we are skipping the remainder of the article
  666. Z      */
  667. Z     sprintf(err, "    skipping: %s after reading line %d\n", filename, lineno);
  668. Z     log(err);
  669. Z     /*
  670. Z      * close the stream
  671. Z      */
  672. Z     fclose(article);
  673. Z     /*
  674. Z      * report the close
  675. Z      */
  676. Z     sprintf(err, "finished: %s\n", filename);
  677. Z     log(err);
  678. Z     return;
  679. Z }
  680. Z /*
  681. Z  * ingore_article - ignore an article, close and report it
  682. Z  */
  683. Z void
  684. Z ignore_article( article, filename )
  685. Z     FILE *article;            /* the article stream */
  686. Z     char *filename;            /* the filename we are skipping */
  687. Z {
  688. Z     /*
  689. Z      * log that we are ignoring the remainder of the article
  690. Z      */
  691. Z     sprintf(err, "    ignore non map file: %s after reading line %d\n",
  692. Z         filename, lineno);
  693. Z     log(err);
  694. Z     /*
  695. Z      * close the stream
  696. Z      */
  697. Z     fclose(article);
  698. Z     /*
  699. Z      * report the close
  700. Z      */
  701. Z     sprintf(err, "finished: %s\n", filename);
  702. Z     log(err);
  703. Z     return;
  704. Z }
  705. Z /*
  706. Z  * check_preamble - check for a valid shar preamble
  707. Z  *
  708. Z  * The shar preamble consists of a bunch of lines that begin with :,
  709. Z  * followed by the 2 lines:
  710. Z  *
  711. Z  *    echo shar: extracting THE-FILE-NAME
  712. Z  *    cat << 'SHAR_EOF' > THE-FILE-NAME
  713. Z  *
  714. Z  * Any other line is printed to both logs as an error.  The "THE-FILE-NAME"
  715. Z  * string is returned if a valid preamble is found, NULL otherwise.
  716. Z  */
  717. Z char *
  718. Z check_preamble( article )
  719. Z     FILE *article;            /* the article stream */
  720. Z {
  721. Z     char *p;                /* pointer */
  722. Z     char *q;                /* pointer, NULL byte of mapname */
  723. Z     int bad_echo=0;            /* 1 ==> a bad echo was found */
  724. Z     /*
  725. Z      * read the preamble
  726. Z      */
  727. Z     mapname[0] = '\0';    /* no mapname yet */
  728. Z     while (1) {
  729. Z     /*
  730. Z      * read the line
  731. Z      */
  732. Z     clearerr(article);
  733. Z     if (fgets(buf, BUFSIZ, article) == NULL) {
  734. Z         if (ferror(article)) {
  735. Z         sprintf(err, "error: bad preamble read after line %d\n",
  736. Z             lineno);
  737. Z         log(err);
  738. Z         } else {
  739. Z         log("error: EOF while reading the preamble\n");
  740. Z         }
  741. Z         return(NULL);
  742. Z     }
  743. Z     ++lineno;            /* count line */
  744. Z     if (! check_newline(buf)) {
  745. Z         sprintf(err, "error: line %d, preamble line too long\n", lineno);
  746. Z         log(err);
  747. Z         return(NULL);
  748. Z     }
  749. Z     /*
  750. Z      * skip the : lines
  751. Z      */
  752. Z     if (buf[0] == ':') {
  753. Z         continue;
  754. Z     }
  755. Z     /*
  756. Z      * look for the echo line
  757. Z      */
  758. Z     if (strncmp("echo shar: extracting ", buf, 22) == 0) {
  759. Z         /* grab the mapname */
  760. Z         for (p=buf+22, q=mapname, bad_echo=0; *p; ++p) {
  761. Z         /* be sure it is well formed */
  762. Z         switch (*p) {
  763. Z         case ' ':
  764. Z         case '\t':
  765. Z             bad_echo = 1;    /* unlikely char in a filename */
  766. Z             *q++ = *p;
  767. Z             break;
  768. Z         case '\n':        /* should be the end */
  769. Z             if (*(p+1) != '\0') {
  770. Z             bad_echo = 1;    /* why is '\n' not the end */
  771. Z             }
  772. Z             break;        /* don't copy the newline */
  773. Z         case '\\':        /* avoid \ and / in filenames */
  774. Z         case '/':
  775. Z             bad_echo = 1;
  776. Z             *q++ = *p;
  777. Z             break;
  778. Z         default:
  779. Z             *q++ = *p;
  780. Z             break;
  781. Z         }
  782. Z         }
  783. Z         *q = '\0';            /* NULL terminate filename */
  784. Z         /* verify mapname */
  785. Z         if (bad_echo == 1) {
  786. Z         sprintf(err, "error: line %d, bad echo mapname: %s\n",
  787. Z             lineno, mapname);
  788. Z         log(err);
  789. Z         return(NULL);        /* bad preamble */
  790. Z         }
  791. Z     /*
  792. Z      * watch for the cat line
  793. Z      */
  794. Z     } else if (strncmp("cat << 'SHAR_EOF' > ", buf, 20) == 0) {
  795. Z         /*
  796. Z          * compare cat filename against echo filename
  797. Z          */
  798. Z         if (mapname[0] == '\0') {
  799. Z         sprintf(err, "error: line %d, cat with no preceding echo: %s",
  800. Z             lineno, buf);
  801. Z         log(err);
  802. Z         return(NULL);        /* bad preamble */
  803. Z         } else if (strncmp(buf+20, mapname, q-mapname) != 0) {
  804. Z         sprintf(err,
  805. Z             "error: line %d, echo mapname: %s != cat mapname: %s",
  806. Z             lineno, mapname, buf+20);
  807. Z         log(err);
  808. Z         return(NULL);        /* bad preamble */
  809. Z         } else {
  810. Z         return(mapname);    /* found end of preamble */
  811. Z         }
  812. Z         
  813. Z     /*
  814. Z      * watch for unkown lines
  815. Z      */
  816. Z     } else {
  817. Z         sprintf(err, "error: line %d, unknown preamble: %s", lineno, buf);
  818. Z         log(err);
  819. Z         return(NULL);
  820. Z     }
  821. Z     }
  822. Z     /* NOT REACHED */
  823. Z }
  824. Z /*
  825. Z  * write_map - write a map file
  826. Z  *
  827. Z  * Given an verified article header and shar preamble, copy the contents
  828. Z  * of the shar HERE_IS document up until the ending shar lines:
  829. Z  *
  830. Z  *    SHAR_EOF
  831. Z  *    :   End of shell archive
  832. Z  *    exit 0
  833. Z  *
  834. Z  * A previous call to check_preamble placed the name of the mapfile in
  835. Z  * the mapname array.
  836. Z  *
  837. Z  * returns 1 if all was ok, 0 otherwise.
  838. Z  */
  839. Z int
  840. Z write_map( article )
  841. Z     FILE *article;            /* the article stream */
  842. Z {
  843. Z     int fd;                /* map file descriptor */
  844. Z     FILE *map;                /* the map file stream */
  845. Z     /*
  846. Z      * open and truncate the map file
  847. Z      */
  848. Z     fd = creat(mapname, 0644);
  849. Z     if (fd < 0) {
  850. Z     sprintf(err, "error: unable to creat/truncate %s\n", mapname);
  851. Z     log(err);
  852. Z     return(1);
  853. Z     }
  854. Z     map = fdopen(fd, "w");
  855. Z     sprintf(err, "extracting: %s\n", mapname);
  856. Z     log(err);
  857. Z     /*
  858. Z      * copy article shar data to the map file
  859. Z      */
  860. Z     while (1) {
  861. Z     /*
  862. Z      * read the line
  863. Z      */
  864. Z     clearerr(article);
  865. Z     if (fgets(buf, BUFSIZ, article) == NULL) {
  866. Z         if (ferror(article)) {
  867. Z         sprintf(err, "error: bad map data read after line %d\n",
  868. Z             lineno);
  869. Z         log(err);
  870. Z         } else {
  871. Z         log("error: EOF while reading the map data\n");
  872. Z         }
  873. Z         return(1);
  874. Z     }
  875. Z     ++lineno;
  876. Z     if (! check_newline(buf)) {
  877. Z         sprintf(err, "error: line %d, map data line too long\n", lineno);
  878. Z         log(err);
  879. Z         return(1);
  880. Z     }
  881. Z     /*
  882. Z      * watch for the end of the shar
  883. Z      */
  884. Z     if (strcmp("SHAR_EOF\n", buf) == 0) {
  885. Z         /* end of the shar file */
  886. Z         if (fclose(map) == EOF) {
  887. Z         log("error: bad fclose\n");
  888. Z         return(1);
  889. Z         }
  890. Z         mapname[0] = '\0';
  891. Z         break;            /* look for final two lines */
  892. Z     }
  893. Z     /*
  894. Z      * write the line
  895. Z      */
  896. Z     if (fputs(buf, map) == EOF) {
  897. Z         log("error: bad write\n");
  898. Z         return(1);
  899. Z     }
  900. Z     }
  901. Z     /*
  902. Z      * verify the : line after the end of the map
  903. Z      */
  904. Z     clearerr(article);
  905. Z     if (fgets(buf, BUFSIZ, article) == NULL) {
  906. Z     if (ferror(article)) {
  907. Z         sprintf(err, "error: bad ending : read after line %d\n",
  908. Z             lineno);
  909. Z         log(err);
  910. Z     } else {
  911. Z         log("error: EOF while reading the ending : line\n");
  912. Z     }
  913. Z     return(1);
  914. Z     }
  915. Z     ++lineno;
  916. Z     if (! check_newline(buf)) {
  917. Z     sprintf(err, "error: line %d, ending : line too long\n", lineno);
  918. Z     log(err);
  919. Z     return(1);
  920. Z     }
  921. Z     if (buf[0] != ':') {
  922. Z     sprintf(err, "error: line %d, not an ending : line: %s", lineno, buf);
  923. Z     log(err);
  924. Z     return(1);
  925. Z     }
  926. Z     /*
  927. Z      * verify the exit 0
  928. Z      */
  929. Z     clearerr(article);
  930. Z     if (fgets(buf, BUFSIZ, article) == NULL) {
  931. Z     if (ferror(article)) {
  932. Z         sprintf(err, "error: bad ending exit read after line %d\n",
  933. Z             lineno);
  934. Z         log(err);
  935. Z     } else {
  936. Z         log("error: EOF while reading the ending exit line\n");
  937. Z     }
  938. Z     return(1);
  939. Z     }
  940. Z     ++lineno;
  941. Z     if (! check_newline(buf)) {
  942. Z     sprintf(err, "error: line %d, ending exit line too long\n", lineno);
  943. Z     log(err);
  944. Z     return(1);
  945. Z     }
  946. Z     if (strcmp("exit 0\n", buf) != 0) {
  947. Z     sprintf(err, "error: line %d, not an ending exit line: %s",
  948. Z         lineno, buf);
  949. Z     log(err);
  950. Z     return(1);
  951. Z     }
  952. Z     /*
  953. Z      * if we are here, all must be ok
  954. Z      */
  955. Z     return(0);
  956. Z }
  957. Z /*
  958. Z  * check_newline - check to be sure that the string endds in a newline
  959. Z  *
  960. Z  * returns a pointer to the newline, or NULL if none found
  961. Z  */
  962. Z char *
  963. Z check_newline( str )
  964. Z     char *str;                /* check for newline in str */
  965. Z {
  966. Z     char *p;                /* pointer */
  967. Z     /* guess the newline location */
  968. Z     p = str + strlen(str);
  969. Z     p -= ((p > str) ? 1 : 0);
  970. Z     /* return result of guess */
  971. Z     return( (*p == '\n') ? p : NULL );
  972. Z }
  973. Z char *
  974. Z xmalloc(size)
  975. Z     unsigned size;
  976. Z {
  977. Z     extern char *malloc();
  978. Z     char *ret = malloc(size);
  979. Z     if (ret == NULL) {
  980. Z     sprintf(err, "error: out of memory in xmalloc\n");
  981. Z     log(err);
  982. Z     sprintf(err, "exiting: status: 1 -  %s", get_date());
  983. Z     log(err);
  984. Z     exit(1);
  985. Z     }
  986. Z     return ret;
  987. Z }
  988. Z char *
  989. Z xrealloc(region, size)
  990. Z     char *region;
  991. Z     unsigned size;
  992. Z {
  993. Z     extern char *realloc();
  994. Z     register char *ret = realloc(region, size);
  995. Z     if (ret == NULL) {
  996. Z     sprintf(err, "error: out of memory in xrealloc\n");
  997. Z     log(err);
  998. Z     sprintf(err, "exiting: status: 1 - %s", get_date());
  999. Z     log(err);
  1000. Z     exit(1);
  1001. Z     }
  1002. Z     return ret;
  1003. Z }
  1004. Z /*
  1005. Z  * strcmpic - case independent strcmp function
  1006. Z  */
  1007. Z int
  1008. Z strncmpic(s1, s2, n)
  1009. Z     register char *s1, *s2;        /* strings to compare */
  1010. Z     int n;                /* compare up to this many chars */
  1011. Z {
  1012. Z     register int c1, c2;        /* temp */
  1013. Z     register int cnt = n;        /* count of chars so far compared */
  1014. Z     while (*s1 && *s2 && cnt > 0) {
  1015. Z     if ((c1 = tolower(*s1)) != (c2 = tolower(*s2))) {
  1016. Z         return c1-c2;
  1017. Z     }
  1018. Z     s1++;
  1019. Z     s2++;
  1020. Z     cnt--;                /* count this character */
  1021. Z     }
  1022. Z     /*
  1023. Z      * If we ran out of chars, then the string segments are equal, otherwise
  1024. Z      * one or both strings must have ended. In this case the subtraction
  1025. Z      * will show which one is shorter, if any.
  1026. Z      */
  1027. Z     return cnt ? (int)((*s1)-(*s2)) : 0;
  1028. Z }
  1029. Z /*
  1030. Z  * strcolon - step through string parts separated by colons
  1031. Z  *
  1032. Z  * when called with a string, return a copy of the first part of
  1033. Z  * the string up to, but excluding the first `:'.  When called with
  1034. Z  * NULL return a copy of the next part of the previously passed string,
  1035. Z  * with each part separated by a colon `:'.
  1036. Z  *
  1037. Z  * return NULL if no more parts are left.
  1038. Z  *
  1039. Z  * strcolon is typically used in a loop on ':' separated names such as:
  1040. Z  *
  1041. Z  *    for (p = strcolon(names); p; p = strcolon((char *)NULL)) {
  1042. Z  *        ... do something with the name p ...
  1043. Z  *    }
  1044. Z  *
  1045. Z  * the malloc region returned is reused, so if you wish to keep a string
  1046. Z  * around, you will need to copy it.
  1047. Z  */
  1048. Z char *
  1049. Z strcolon(s)
  1050. Z     register char *s;            /* string or NULL */
  1051. Z {
  1052. Z     static char *next = NULL;        /* pointer to next ':' */
  1053. Z     static char *region = NULL;        /* region used to store result */
  1054. Z     static int alloc = 0;        /* alloc size of region */
  1055. Z     if (!s) {
  1056. Z     s = next;
  1057. Z     if (s == NULL) {
  1058. Z         return NULL;
  1059. Z     }
  1060. Z     }
  1061. Z     next = strchr(s, ':');
  1062. Z     if (next) {
  1063. Z     register int len = next - s;
  1064. Z     if (len >= alloc) {
  1065. Z         if (region == NULL) {
  1066. Z         region = xmalloc(alloc = len + 1);
  1067. Z         } else {
  1068. Z         region = xrealloc(region, alloc = len + 1);
  1069. Z         }
  1070. Z     }
  1071. Z     (void) memcpy(region, s, next - s);
  1072. Z     region[next - s] = '\0';
  1073. Z     next++;
  1074. Z     return region;
  1075. Z     }
  1076. Z     return s;
  1077. Z }
  1078. ----SHAR-EOF----
  1079. if test 20620 -ne "`wc -c unsharmap.c`"
  1080. then
  1081. echo shar: Uebertragungsfehler in unsharmap.c '(Soll-Laenge = 20620 Zeichen)'
  1082. fi
  1083. echo shar: Extraktion von install
  1084. sed 's/^Z //' << \----SHAR-EOF---- > install
  1085. Z : use /bin/sh
  1086. Z # ---------------------------------------------------------------------
  1087. Z #  Title     : installation von 'unsharmap' (als root ausfuehren)
  1088. Z #  Version      :       Wed, 16-May-90 / 21:00 / (root@artcom0)
  1089. Z # ---------------------------------------------------------------------
  1090. Z if [ ! -r /usr/sysadm ]
  1091. Z then echo "Install must be done with 'root' priv !" ; exit 1
  1092. Z fi
  1093. Z MAPDIR=/usr/lib/uucp/maps
  1094. Z BINDIR=/usr/local/bin
  1095. Z if [ ! -d $BINDIR ]
  1096. Z then echo "Oh... ich finde '/usr/local/bin' viel uebersichtlicher.
  1097. Z egal... wenn's denn sein soll, nehmen wir halt '/usr/bin' : "
  1098. Z      BINDIR=/usr/bin
  1099. Z fi
  1100. Z NEWSDIR=/usr/local/lib/news
  1101. Z if [ ! -d $NEWSDIR ]
  1102. Z then echo "Oh... ich finde '/usr/local/lib/news' viel uebersichtlicher.
  1103. Z egal... wenn's denn sein soll, nehmen wir halt '/usr/lib/news' : "
  1104. Z      NEWSDIR=/usr/lib/news
  1105. Z fi
  1106. Z if [ ! -d $MAPDIR ]
  1107. Z then mkdir $MAPDIR
  1108. Z      chmod 755 $MAPDIR
  1109. Z      chgrp news $MAPDIR
  1110. Z fi
  1111. Z if [ ! -d $MAPDIR/work ]
  1112. Z then mkdir $MAPDIR/work
  1113. Z      chmod 775 $MAPDIR/work
  1114. Z      # Ganz Wichtig : Gruppen Schreibzugriff fuer News !
  1115. Z      chgrp news $MAPDIR/work
  1116. Z fi
  1117. Z cp unsharmap $BINDIR
  1118. Z chgrp news $BINDIR/unsharmap
  1119. Z chown mail $BINDIR/unsharmap
  1120. Z chmod 6755 $BINDIR/unsharmap
  1121. Z cp mkpaths map.daily $MAPDIR
  1122. Z cd $MAPDIR
  1123. Z chown mail mkpaths map.daily
  1124. Z chgrp news mkpaths map.daily
  1125. Z chmod 755  mkpaths map.daily
  1126. Z #
  1127. Z # Aufruf von 'unsharmap' ins News-Sysfile einfuegen :
  1128. Z # 
  1129. Z SYSFILE=$NEWSDIR/sys
  1130. Z if [ ! -w $SYSFILE ]
  1131. Z then echo "Oh. Kein News-Sysfile ? ($SYSFILE)" ; exit 1
  1132. Z fi
  1133. Z grep "^automapadm" $SYSFILE >/dev/null || echo \
  1134. Z "# Automatische Mail-Routing-Map-Administration :
  1135. Z automapadm:world,sub,!sub.all,sub.config.maps::$BINDIR/unsharmap -p \\
  1136. Z     -n sub.config.maps -d $MAPDIR/work | mail -s \"Auto map adm\" \\
  1137. Z     postmaster" >> $SYSFILE
  1138. Z echo "Installation in $MAPDIR fertig ... 
  1139. Z und nun \"$MAPDIR/map.daily\" taeglich via root-crontab 
  1140. Z ausfuehren lassen oder per Hand aufrufen, wenn neue Maps ankamen."
  1141. ----SHAR-EOF----
  1142. if test 1902 -ne "`wc -c install`"
  1143. then
  1144. echo shar: Uebertragungsfehler in install '(Soll-Laenge = 1902 Zeichen)'
  1145. fi
  1146. echo shar: Extraktion von avoid-unido
  1147. sed 's/^Z //' << \----SHAR-EOF---- > avoid-unido
  1148. Z : use /bin/sh
  1149. Z #
  1150. Z #  Title    : avoid-unido -- avoid routing over unido, whenever possible
  1151. Z #  Version      :       Sat, 26-May-90 / 12:38 / (root@artcom0)
  1152. Z #
  1153. Z for i in u.deu.* ; do
  1154. Z     if [ "$i" = "*" ]
  1155. Z     then exit 0
  1156. Z     fi
  1157. Z     mv $i tmp
  1158. Z     awk ' { gsub (/DAILY/, "DEAD"); 
  1159. Z         gsub (/HOURLY/, "DEAD");
  1160. Z         gsub (/LOCAL/, "DEAD");
  1161. Z         gsub (/ARPA/, "DEAD");
  1162. Z         print $0 } ' < tmp > $i
  1163. Z     rm tmp
  1164. Z done
  1165. ----SHAR-EOF----
  1166. if test 402 -ne "`wc -c avoid-unido`"
  1167. then
  1168. echo shar: Uebertragungsfehler in avoid-unido '(Soll-Laenge = 402 Zeichen)'
  1169. fi
  1170. echo shar: Extraktion von getmap
  1171. sed 's/^Z //' << \----SHAR-EOF---- > getmap
  1172. Z #! /bin/sh
  1173. Z # @(#)getmap.sh    1.15 2/5/89 14:13:35
  1174. Z #
  1175. Z #    Copyright (C) 1988 Ronald S. Karr and Landon Curt Noll
  1176. Z #
  1177. Z # See the file COPYING, distributed with smail, for restriction
  1178. Z # and warranty information.
  1179. Z # getmap - unshar usenet map articles into the UNSHAR_MAP_DIR directory
  1180. Z #
  1181. Z # usage: getmap [-m mapdir] [-w workdir] [-b batchfile] [-u username]
  1182. Z #
  1183. Z #     -m mapdir    - 'mapdir' is where maps are unpacked,
  1184. Z #              by default 'mapdir' is $UNSHAR_MAP_DIR
  1185. Z #     -w workdir    - where logs and default batch files are kept,
  1186. Z #              by default 'workdir' is 'mapdir'/work
  1187. Z #      -b batch    - 'batch' is a file of filenames to unshar,
  1188. Z #              '-' impiles read filenames from stdin,
  1189. Z #              by default 'batch' is 'workdir'/batch
  1190. Z #     -u username    - errors are Emailed to 'username' rather than
  1191. Z #              Posmaster, the username '-' imples that
  1192. Z #              the errors should be written to standard error
  1193. Z #     -n newsgroups    - allowed newsgroups for articles
  1194. Z #
  1195. Z # unsharmap errors will be emailed to the postmaster.
  1196. Z #
  1197. Z # default files:
  1198. Z #    $UNSHAR_MAP_DIR            - maps are unpacked here
  1199. Z #    $UNSHAR_MAP_DIR/work/getmap.log    - log of getmap activity and errors
  1200. Z #    $UNSHAR_MAP_DIR/work/getmap.err    - like getmap.log + skipped lines
  1201. Z #                      removed if no major unshar errors
  1202. Z #    $UNSHAR_MAP_DIR/work/batch        - default list of artciles to unshar
  1203. Z #    batch.work                - tmp copy of batch work, normally
  1204. Z #                      $UNSHAR_MAP_DIR/work/batch.work,
  1205. Z #                      ignored if "-w -"
  1206. Z # locations and constants
  1207. Z #
  1208. Z PATH="/usr/bin:/bin:/usr/local/bin"
  1209. Z UTIL_BIN="/usr/spool/maps/bin"
  1210. Z UNSHAR_MAP_DIR="/usr/spool/maps"
  1211. Z UNSHAR=$UTIL_BIN/unsharmap
  1212. Z # set defaults value for location that can change by option
  1213. Z #
  1214. Z MAPDIR=$UNSHAR_MAP_DIR
  1215. Z WORKDIR=$MAPDIR/work
  1216. Z BATCH=$WORKDIR/batch
  1217. Z USERNAME=postmaster
  1218. Z NEWSGROUPS=comp.mail.maps:sub.config.maps
  1219. Z # parse args
  1220. Z #
  1221. Z PROG=$0
  1222. Z USAGE="usage: $PROG [-m mapdir] [-w workdir] [-b batch] [-u username]"
  1223. Z set -- `getopt -n $PROG -q m:w:b:u:n: $*`
  1224. Z if [ $? != 0 ]; then
  1225. Z     echo $USAGE 1>&2
  1226. Z     exit 1
  1227. Z fi
  1228. Z for i in $*; do
  1229. Z     case $i in
  1230. Z     -m) MAPDIR=$2; shift 2;;
  1231. Z     -w) WORKDIR=$2; shift 2;;
  1232. Z     -b) BATCH=$2; shift 2;;
  1233. Z     -u) USERNAME=$2; shift 2;;
  1234. Z     -n) NEWSGROUPS=$2; shift 2;;
  1235. Z     --) shift; break;;
  1236. Z     esac
  1237. Z done
  1238. Z if [ "$#" -ne 0 ]; then
  1239. Z     echo $USAGE 1>&2
  1240. Z     exit 2
  1241. Z fi
  1242. Z if [ "$BATCH" = "-" ]; then    # catch stdin case
  1243. Z     BATCH=
  1244. Z fi
  1245. Z if [ "$USERNAME" = "-" ]; then    # catch the cat errors to stderr case
  1246. Z     REPORT="cat 1>&2"
  1247. Z else
  1248. Z     REPORT="/usr/local/lib/sendmail -i -t"
  1249. Z fi
  1250. Z # set locations now that we have the flags
  1251. Z #
  1252. Z LOG=$WORKDIR/getmap.log
  1253. Z ERROR_LOG=$WORKDIR/getmap.err
  1254. Z REBUILD=$WORKDIR/getmap.rebuild
  1255. Z # be sure the working file does not exist, unless we read from stdin
  1256. Z #
  1257. Z if [ ! -z "$BATCH" ]; then
  1258. Z     BATCH_TMP="$BATCH".work
  1259. Z     if [ -f "$BATCH_TMP" ]; then
  1260. Z         echo "$PROG: working batch file $BATCH_TMP exists" 1>&2
  1261. Z         echo "$PROG: remove $BATCH_TMP by hand if stale" 1>&2
  1262. Z         exit 3
  1263. Z     fi
  1264. Z fi
  1265. Z # setup log files
  1266. Z #
  1267. Z if [ ! -z "$BATCH" ]; then
  1268. Z     BATCH_MSG="$PROG: starting work on $BATCH at `date`"
  1269. Z else
  1270. Z     BATCH_MSG="$PROG: starting work on [stdin] at `date`"
  1271. Z fi
  1272. Z echo "$BATCH_MSG" > $ERROR_LOG
  1273. Z if [ "$?" -ne 0 ]; then
  1274. Z     echo "$PROG: can not clear $ERROR_LOG" 1>&2
  1275. Z     exit 4
  1276. Z fi
  1277. Z touch $LOG 2>/dev/null
  1278. Z if [ "$?" -ne 0 ]; then
  1279. Z     echo "$PROG: can not write to $LOG" 1>&2
  1280. Z     echo "$PROG: can not write to $LOG" >> $ERROR_LOG
  1281. Z     (if [ "$USERNAME" != "-" ]; then
  1282. Z     echo "To: $USERNAME"
  1283. Z     echo "Subject: getmap error"
  1284. Z     echo ""
  1285. Z     echo ""
  1286. Z      fi
  1287. Z      echo "getmap error log follows -----"
  1288. Z      cat $ERROR_LOG
  1289. Z      echo "end of getmap error log =====") | eval "$REPORT"
  1290. Z     exit 5
  1291. Z fi
  1292. Z # save the batch file, if not from stdin
  1293. Z #
  1294. Z if [ ! -z "$BATCH" ]; then
  1295. Z     # do nothing if no batch file or no work in the batch file
  1296. Z     if [ ! -f "$BATCH" -o ! -s "$BATCH" ]; then
  1297. Z     echo "$PROG: no work in $BATCH" >> $LOG
  1298. Z     rm -f $ERROR_LOG
  1299. Z         exit 0
  1300. Z     fi
  1301. Z     mv $BATCH $BATCH_TMP
  1302. Z     if [ "$?" -ne 0 ]; then
  1303. Z         echo "$PROG: could not move $BATCH to $BATCH_TMP" 1>&2
  1304. Z         echo "$PROG: could not move $BATCH to $BATCH_TMP" >> $ERROR_LOG
  1305. Z     (if [ "$USERNAME" != "-" ]; then
  1306. Z         echo "To: $USERNAME"
  1307. Z         echo "Subject: getmap error"
  1308. Z         echo ""
  1309. Z         echo ""
  1310. Z      fi
  1311. Z      echo "getmap error log follows -----"
  1312. Z      cat $ERROR_LOG
  1313. Z      echo "end of getmap error log =====") | eval "$REPORT"
  1314. Z     cat $ERROR_LOG >> $LOG
  1315. Z     exit 6
  1316. Z     fi
  1317. Z # if work from stdin, prep a file to be used to save a copy
  1318. Z #
  1319. Z else
  1320. Z     BATCH_TMP=$WORKDIR/getmap.in$$
  1321. Z     cat /dev/null > $BATCH_TMP
  1322. Z     if [ "$?" -ne 0 ]; then
  1323. Z         echo "$PROG: could not clear $BATCH_TMP to hold a copy of [stdin]" 1>&2
  1324. Z         echo "$PROG: could not clear $BATCH_TMP to hold a copy of [stdin]" >> $ERROR_LOG
  1325. Z     (if [ "$USERNAME" != "-" ]; then
  1326. Z         echo "To: $USERNAME"
  1327. Z         echo "Subject: getmap error"
  1328. Z         echo ""
  1329. Z         echo ""
  1330. Z      fi
  1331. Z      echo "getmap error log follows -----"
  1332. Z      cat $ERROR_LOG
  1333. Z      echo "end of getmap error log =====") | eval "$REPORT"
  1334. Z     cat $ERROR_LOG >> $LOG
  1335. Z     exit 7
  1336. Z     fi
  1337. Z fi
  1338. Z # process the map artcile files
  1339. Z #
  1340. Z if [ ! -z "$BATCH" ]; then
  1341. Z     $UNSHAR -d $MAPDIR -n $NEWSGROUPS < $BATCH_TMP >> $ERROR_LOG
  1342. Z     STATUS=$?
  1343. Z else
  1344. Z     tee -a $BATCH_TMP | $UNSHAR -d $MAPDIR >> $ERROR_LOG
  1345. Z     STATUS=$?
  1346. Z fi
  1347. Z # note if we unpacked anything
  1348. Z if [ -s "$BATCH_TMP" ]; then
  1349. Z     touch $REBUILD
  1350. Z fi
  1351. Z # log the activity
  1352. Z #
  1353. Z cat $ERROR_LOG >> $LOG
  1354. Z # post processing - look for errors to report
  1355. Z #
  1356. Z if [ "$STATUS" -ne 0 ]; then
  1357. Z     # form the mail message header
  1358. Z     (if [ "$USERNAME" != "-" ]; then
  1359. Z     echo "To: $USERNAME"
  1360. Z     echo "Subject: getmap error"
  1361. Z     echo ""
  1362. Z     echo ""
  1363. Z      fi
  1364. Z      echo "getmap error log follows -----"
  1365. Z      cat $ERROR_LOG
  1366. Z      echo "end of getmap error log ====="
  1367. Z      echo ""
  1368. Z      echo ""
  1369. Z      if [ ! -z "$BATCH" ]; then
  1370. Z          echo "$BATCH_TMP work queue follows -----"
  1371. Z          cat $BATCH_TMP
  1372. Z          echo "end of $BATCH_TMP work queue ====="
  1373. Z      else
  1374. Z          echo "[stdin] work queue follows -----"
  1375. Z      cat $BATCH_TMP
  1376. Z          echo "end of [stdin] work queue ====="
  1377. Z      fi) | eval "$REPORT"
  1378. Z else
  1379. Z     rm -f $ERROR_LOG    # no error, so remove the error log
  1380. Z fi
  1381. Z rm -f $BATCH_TMP
  1382. Z exit 0
  1383. ----SHAR-EOF----
  1384. if test 6008 -ne "`wc -c getmap`"
  1385. then
  1386. echo shar: Uebertragungsfehler in getmap '(Soll-Laenge = 6008 Zeichen)'
  1387. fi
  1388. echo shar: Extraktion von patch.README
  1389. sed 's/^Z //' << \----SHAR-EOF---- > patch.README
  1390. Z From: Matthias Urlichs <urlichs@smurf.sub.org>
  1391. Z Newsgroups: sub.os.unix
  1392. Z Subject: Re: Map-Unpacker
  1393. Z In sub.os.unix, Artikel <1672@chiuur.chi.sub.org>,
  1394. Z   schreibt maps@chi.sub.org (Christian Kaiser):
  1395. Z [ unsharmap deleted ]
  1396. Z Wer die Maps alternativ gleich aus sub.config.maps raussaugen will, kann
  1397. Z folgenden Patch applizieren:
  1398. Z In der /usr/lib/news/sys-Datei (oder wo auch immer -- bei mir heisst das Ding
  1399. Z momentan /usr/local/news/c/admin/sys ;-) ) steht dann noch ein
  1400. Z map:world,sub,!sub.all,sub.config.maps.ctl::/usr/local/mail/bin/unsharmap -p -n sub.config.maps -d /usr/local/mail/map
  1401. Z Sicherheitsfanatiker machen dann noch ein (bzw. drei :-)
  1402. Z chown mail unsharmap
  1403. Z chgrp news unsharmap
  1404. Z chmod 6750 unsharmap
  1405. Z Die Maps liegen dann gleich ausgepackt im richtigen Verzeichnis.
  1406. Z Ach ja, den Pathalias laesst man am besten zur selben Zeit laufen wie den
  1407. Z Expire, damit es keine Probleme mit halben Maps gibt...
  1408. Z -p heisst "Pipe". Ein "-" konnte ich nicht verwenden, weil einige
  1409. Z getopt-Implementationen das missverstehen.
  1410. ----SHAR-EOF----
  1411. if test 1011 -ne "`wc -c patch.README`"
  1412. then
  1413. echo shar: Uebertragungsfehler in patch.README '(Soll-Laenge = 1011 Zeichen)'
  1414. fi
  1415. #    Ende des Shell Archivs
  1416. exit 0
  1417.  
  1418. -->
  1419. Peter Funk \\ ArtCom GmbH, Schwachhauser Heerstr. 78, D-2800 Bremen 1
  1420. Work at home: Oldenburger Str.86, D-2875 Ganderkesee 1 /+49 4222 6018 (8am-6pm)
  1421.  
  1422.