home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-11-21 | 42.4 KB | 1,536 lines |
- Article 1644 of sub.config:
- Path: xenon!nadia!doitcr!tmpmbx!mcshh!artcom0!pf
- From: pf@artcom0.artcom.north.de (Peter Funk)
- Newsgroups: sub.config,dnet.and.sub.general
- Subject: REPOST: unpack-map Paket
- Summary: unsharmap -- Dank makefile auf Xenix kinderleicht zu installieren
- Keywords: Mail-Maps, Automatik, Aktualisierung
- Message-ID: <2062@artcom0.artcom.north.de>
- Date: 1 Jun 90 00:31:19 GMT
- Followup-To: poster
- Distribution: sub,dnet
- Organization: ArtCom GmbH, Atelier f. Computergrafik, Bremen(FRG)
- Lines: 1519
- Flames-To: poster
-
- Da ich auf meine Ankuendigung kein Gemeckere und nur Zustimmung gehoert
- habe, hier der REPOST des 'unsharmap'-Paketes. Die Installation ist
- zumindest unter SCO Xenix 386 kinderleicht. Wer schon 'nn6.4' laufen
- hat, braucht jetzt nur ':unshar' einzutippen und dann in dem
- betreffenden Directory 'make' aufzurufen.
-
- Okay, hier isses ...
-
- # Dies ist ein UNIX-Shell Archiv.
- # Loesche alles ueber und einschliesslich der Schnittzeile.
- # Dann lasse den Rest der Datei durch sh laufen.
- #----schnitt-----schnippel-----fetz-----reiz-----schnitz----
- : /bin/sh
- # shar: UNIX-Shell Archivier-Programm
- # Bei Ausfuehrung dieses Textes durch /bin/sh enstehen die Dateien :
- # README
- # map.daily
- # mkpaths
- # Makefile
- # unsharmap.c
- # install
- # avoid-unido
- # getmap
- # patch.README
- # Dieses Archiv wurde erzeugt : Fri Jun 1 02:28:27 1990
- echo shar: Extraktion von README
- sed 's/^Z //' << \----SHAR-EOF---- > README
- Z # Title : README - unpack-map
- Z # Version : Sat, 26-May-90 / 12:55 / (pf@artcom0)
- Z
- Z Das Paket 'unpack-map' dient zum automatischen Aktualisieren der
- Z EMail-Routing Database (/usr/lib/uucp/paths) anhand der regelmaessigen
- Z Postings in 'sub.config.maps'.
- Z
- Z Ich habe dieses Unsharmap-Paket hier an meine speziellen
- Z SCO-Xenix 386 Beduerfnisse und meine Directory-Struktur
- Z angepasst und zwecks leichterer Installation um ein paar
- Z Shell-Skripte und ein Makefile erweitert. Das in der
- Z Original-Version mitgelieferte Skript 'getmap' wird
- Z hier nicht mehr benoetigt, ist aber aus Gruenden
- Z der Vollstaendigkeit dabei belassen. Wer es so wie
- Z ich nicht braucht, kann es einfach loeschen.
- Z
- Z Die Installation ist sehr einfach, wenn man sowieso schon 'smail2.5',
- Z 'pathalias' und 'news' laufen hat. :
- Z
- Z make
- Z make install
- Z make clobber
- Z
- Z Danach kann man dieses Directory wieder einpacken und irgendwo
- Z verstauen. Will man die eintrudelden Maps kontrollieren,
- Z kann man dies tun, da sie im Verzeichnis /usr/lib/uucp/maps/work
- Z stehen bleiben. Erst durch 'map.daily' werden sie an Ort und
- Z Stelle 'gemoved' und dann eine neue 'paths'-Datei generiert.
- Z Vertraut man der Moderation von 'sub.config.maps', kann man
- Z einfach wie ich das 'map.daily' in die 'root'-crontab eintragen.
- Z
- Z Wer trotzdem auf Nummer sicher gehen will, kann sich ein Directory
- Z /usr/lib/uucp/oldmaps einrichten, in dem man eine gewisse Anzahl
- Z von Sicherheitskopien alter (vorhergehender) Maps aufbewahren kann.
- Z Details dazu sind in 'map.daily' dokumentiert.
- Z
- Z Einige Geschmackssachen (oder Portabilitaetsprobleme) :
- Z -------------------------------------------------------
- Z Ein Veraendern des Paketes auf eine andere Directory-Struktur
- Z (bei mir stehen die benutzten Maps alle in /usr/lib/uucp/maps und
- Z das Executable in /usr/local/bin) sollte Dank der SHELL-Variablen
- Z mit maessigem Editier-Aufwand moeglich sein.
- Z
- Z Veraendert werden muessten dazu die Dateien :
- Z install
- Z map.daily
- Z mkpaths
- Z
- Z Wenn man 'C'-News hat, wird das 'sys'-File vielleicht sonstwo liegen.
- Z Dann muss man dies natuerlich auch in 'install' abaendern.
- Z --
- Z Peter Funk / ArtCom GmbH, Schwachhauser Heerstr. 78, D-2800 Bremen 1
- Z Work at home/ Oldenburger Str.86, D-2875 Ganderkesee 1 /+49 4222 6018 (8am-6pm)
- Z pf@artcom0.artcom.north.de
- ----SHAR-EOF----
- if test 2252 -ne "`wc -c README`"
- then
- echo shar: Uebertragungsfehler in README '(Soll-Laenge = 2252 Zeichen)'
- fi
- echo shar: Extraktion von map.daily
- sed 's/^Z //' << \----SHAR-EOF---- > map.daily
- Z :
- Z # ------------------------------------------------------------------
- Z # Title : map.daily -- automatically install new maps
- Z # Usage : map.daily [ -v ] [ -V ]
- Z # Options : -v : Verbose mode, show up "no op" invocation
- Z # -V : Very Verbose Mode
- Z # Version : Sat, 26-May-90 / 11:45 / (root@artcom0)
- Z # Remarks : You may create a directory /usr/lib/uucp/oldmaps
- Z # with some numerical named subdirectories. e.g.
- Z # /usr/lib/uucp/oldmaps/0
- Z # /usr/lib/uucp/oldmaps/1 ...
- Z # Older maps will be preserved there.
- Z # These directories should be owned by 'news' and
- Z # should also have write-Permissions, if You don't
- Z # want to run this script here under 'root' !
- Z # If you don't trust new maps, You may also choose
- Z # the '-V' option, and You will get a diff mail,
- Z # whenever there are new maps arrived !
- Z # ------------------------------------------------------------------
- Z if [ "$1" = "-v" ]
- Z then VERBOSE=TRUE
- Z shift
- Z else VERBOSE=
- Z fi
- Z if [ "$1" = "-V" ]
- Z then VERBOSE=Talkative
- Z shift
- Z fi
- Z MAPDIR=/usr/lib/uucp/maps
- Z OLDMAPS=/usr/lib/uucp/oldmaps
- Z cd $MAPDIR/work
- Z # --- Do the installation
- Z NEWMAPS=
- Z for i in * ; do
- Z if [ "$i" = "*" ]
- Z then if [ "$VERBOSE" ]
- Z then echo "No new maps arrived !"
- Z fi
- Z exit 0
- Z fi
- Z # -- preserve old maps
- Z for olddirnum in 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 ; do
- Z OLDMAPDIR=$OLDMAPS/$olddirnum
- Z if [ -d $OLDMAPDIR ]
- Z then if [ $olddirnum -gt 0 ]
- Z then prevdirnum=`expr $olddirnum - 1`
- Z PREVDIR=$OLDMAPS/$prevdirnum
- Z else PREVDIR=$MAPDIR
- Z fi
- Z if [ -f $PREVDIR/$i ]
- Z then mv $PREVDIR/$i $OLDMAPDIR/$i
- Z fi
- Z fi
- Z done
- Z mv $i $MAPDIR
- Z NEWMAPS="$NEWMAPS $i"
- Z done
- Z # -- mail significant map changes as diff to the postmaster :
- Z if [ "$VERBOSE" = "Talkative" ] && [ -d $OLDMAPS/0 ]
- Z then if [ -x /usr/local/bin/gdiff ]
- Z then /usr/local/bin/gdiff -r -c $OLDMAPS/0 $MAPDIR
- Z else cd $MAPDIR
- Z for i in $NEWMAPS ; do
- Z if [ -r $OLDMAPS/0/$i ]
- Z then echo "--- $i Differences: ---"
- Z diff $OLDMAPS/0/$i $i
- Z else echo "--- $i is a new map file ! ---"
- Z fi
- Z done
- Z fi | mail -s "Map Changes" postmaster
- Z fi
- Z # -- regenerate the paths database :
- Z cd $MAPDIR
- Z ./mkpaths
- ----SHAR-EOF----
- if test 2232 -ne "`wc -c map.daily`"
- then
- echo shar: Uebertragungsfehler in map.daily '(Soll-Laenge = 2232 Zeichen)'
- fi
- echo shar: Extraktion von mkpaths
- sed 's/^Z //' << \----SHAR-EOF---- > mkpaths
- Z : use /bin/sh
- Z # ------------------------------------------------------------------------------
- Z # Title : mkpaths -- Create a new paths data base from diverse map files
- Z # Version : Sat, 26-May-90 / 11:29 / (pf@artcom0)
- Z # Portability : Bourne Shell SCO Xenix 2.3
- Z # Usage : mkpaths [ "test" [ <rechnername> ] ]
- Z # Durch den Aufruf 'mkpaths test kiste' kann man sich die von 'kiste'
- Z # aus generierten Pfade im Pager anschauen. Das ist manchmal ganz
- Z # praktisch.
- Z # ------------------------------------------------------------------------------
- Z PATH="$PATH:/usr/local/bin"
- Z MAPDIR=/usr/lib/uucp/maps
- Z PATHS=/usr/lib/uucp/paths
- Z if [ -x /usr/local/bin/less ]
- Z then PAGER="/usr/local/bin/less -e"
- Z else PAGER=more
- Z fi
- Z # --- Es gibt die Konvention, das alle Pathalias Eingabe-Dateien mit
- Z # 'd.' oder 'u.' beginnen.
- Z # Die Map-Dateien des 'Sub-Netzes' heissen 'u.sub.*'.
- Z # Lokale Map-Daten sollte man in 'u.local' halten.
- Z MAPS="u.* d.*"
- Z # --- Wenn kein Rechnername angegeben ist, dann benutze das 'uuname'-Kommando
- Z # (Wie geht das auf NICHT-Xenix Systemen ?)
- Z if [ "$2" ]
- Z then HOST=$2
- Z else HOST=`uuname -l`
- Z fi
- Z # ---
- Z cd $MAPDIR
- Z echo ".UUCP %s" > paths
- Z pathalias -l $HOST $MAPS | /bin/sort >> paths
- Z if [ "$1" != "test" ]
- Z then # -- The following 'cat' will preserve permissions and links to the
- Z # system path data base, which would have been lost, if we had used
- Z # a simple 'mv paths $PATHS' ...
- Z cat paths > $PATHS
- Z rm -f paths
- Z # -- The following is just for safety (If 'paths' did not exist before !) :
- Z chown mail $PATHS ; chgrp news $PATHS ; chmod 664 $PATHS
- Z else # -- Don't install 'paths', just view it :
- Z chmod +r paths
- Z $PAGER paths
- Z # You may consider to remove the paths file afterwards :
- Z # rm -f paths
- Z mv paths /tmp/paths.$HOST
- Z exit 0
- Z fi
- ----SHAR-EOF----
- if test 1826 -ne "`wc -c mkpaths`"
- then
- echo shar: Uebertragungsfehler in mkpaths '(Soll-Laenge = 1826 Zeichen)'
- fi
- echo shar: Extraktion von Makefile
- sed 's/^Z //' << \----SHAR-EOF---- > Makefile
- Z # Makefile for unsharmap under SCO XENIX 386
- Z #
- Z # Version : Wed, 16-May-90 / 19:11 / (pf@artcom0)
- Z # Documented for net distribution.
- Z
- Z # Things to do:
- Z # make make executables
- Z # make all " "
- Z # make install perform XENIX installation
- Z # make clean cleanup this directory
- Z # make clobber clean ...and remove executables from this dir
- Z # make shar create a file 'unpack-map.sha'
- Z
- Z SHELL= /bin/sh
- Z CFLAGS = -O
- Z
- Z OBJECTS = unsharmap.o
- Z
- Z all: unsharmap
- Z
- Z unsharmap: $(OBJECTS)
- Z cc $(CFLAGS) $(OBJECTS) -o unsharmap
- Z
- Z $(OBJECTS):
- Z cc $(CFLAGS) -c $<
- Z
- Z clean:
- Z rm -f *.o *.ln a.out core
- Z
- Z clobber: clean
- Z rm -f unsharmap
- Z
- Z install: all
- Z ./install
- Z
- Z shar:
- Z shar -cgvp'Z ' README map.daily mkpaths Makefile \
- Z unsharmap.c install avoid-unido \
- Z getmap patch.README > unpack-map.sha
- ----SHAR-EOF----
- if test 801 -ne "`wc -c Makefile`"
- then
- echo shar: Uebertragungsfehler in Makefile '(Soll-Laenge = 801 Zeichen)'
- fi
- echo shar: Extraktion von unsharmap.c
- sed 's/^Z //' << \----SHAR-EOF---- > unsharmap.c
- Z /* @(#)unsharmap.c 1.6 2/5/89 14:14:01 */
- Z /*
- Z * Copyright (C) 1988 Ronald S. Karr and Landon Curt Noll
- Z *
- Z * See the file COPYING, distributed with smail, for restriction
- Z * and warranty information.
- Z */
- Z
- Z /*
- Z * unsharmap - unshar a USENET comp.news.maps article
- Z *
- Z * usage: unsharmap [-d dir] < filelist > log
- Z *
- Z * -d dir - cd to 'dir' before unsharing
- Z * -n newsgroups - colon separated list of allowed newsgroups
- Z * -p - use stdin (for piped input from 'sys')
- Z *
- Z * where "filelist" contains a list of files that are in the format below.
- Z *
- Z * The USENET map project distributes files in the following format:
- Z *
- Z * The header, which starts at the firts line and continues up until
- Z * there is a blank line as the follow lins it:
- Z *
- Z * Newsgroups: comp.mail.maps
- Z * Subject: UUCP ...
- Z * Message-ID: ...
- Z * Date: ...
- Z * Approved: ...
- Z *
- Z * These lines are not the complete list, nor do they show up in that order.
- Z * After the header is a blank line. Next comes the shar file preamble
- Z * which consists of a bunch of lines that begin with a :, followed
- Z * by the 2 lines:
- Z *
- Z * echo shar: extracting THE-FILE-NAME
- Z * cat << 'SHAR_EOF' > THE-FILE-NAME
- Z *
- Z * what follows is the map data intended to override THE-FILE-NAME in the
- Z * UNSHAR_MAP_DIR directory. The final 3 lines:
- Z *
- Z * SHAR_EOF
- Z * : End of shell archive
- Z * exit 0
- Z *
- Z * terminate the shar file, and are not considered a part of the map data.
- Z *
- Z * For each shar file processed, the following information is written
- Z * to stdout:
- Z *
- Z * filename read
- Z * filename written
- Z * subject line
- Z * message-ID
- Z * date
- Z * approved info
- Z * any error message
- Z *
- Z * All error message lines begin with 'error:'.
- Z *
- Z * exits by 0 if there was no errors, non-0 otherwise.
- Z */
- Z
- Z #include <stdio.h>
- Z
- Z #define HEADER_OK 1 /* the article header is correct */
- Z #define HEADER_ERROR 2 /* bad header, skip and log */
- Z #define HEADER_SKIP 3 /* not a map shar, ignore file */
- Z
- Z char *program; /* our name */
- Z char err[BUFSIZ+1]; /* error and log message */
- Z char buf[BUFSIZ+1]; /* input buffer */
- Z char mapname[BUFSIZ+1]; /* name of the output map file */
- Z int lineno = 0; /* current line number */
- Z char *newsgroups = "comp.mail.maps"; /* : list of allowed newsgroups */
- Z
- Z char *get_date(); /* system dependent date string */
- Z void log(); /* write to log and error log */
- Z int check_header(); /* check the article header */
- Z void skip_article(); /* skip a bad article */
- Z void ignore_article(); /* ignore the non-map article */
- Z char *check_preamble(); /* check shar preamble, get map name */
- Z int write_map(); /* write a map file */
- Z char *check_newline(); /* check to be sure we read a '\n' */
- Z
- Z char *xmalloc(); /* for string.c and strcolon()*/
- Z char *xrealloc(); /* for string.c and strcolon() */
- Z
- Z extern char *strcolon(); /* grap strcolon() from src/string.c */
- Z
- Z main( argc, argv )
- Z int argc; /* arg count */
- Z char *argv[]; /* args */
- Z {
- Z char filename[BUFSIZ+1]; /* name of the input article */
- Z char *p; /* pointer */
- Z int c; /* the option flag */
- Z int header; /* HEADER_OK,ERROR,SKIP */
- Z int errors=0; /* number of problems found */
- Z int stdinfile; /* get just one file from std input */
- Z FILE *article; /* input article stream */
- Z extern char *optarg; /* the option argument */
- Z extern int optind; /* operand index */
- Z
- Z /*
- Z * parse args
- Z */
- Z program = argv[0];
- Z while ((c = getopt(argc, argv, "pd:n:")) != EOF) {
- Z switch(c) {
- Z case 'p':
- Z stdinfile = 1;
- Z break;
- Z case 'd': /* directory to cd to */
- Z if (chdir(optarg) < 0) {
- Z sprintf(err, "error: can not cd to %s\n", optarg);
- Z log(err);
- Z sprintf(err, "exiting: status: 5 - %s", get_date());
- Z log(err);
- Z exit(5);
- Z }
- Z break;
- Z case 'n':
- Z newsgroups = optarg;
- Z break;
- Z
- Z case '?':
- Z sprintf(err,
- Z "error: usage: %s [-d dir] < filelist > log 2> error\n",
- Z program);
- Z log(err);
- Z sprintf(err, "exiting: status: 1 - %s", get_date());
- Z log(err);
- Z exit(1);
- Z break;
- Z }
- Z }
- Z if (optind != argc) {
- Z sprintf(err, "error: usage: %s [-d dir] < filelist > log 2> error\n",
- Z program);
- Z log(err);
- Z sprintf(err, "exiting: status: 1 - %s", get_date());
- Z log(err);
- Z exit(1);
- Z }
- Z
- Z
- Z /*
- Z * process all file names on input
- Z */
- Z sprintf(err, "starting: %s", get_date());
- Z log(err);
- Z while (stdinfile || fgets(filename, BUFSIZ, stdin) != NULL) {
- Z
- Z if(!stdinfile){
- Z /*
- Z * open the map file
- Z */
- Z lineno = 0; /* clear the line count */
- Z if ((p = check_newline(filename)) == NULL) {
- Z sprintf(err, "error: filename longer than %d chars\n",
- Z program, BUFSIZ-2);
- Z log(err);
- Z sprintf(err, "exiting: status: 2 - %s", get_date());
- Z log(err);
- Z exit(2);
- Z }
- Z *p = '\0'; /* remove the newline from the filename */
- Z if ((article = fopen(filename, "r")) == NULL) {
- Z sprintf(err, "error: can not open: %s\n", filename);
- Z log(err);
- Z ++errors;
- Z continue;
- Z }
- Z sprintf(err, "filename: %s\n", filename);
- Z log(err);
- Z } else {
- Z strcpy(filename,"stdin");
- Z article = stdin;
- Z }
- Z /*
- Z * verify the article header
- Z *
- Z * close file if error or skip
- Z */
- Z switch (header = check_header(article)) {
- Z case HEADER_OK: /* we have a good header */
- Z break;
- Z case HEADER_ERROR: /* the article is bad, skip & log */
- Z skip_article(article, filename);
- Z ++errors;
- Z break;
- Z case HEADER_SKIP: /* not a map article, ignore it */
- Z ignore_article(article, filename);
- Z break;
- Z default: /* how did we get here? */
- Z sprintf(err, "error: check_header returned %d, why?\n", header);
- Z log(err);
- Z sprintf(err, "exiting: status: 3 - %s", get_date());
- Z log(err);
- Z exit(3);
- Z }
- Z if (header != HEADER_OK) {
- Z continue; /* try another file */
- Z }
- Z
- Z /*
- Z * check the shar preamble, get the shar file name
- Z */
- Z if (check_preamble(article) == NULL) {
- Z skip_article(article, filename);
- Z ++errors;
- Z continue;
- Z }
- Z
- Z if(stdinfile) strcpy(filename,mapname);
- Z /*
- Z * write the map, verify final lines
- Z */
- Z if (write_map(article) != 0) {
- Z skip_article(article, filename);
- Z ++errors;
- Z continue;
- Z }
- Z
- Z /*
- Z * all done with this article
- Z */
- Z fclose(article);
- Z fflush(stdout);
- Z if(stdinfile)break;
- Z }
- Z
- Z /*
- Z * note if everything went ok
- Z */
- Z sprintf(err, "exiting: status: %d - %s", (errors>0) ? 4 : 0, get_date());
- Z log(err);
- Z exit( (errors>0) ? 4 : 0 );
- Z }
- Z
- Z
- Z /*
- Z * get_date - get the date followed by newline in the standard way
- Z *
- Z * returns the date in ctime(3) format
- Z */
- Z char *
- Z get_date()
- Z {
- Z extern long time();
- Z long clock = time((long *)0); /* seconds since 1-jan-1970 0:00:00 GMT */
- Z char *ctime(); /* convert clock into string */
- Z
- Z return(ctime(&clock));
- Z }
- Z
- Z
- Z /*
- Z * log - write a message to the log
- Z */
- Z void
- Z log( msg )
- Z char *msg; /* the message to write */
- Z {
- Z /* write to the log */
- Z fputs(msg, stdout);
- Z }
- Z
- Z
- Z /*
- Z * check_header - check the article header
- Z *
- Z * This routine verifies that a article header has the following lines:
- Z *
- Z * Newsgroups: comp.mail.maps
- Z * Subject: UUCP ...
- Z * Message-ID: ...
- Z * Date: ...
- Z * Approved: ...
- Z *
- Z * The text of all but the Newsgroups lines are logged. If the Newsgroups
- Z * line is bad, that too is logged. The header ends before a blank line.
- Z * The final blank line is read and discarded.
- Z *
- Z * returns HEADER_OK is all 5 header lines were read and were valid,
- Z * HEADER_ERROR is the header was bad and needs to be skipped & logged,
- Z * HEADER_SKIP if the file is not a UUCP shar file and should be skipped
- Z */
- Z int
- Z check_header( article )
- Z FILE *article; /* the article stream */
- Z {
- Z int saw_groups=0; /* 1 ==> saw Newsgroups: */
- Z int saw_subject=0; /* 1 ==> saw Subject: */
- Z int saw_message=0; /* 1 ==> saw Message-ID: */
- Z int saw_date=0; /* 1 ==> saw Date: */
- Z int saw_approved=0; /* 1 ==> saw Approved: */
- Z char *p; /* temp */
- Z
- Z /*
- Z * read the header
- Z */
- Z do {
- Z /*
- Z * read the line
- Z */
- Z clearerr(article);
- Z if (fgets(buf, BUFSIZ, article) == NULL) {
- Z if (ferror(article)) {
- Z sprintf(buf, "error: bad header read after line %d\n", lineno);
- Z log(err);
- Z } else {
- Z log("error: EOF while reading the header\n");
- Z }
- Z return(HEADER_ERROR);
- Z }
- Z ++lineno; /* count this line */
- Z if (! check_newline(buf)) {
- Z sprintf(err, "error: line %d, header line too long\n", lineno);
- Z log(err);
- Z return(HEADER_ERROR);
- Z }
- Z
- Z /*
- Z * look for special types
- Z */
- Z switch (buf[0]) {
- Z case 'n':
- Z case 'N': /* could be Newsgroups: */
- Z if (strncmpic("Newsgroups: ", buf, 12) == 0) {
- Z for (p = strcolon(newsgroups); p; p = strcolon((char *)NULL)) {
- Z if (strncmpic(buf + 12, p, strlen(p)) == 0 &&
- Z buf[12 + strlen(p)] == '\n')
- Z {
- Z break;
- Z }
- Z }
- Z if (p != NULL) {
- Z saw_groups = 1;
- Z } else {
- Z sprintf(err, "error: line %d, bad %s", lineno, buf);
- Z log(err);
- Z return(HEADER_ERROR);
- Z }
- Z }
- Z break;
- Z case 's':
- Z case 'S': /* Subject: buf */
- Z if (strncmpic("Subject: ", buf, 9) == 0) {
- Z if (strncmpic("Subject: UUCP ", buf, 14) == 0) {
- Z saw_subject = 1;
- Z log(" ");
- Z log(buf);
- Z } else {
- Z log(" ");
- Z log(err);
- Z return(HEADER_SKIP); /* not a shar map file */
- Z }
- Z }
- Z break;
- Z case 'm':
- Z case 'M': /* Message-ID: buf */
- Z if (strncmpic("Message-ID: ", buf, 12) == 0) {
- Z saw_message = 1;
- Z log(" ");
- Z log(buf);
- Z }
- Z break;
- Z case 'd':
- Z case 'D': /* Message-ID: buf */
- Z if (strncmpic("Date: ", buf, 6) == 0) {
- Z saw_date = 1;
- Z log(" ");
- Z log(buf);
- Z }
- Z break;
- Z case 'a':
- Z case 'A': /* Message-ID: buf */
- Z if (strncmpic("Approved: ", buf, 10) == 0) {
- Z saw_approved = 1;
- Z log(" ");
- Z log(buf);
- Z }
- Z break;
- Z }
- Z
- Z } while(strcmp("\n", buf) != 0); /* while heading the header */
- Z
- Z /*
- Z * report if er got everything
- Z */
- Z if (saw_groups == 0) {
- Z log("error: no Newsgroups: line\n");
- Z return(HEADER_ERROR);
- Z }
- Z if (saw_subject == 0) {
- Z log("error: no Subject: line\n");
- Z return(HEADER_ERROR);
- Z }
- Z if (saw_message == 0) {
- Z log("error: no Message-ID: line\n");
- Z return(HEADER_ERROR);
- Z }
- Z if (saw_date == 0) {
- Z log("error: no Date: line\n");
- Z return(HEADER_ERROR);
- Z }
- Z if (saw_approved == 0) {
- Z log("error: no Approved: line\n");
- Z return(HEADER_ERROR);
- Z }
- Z return(HEADER_OK); /* passed all the tests */
- Z }
- Z
- Z /*
- Z * skip_article - skip article, log and close it
- Z */
- Z void
- Z skip_article( article, filename )
- Z FILE *article; /* the article stream */
- Z char *filename; /* the filename we are skipping */
- Z {
- Z /*
- Z * log that we are skipping the remainder of the article
- Z */
- Z sprintf(err, " skipping: %s after reading line %d\n", filename, lineno);
- Z log(err);
- Z
- Z /*
- Z * close the stream
- Z */
- Z fclose(article);
- Z
- Z /*
- Z * report the close
- Z */
- Z sprintf(err, "finished: %s\n", filename);
- Z log(err);
- Z return;
- Z }
- Z
- Z
- Z /*
- Z * ingore_article - ignore an article, close and report it
- Z */
- Z void
- Z ignore_article( article, filename )
- Z FILE *article; /* the article stream */
- Z char *filename; /* the filename we are skipping */
- Z {
- Z /*
- Z * log that we are ignoring the remainder of the article
- Z */
- Z sprintf(err, " ignore non map file: %s after reading line %d\n",
- Z filename, lineno);
- Z log(err);
- Z
- Z /*
- Z * close the stream
- Z */
- Z fclose(article);
- Z
- Z /*
- Z * report the close
- Z */
- Z sprintf(err, "finished: %s\n", filename);
- Z log(err);
- Z return;
- Z }
- Z
- Z
- Z /*
- Z * check_preamble - check for a valid shar preamble
- Z *
- Z * The shar preamble consists of a bunch of lines that begin with :,
- Z * followed by the 2 lines:
- Z *
- Z * echo shar: extracting THE-FILE-NAME
- Z * cat << 'SHAR_EOF' > THE-FILE-NAME
- Z *
- Z * Any other line is printed to both logs as an error. The "THE-FILE-NAME"
- Z * string is returned if a valid preamble is found, NULL otherwise.
- Z */
- Z char *
- Z check_preamble( article )
- Z FILE *article; /* the article stream */
- Z {
- Z char *p; /* pointer */
- Z char *q; /* pointer, NULL byte of mapname */
- Z int bad_echo=0; /* 1 ==> a bad echo was found */
- Z
- Z /*
- Z * read the preamble
- Z */
- Z mapname[0] = '\0'; /* no mapname yet */
- Z while (1) {
- Z /*
- Z * read the line
- Z */
- Z clearerr(article);
- Z if (fgets(buf, BUFSIZ, article) == NULL) {
- Z if (ferror(article)) {
- Z sprintf(err, "error: bad preamble read after line %d\n",
- Z lineno);
- Z log(err);
- Z } else {
- Z log("error: EOF while reading the preamble\n");
- Z }
- Z return(NULL);
- Z }
- Z ++lineno; /* count line */
- Z if (! check_newline(buf)) {
- Z sprintf(err, "error: line %d, preamble line too long\n", lineno);
- Z log(err);
- Z return(NULL);
- Z }
- Z
- Z /*
- Z * skip the : lines
- Z */
- Z if (buf[0] == ':') {
- Z continue;
- Z }
- Z
- Z /*
- Z * look for the echo line
- Z */
- Z if (strncmp("echo shar: extracting ", buf, 22) == 0) {
- Z /* grab the mapname */
- Z for (p=buf+22, q=mapname, bad_echo=0; *p; ++p) {
- Z /* be sure it is well formed */
- Z switch (*p) {
- Z case ' ':
- Z case '\t':
- Z bad_echo = 1; /* unlikely char in a filename */
- Z *q++ = *p;
- Z break;
- Z case '\n': /* should be the end */
- Z if (*(p+1) != '\0') {
- Z bad_echo = 1; /* why is '\n' not the end */
- Z }
- Z break; /* don't copy the newline */
- Z case '\\': /* avoid \ and / in filenames */
- Z case '/':
- Z bad_echo = 1;
- Z *q++ = *p;
- Z break;
- Z default:
- Z *q++ = *p;
- Z break;
- Z }
- Z }
- Z *q = '\0'; /* NULL terminate filename */
- Z
- Z /* verify mapname */
- Z if (bad_echo == 1) {
- Z sprintf(err, "error: line %d, bad echo mapname: %s\n",
- Z lineno, mapname);
- Z log(err);
- Z return(NULL); /* bad preamble */
- Z }
- Z
- Z /*
- Z * watch for the cat line
- Z */
- Z } else if (strncmp("cat << 'SHAR_EOF' > ", buf, 20) == 0) {
- Z
- Z /*
- Z * compare cat filename against echo filename
- Z */
- Z if (mapname[0] == '\0') {
- Z sprintf(err, "error: line %d, cat with no preceding echo: %s",
- Z lineno, buf);
- Z log(err);
- Z return(NULL); /* bad preamble */
- Z } else if (strncmp(buf+20, mapname, q-mapname) != 0) {
- Z sprintf(err,
- Z "error: line %d, echo mapname: %s != cat mapname: %s",
- Z lineno, mapname, buf+20);
- Z log(err);
- Z return(NULL); /* bad preamble */
- Z } else {
- Z return(mapname); /* found end of preamble */
- Z }
- Z
- Z /*
- Z * watch for unkown lines
- Z */
- Z } else {
- Z sprintf(err, "error: line %d, unknown preamble: %s", lineno, buf);
- Z log(err);
- Z return(NULL);
- Z }
- Z }
- Z /* NOT REACHED */
- Z }
- Z
- Z
- Z /*
- Z * write_map - write a map file
- Z *
- Z * Given an verified article header and shar preamble, copy the contents
- Z * of the shar HERE_IS document up until the ending shar lines:
- Z *
- Z * SHAR_EOF
- Z * : End of shell archive
- Z * exit 0
- Z *
- Z * A previous call to check_preamble placed the name of the mapfile in
- Z * the mapname array.
- Z *
- Z * returns 1 if all was ok, 0 otherwise.
- Z */
- Z int
- Z write_map( article )
- Z FILE *article; /* the article stream */
- Z {
- Z int fd; /* map file descriptor */
- Z FILE *map; /* the map file stream */
- Z
- Z /*
- Z * open and truncate the map file
- Z */
- Z fd = creat(mapname, 0644);
- Z if (fd < 0) {
- Z sprintf(err, "error: unable to creat/truncate %s\n", mapname);
- Z log(err);
- Z return(1);
- Z }
- Z map = fdopen(fd, "w");
- Z sprintf(err, "extracting: %s\n", mapname);
- Z log(err);
- Z
- Z /*
- Z * copy article shar data to the map file
- Z */
- Z while (1) {
- Z /*
- Z * read the line
- Z */
- Z clearerr(article);
- Z if (fgets(buf, BUFSIZ, article) == NULL) {
- Z if (ferror(article)) {
- Z sprintf(err, "error: bad map data read after line %d\n",
- Z lineno);
- Z log(err);
- Z } else {
- Z log("error: EOF while reading the map data\n");
- Z }
- Z return(1);
- Z }
- Z ++lineno;
- Z if (! check_newline(buf)) {
- Z sprintf(err, "error: line %d, map data line too long\n", lineno);
- Z log(err);
- Z return(1);
- Z }
- Z
- Z /*
- Z * watch for the end of the shar
- Z */
- Z if (strcmp("SHAR_EOF\n", buf) == 0) {
- Z /* end of the shar file */
- Z if (fclose(map) == EOF) {
- Z log("error: bad fclose\n");
- Z return(1);
- Z }
- Z mapname[0] = '\0';
- Z break; /* look for final two lines */
- Z }
- Z
- Z /*
- Z * write the line
- Z */
- Z if (fputs(buf, map) == EOF) {
- Z log("error: bad write\n");
- Z return(1);
- Z }
- Z }
- Z
- Z /*
- Z * verify the : line after the end of the map
- Z */
- Z clearerr(article);
- Z if (fgets(buf, BUFSIZ, article) == NULL) {
- Z if (ferror(article)) {
- Z sprintf(err, "error: bad ending : read after line %d\n",
- Z lineno);
- Z log(err);
- Z } else {
- Z log("error: EOF while reading the ending : line\n");
- Z }
- Z return(1);
- Z }
- Z ++lineno;
- Z if (! check_newline(buf)) {
- Z sprintf(err, "error: line %d, ending : line too long\n", lineno);
- Z log(err);
- Z return(1);
- Z }
- Z if (buf[0] != ':') {
- Z sprintf(err, "error: line %d, not an ending : line: %s", lineno, buf);
- Z log(err);
- Z return(1);
- Z }
- Z
- Z /*
- Z * verify the exit 0
- Z */
- Z clearerr(article);
- Z if (fgets(buf, BUFSIZ, article) == NULL) {
- Z if (ferror(article)) {
- Z sprintf(err, "error: bad ending exit read after line %d\n",
- Z lineno);
- Z log(err);
- Z } else {
- Z log("error: EOF while reading the ending exit line\n");
- Z }
- Z return(1);
- Z }
- Z ++lineno;
- Z if (! check_newline(buf)) {
- Z sprintf(err, "error: line %d, ending exit line too long\n", lineno);
- Z log(err);
- Z return(1);
- Z }
- Z if (strcmp("exit 0\n", buf) != 0) {
- Z sprintf(err, "error: line %d, not an ending exit line: %s",
- Z lineno, buf);
- Z log(err);
- Z return(1);
- Z }
- Z
- Z /*
- Z * if we are here, all must be ok
- Z */
- Z return(0);
- Z }
- Z
- Z
- Z /*
- Z * check_newline - check to be sure that the string endds in a newline
- Z *
- Z * returns a pointer to the newline, or NULL if none found
- Z */
- Z char *
- Z check_newline( str )
- Z char *str; /* check for newline in str */
- Z {
- Z char *p; /* pointer */
- Z
- Z /* guess the newline location */
- Z p = str + strlen(str);
- Z p -= ((p > str) ? 1 : 0);
- Z
- Z /* return result of guess */
- Z return( (*p == '\n') ? p : NULL );
- Z }
- Z
- Z char *
- Z xmalloc(size)
- Z unsigned size;
- Z {
- Z extern char *malloc();
- Z char *ret = malloc(size);
- Z
- Z if (ret == NULL) {
- Z sprintf(err, "error: out of memory in xmalloc\n");
- Z log(err);
- Z sprintf(err, "exiting: status: 1 - %s", get_date());
- Z log(err);
- Z exit(1);
- Z }
- Z
- Z return ret;
- Z }
- Z
- Z char *
- Z xrealloc(region, size)
- Z char *region;
- Z unsigned size;
- Z {
- Z extern char *realloc();
- Z register char *ret = realloc(region, size);
- Z
- Z if (ret == NULL) {
- Z sprintf(err, "error: out of memory in xrealloc\n");
- Z log(err);
- Z sprintf(err, "exiting: status: 1 - %s", get_date());
- Z log(err);
- Z exit(1);
- Z }
- Z
- Z return ret;
- Z }
- Z
- Z
- Z /*
- Z * strcmpic - case independent strcmp function
- Z */
- Z int
- Z strncmpic(s1, s2, n)
- Z register char *s1, *s2; /* strings to compare */
- Z int n; /* compare up to this many chars */
- Z {
- Z register int c1, c2; /* temp */
- Z register int cnt = n; /* count of chars so far compared */
- Z
- Z while (*s1 && *s2 && cnt > 0) {
- Z if ((c1 = tolower(*s1)) != (c2 = tolower(*s2))) {
- Z return c1-c2;
- Z }
- Z s1++;
- Z s2++;
- Z cnt--; /* count this character */
- Z }
- Z
- Z /*
- Z * If we ran out of chars, then the string segments are equal, otherwise
- Z * one or both strings must have ended. In this case the subtraction
- Z * will show which one is shorter, if any.
- Z */
- Z return cnt ? (int)((*s1)-(*s2)) : 0;
- Z }
- Z
- Z /*
- Z * strcolon - step through string parts separated by colons
- Z *
- Z * when called with a string, return a copy of the first part of
- Z * the string up to, but excluding the first `:'. When called with
- Z * NULL return a copy of the next part of the previously passed string,
- Z * with each part separated by a colon `:'.
- Z *
- Z * return NULL if no more parts are left.
- Z *
- Z * strcolon is typically used in a loop on ':' separated names such as:
- Z *
- Z * for (p = strcolon(names); p; p = strcolon((char *)NULL)) {
- Z * ... do something with the name p ...
- Z * }
- Z *
- Z * the malloc region returned is reused, so if you wish to keep a string
- Z * around, you will need to copy it.
- Z */
- Z char *
- Z strcolon(s)
- Z register char *s; /* string or NULL */
- Z {
- Z static char *next = NULL; /* pointer to next ':' */
- Z static char *region = NULL; /* region used to store result */
- Z static int alloc = 0; /* alloc size of region */
- Z
- Z if (!s) {
- Z s = next;
- Z if (s == NULL) {
- Z return NULL;
- Z }
- Z }
- Z next = strchr(s, ':');
- Z if (next) {
- Z register int len = next - s;
- Z
- Z if (len >= alloc) {
- Z if (region == NULL) {
- Z region = xmalloc(alloc = len + 1);
- Z } else {
- Z region = xrealloc(region, alloc = len + 1);
- Z }
- Z }
- Z (void) memcpy(region, s, next - s);
- Z region[next - s] = '\0';
- Z next++;
- Z return region;
- Z }
- Z return s;
- Z }
- ----SHAR-EOF----
- if test 20620 -ne "`wc -c unsharmap.c`"
- then
- echo shar: Uebertragungsfehler in unsharmap.c '(Soll-Laenge = 20620 Zeichen)'
- fi
- echo shar: Extraktion von install
- sed 's/^Z //' << \----SHAR-EOF---- > install
- Z : use /bin/sh
- Z # ---------------------------------------------------------------------
- Z # Title : installation von 'unsharmap' (als root ausfuehren)
- Z # Version : Wed, 16-May-90 / 21:00 / (root@artcom0)
- Z # ---------------------------------------------------------------------
- Z if [ ! -r /usr/sysadm ]
- Z then echo "Install must be done with 'root' priv !" ; exit 1
- Z fi
- Z MAPDIR=/usr/lib/uucp/maps
- Z BINDIR=/usr/local/bin
- Z if [ ! -d $BINDIR ]
- Z then echo "Oh... ich finde '/usr/local/bin' viel uebersichtlicher.
- Z egal... wenn's denn sein soll, nehmen wir halt '/usr/bin' : "
- Z BINDIR=/usr/bin
- Z fi
- Z NEWSDIR=/usr/local/lib/news
- Z if [ ! -d $NEWSDIR ]
- Z then echo "Oh... ich finde '/usr/local/lib/news' viel uebersichtlicher.
- Z egal... wenn's denn sein soll, nehmen wir halt '/usr/lib/news' : "
- Z NEWSDIR=/usr/lib/news
- Z fi
- Z
- Z if [ ! -d $MAPDIR ]
- Z then mkdir $MAPDIR
- Z chmod 755 $MAPDIR
- Z chgrp news $MAPDIR
- Z fi
- Z
- Z if [ ! -d $MAPDIR/work ]
- Z then mkdir $MAPDIR/work
- Z chmod 775 $MAPDIR/work
- Z # Ganz Wichtig : Gruppen Schreibzugriff fuer News !
- Z chgrp news $MAPDIR/work
- Z fi
- Z
- Z cp unsharmap $BINDIR
- Z chgrp news $BINDIR/unsharmap
- Z chown mail $BINDIR/unsharmap
- Z chmod 6755 $BINDIR/unsharmap
- Z
- Z cp mkpaths map.daily $MAPDIR
- Z cd $MAPDIR
- Z chown mail mkpaths map.daily
- Z chgrp news mkpaths map.daily
- Z chmod 755 mkpaths map.daily
- Z
- Z #
- Z # Aufruf von 'unsharmap' ins News-Sysfile einfuegen :
- Z #
- Z SYSFILE=$NEWSDIR/sys
- Z if [ ! -w $SYSFILE ]
- Z then echo "Oh. Kein News-Sysfile ? ($SYSFILE)" ; exit 1
- Z fi
- Z
- Z grep "^automapadm" $SYSFILE >/dev/null || echo \
- Z "# Automatische Mail-Routing-Map-Administration :
- Z automapadm:world,sub,!sub.all,sub.config.maps::$BINDIR/unsharmap -p \\
- Z -n sub.config.maps -d $MAPDIR/work | mail -s \"Auto map adm\" \\
- Z postmaster" >> $SYSFILE
- Z
- Z echo "Installation in $MAPDIR fertig ...
- Z und nun \"$MAPDIR/map.daily\" taeglich via root-crontab
- Z ausfuehren lassen oder per Hand aufrufen, wenn neue Maps ankamen."
- ----SHAR-EOF----
- if test 1902 -ne "`wc -c install`"
- then
- echo shar: Uebertragungsfehler in install '(Soll-Laenge = 1902 Zeichen)'
- fi
- echo shar: Extraktion von avoid-unido
- sed 's/^Z //' << \----SHAR-EOF---- > avoid-unido
- Z : use /bin/sh
- Z #
- Z # Title : avoid-unido -- avoid routing over unido, whenever possible
- Z # Version : Sat, 26-May-90 / 12:38 / (root@artcom0)
- Z #
- Z for i in u.deu.* ; do
- Z if [ "$i" = "*" ]
- Z then exit 0
- Z fi
- Z mv $i tmp
- Z awk ' { gsub (/DAILY/, "DEAD");
- Z gsub (/HOURLY/, "DEAD");
- Z gsub (/LOCAL/, "DEAD");
- Z gsub (/ARPA/, "DEAD");
- Z print $0 } ' < tmp > $i
- Z rm tmp
- Z done
- ----SHAR-EOF----
- if test 402 -ne "`wc -c avoid-unido`"
- then
- echo shar: Uebertragungsfehler in avoid-unido '(Soll-Laenge = 402 Zeichen)'
- fi
- echo shar: Extraktion von getmap
- sed 's/^Z //' << \----SHAR-EOF---- > getmap
- Z #! /bin/sh
- Z # @(#)getmap.sh 1.15 2/5/89 14:13:35
- Z #
- Z # Copyright (C) 1988 Ronald S. Karr and Landon Curt Noll
- Z #
- Z # See the file COPYING, distributed with smail, for restriction
- Z # and warranty information.
- Z
- Z # getmap - unshar usenet map articles into the UNSHAR_MAP_DIR directory
- Z #
- Z # usage: getmap [-m mapdir] [-w workdir] [-b batchfile] [-u username]
- Z #
- Z # -m mapdir - 'mapdir' is where maps are unpacked,
- Z # by default 'mapdir' is $UNSHAR_MAP_DIR
- Z # -w workdir - where logs and default batch files are kept,
- Z # by default 'workdir' is 'mapdir'/work
- Z # -b batch - 'batch' is a file of filenames to unshar,
- Z # '-' impiles read filenames from stdin,
- Z # by default 'batch' is 'workdir'/batch
- Z # -u username - errors are Emailed to 'username' rather than
- Z # Posmaster, the username '-' imples that
- Z # the errors should be written to standard error
- Z # -n newsgroups - allowed newsgroups for articles
- Z #
- Z # unsharmap errors will be emailed to the postmaster.
- Z #
- Z # default files:
- Z # $UNSHAR_MAP_DIR - maps are unpacked here
- Z # $UNSHAR_MAP_DIR/work/getmap.log - log of getmap activity and errors
- Z # $UNSHAR_MAP_DIR/work/getmap.err - like getmap.log + skipped lines
- Z # removed if no major unshar errors
- Z # $UNSHAR_MAP_DIR/work/batch - default list of artciles to unshar
- Z # batch.work - tmp copy of batch work, normally
- Z # $UNSHAR_MAP_DIR/work/batch.work,
- Z # ignored if "-w -"
- Z
- Z # locations and constants
- Z #
- Z PATH="/usr/bin:/bin:/usr/local/bin"
- Z UTIL_BIN="/usr/spool/maps/bin"
- Z UNSHAR_MAP_DIR="/usr/spool/maps"
- Z UNSHAR=$UTIL_BIN/unsharmap
- Z
- Z # set defaults value for location that can change by option
- Z #
- Z MAPDIR=$UNSHAR_MAP_DIR
- Z WORKDIR=$MAPDIR/work
- Z BATCH=$WORKDIR/batch
- Z USERNAME=postmaster
- Z NEWSGROUPS=comp.mail.maps:sub.config.maps
- Z
- Z # parse args
- Z #
- Z PROG=$0
- Z USAGE="usage: $PROG [-m mapdir] [-w workdir] [-b batch] [-u username]"
- Z set -- `getopt -n $PROG -q m:w:b:u:n: $*`
- Z if [ $? != 0 ]; then
- Z echo $USAGE 1>&2
- Z exit 1
- Z fi
- Z for i in $*; do
- Z case $i in
- Z -m) MAPDIR=$2; shift 2;;
- Z -w) WORKDIR=$2; shift 2;;
- Z -b) BATCH=$2; shift 2;;
- Z -u) USERNAME=$2; shift 2;;
- Z -n) NEWSGROUPS=$2; shift 2;;
- Z --) shift; break;;
- Z esac
- Z done
- Z if [ "$#" -ne 0 ]; then
- Z echo $USAGE 1>&2
- Z exit 2
- Z fi
- Z if [ "$BATCH" = "-" ]; then # catch stdin case
- Z BATCH=
- Z fi
- Z if [ "$USERNAME" = "-" ]; then # catch the cat errors to stderr case
- Z REPORT="cat 1>&2"
- Z else
- Z REPORT="/usr/local/lib/sendmail -i -t"
- Z fi
- Z
- Z # set locations now that we have the flags
- Z #
- Z LOG=$WORKDIR/getmap.log
- Z ERROR_LOG=$WORKDIR/getmap.err
- Z REBUILD=$WORKDIR/getmap.rebuild
- Z
- Z # be sure the working file does not exist, unless we read from stdin
- Z #
- Z if [ ! -z "$BATCH" ]; then
- Z BATCH_TMP="$BATCH".work
- Z if [ -f "$BATCH_TMP" ]; then
- Z echo "$PROG: working batch file $BATCH_TMP exists" 1>&2
- Z echo "$PROG: remove $BATCH_TMP by hand if stale" 1>&2
- Z exit 3
- Z fi
- Z fi
- Z
- Z # setup log files
- Z #
- Z if [ ! -z "$BATCH" ]; then
- Z BATCH_MSG="$PROG: starting work on $BATCH at `date`"
- Z else
- Z BATCH_MSG="$PROG: starting work on [stdin] at `date`"
- Z fi
- Z echo "$BATCH_MSG" > $ERROR_LOG
- Z if [ "$?" -ne 0 ]; then
- Z echo "$PROG: can not clear $ERROR_LOG" 1>&2
- Z exit 4
- Z fi
- Z touch $LOG 2>/dev/null
- Z if [ "$?" -ne 0 ]; then
- Z echo "$PROG: can not write to $LOG" 1>&2
- Z echo "$PROG: can not write to $LOG" >> $ERROR_LOG
- Z (if [ "$USERNAME" != "-" ]; then
- Z echo "To: $USERNAME"
- Z echo "Subject: getmap error"
- Z echo ""
- Z echo ""
- Z fi
- Z echo "getmap error log follows -----"
- Z cat $ERROR_LOG
- Z echo "end of getmap error log =====") | eval "$REPORT"
- Z exit 5
- Z fi
- Z
- Z
- Z # save the batch file, if not from stdin
- Z #
- Z if [ ! -z "$BATCH" ]; then
- Z # do nothing if no batch file or no work in the batch file
- Z if [ ! -f "$BATCH" -o ! -s "$BATCH" ]; then
- Z echo "$PROG: no work in $BATCH" >> $LOG
- Z rm -f $ERROR_LOG
- Z exit 0
- Z fi
- Z mv $BATCH $BATCH_TMP
- Z if [ "$?" -ne 0 ]; then
- Z echo "$PROG: could not move $BATCH to $BATCH_TMP" 1>&2
- Z echo "$PROG: could not move $BATCH to $BATCH_TMP" >> $ERROR_LOG
- Z (if [ "$USERNAME" != "-" ]; then
- Z echo "To: $USERNAME"
- Z echo "Subject: getmap error"
- Z echo ""
- Z echo ""
- Z fi
- Z echo "getmap error log follows -----"
- Z cat $ERROR_LOG
- Z echo "end of getmap error log =====") | eval "$REPORT"
- Z cat $ERROR_LOG >> $LOG
- Z exit 6
- Z fi
- Z
- Z # if work from stdin, prep a file to be used to save a copy
- Z #
- Z else
- Z BATCH_TMP=$WORKDIR/getmap.in$$
- Z cat /dev/null > $BATCH_TMP
- Z if [ "$?" -ne 0 ]; then
- Z echo "$PROG: could not clear $BATCH_TMP to hold a copy of [stdin]" 1>&2
- Z echo "$PROG: could not clear $BATCH_TMP to hold a copy of [stdin]" >> $ERROR_LOG
- Z (if [ "$USERNAME" != "-" ]; then
- Z echo "To: $USERNAME"
- Z echo "Subject: getmap error"
- Z echo ""
- Z echo ""
- Z fi
- Z echo "getmap error log follows -----"
- Z cat $ERROR_LOG
- Z echo "end of getmap error log =====") | eval "$REPORT"
- Z cat $ERROR_LOG >> $LOG
- Z exit 7
- Z fi
- Z fi
- Z
- Z # process the map artcile files
- Z #
- Z if [ ! -z "$BATCH" ]; then
- Z $UNSHAR -d $MAPDIR -n $NEWSGROUPS < $BATCH_TMP >> $ERROR_LOG
- Z STATUS=$?
- Z else
- Z tee -a $BATCH_TMP | $UNSHAR -d $MAPDIR >> $ERROR_LOG
- Z STATUS=$?
- Z fi
- Z
- Z # note if we unpacked anything
- Z if [ -s "$BATCH_TMP" ]; then
- Z touch $REBUILD
- Z fi
- Z
- Z # log the activity
- Z #
- Z cat $ERROR_LOG >> $LOG
- Z
- Z # post processing - look for errors to report
- Z #
- Z if [ "$STATUS" -ne 0 ]; then
- Z # form the mail message header
- Z (if [ "$USERNAME" != "-" ]; then
- Z echo "To: $USERNAME"
- Z echo "Subject: getmap error"
- Z echo ""
- Z echo ""
- Z fi
- Z echo "getmap error log follows -----"
- Z cat $ERROR_LOG
- Z echo "end of getmap error log ====="
- Z echo ""
- Z echo ""
- Z if [ ! -z "$BATCH" ]; then
- Z echo "$BATCH_TMP work queue follows -----"
- Z cat $BATCH_TMP
- Z echo "end of $BATCH_TMP work queue ====="
- Z else
- Z echo "[stdin] work queue follows -----"
- Z cat $BATCH_TMP
- Z echo "end of [stdin] work queue ====="
- Z fi) | eval "$REPORT"
- Z else
- Z rm -f $ERROR_LOG # no error, so remove the error log
- Z fi
- Z rm -f $BATCH_TMP
- Z
- Z exit 0
- ----SHAR-EOF----
- if test 6008 -ne "`wc -c getmap`"
- then
- echo shar: Uebertragungsfehler in getmap '(Soll-Laenge = 6008 Zeichen)'
- fi
- echo shar: Extraktion von patch.README
- sed 's/^Z //' << \----SHAR-EOF---- > patch.README
- Z From: Matthias Urlichs <urlichs@smurf.sub.org>
- Z Newsgroups: sub.os.unix
- Z Subject: Re: Map-Unpacker
- Z
- Z In sub.os.unix, Artikel <1672@chiuur.chi.sub.org>,
- Z schreibt maps@chi.sub.org (Christian Kaiser):
- Z [ unsharmap deleted ]
- Z
- Z Wer die Maps alternativ gleich aus sub.config.maps raussaugen will, kann
- Z folgenden Patch applizieren:
- Z
- Z In der /usr/lib/news/sys-Datei (oder wo auch immer -- bei mir heisst das Ding
- Z momentan /usr/local/news/c/admin/sys ;-) ) steht dann noch ein
- Z
- 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
- Z
- Z Sicherheitsfanatiker machen dann noch ein (bzw. drei :-)
- Z chown mail unsharmap
- Z chgrp news unsharmap
- Z chmod 6750 unsharmap
- Z Die Maps liegen dann gleich ausgepackt im richtigen Verzeichnis.
- Z
- Z Ach ja, den Pathalias laesst man am besten zur selben Zeit laufen wie den
- Z Expire, damit es keine Probleme mit halben Maps gibt...
- Z
- Z -p heisst "Pipe". Ein "-" konnte ich nicht verwenden, weil einige
- Z getopt-Implementationen das missverstehen.
- ----SHAR-EOF----
- if test 1011 -ne "`wc -c patch.README`"
- then
- echo shar: Uebertragungsfehler in patch.README '(Soll-Laenge = 1011 Zeichen)'
- fi
- # Ende des Shell Archivs
- exit 0
-
- -->
- Peter Funk \\ ArtCom GmbH, Schwachhauser Heerstr. 78, D-2800 Bremen 1
- Work at home: Oldenburger Str.86, D-2875 Ganderkesee 1 /+49 4222 6018 (8am-6pm)
-
-