|
|
1.1 root 1: case $CONFIG in
2: '') . config.sh ;;
3: esac
4: echo "Extracting Pnews (with variable substitutions)"
5: $spitshell >Pnews <<!GROK!THIS!
6: $startsh
7: # $Header: Pnews.SH,v 4.3.1.2 85/05/17 10:36:46 lwall Exp $
8: #
9: # $Log: Pnews.SH,v $
10: # Revision 4.3.1.2 85/05/17 10:36:46 lwall
11: # Removed some extra backslashes.
12: #
13: # Revision 4.3.1.1 85/05/10 11:30:21 lwall
14: # Branch for patches.
15: #
16: # Revision 4.3 85/05/01 12:20:33 lwall
17: # Baseline for release with 4.3bsd.
18: #
19: #
20: # syntax: Pnews -h headerfile or
21: # Pnews -h headerfile oldarticle or
22: # Pnews newsgroup title or just
23: # Pnews
24:
25: export PATH || (echo "OOPS, this isn't sh. Desperation time. I will feed myself to sh."; sh \$0; kill \$\$)
26:
27: # System dependencies
28:
29: mailer="${mailer-/bin/mail}"
30: # if you change this to something that does signatures, take out signature code
31:
32: case $portable in
33: define)
34: # your site name
35: sitename=\`$hostcmd\`
36: # where recordings, distributions and moderators are kept
37: lib=\`$filexp $lib\`
38: # where important rn things are kept
39: rnlib=\`$filexp $rnlib\`
40: ;;
41: undef)
42: # your site name
43: sitename="$sitename"
44: # where recordings, distributions and moderators are kept
45: lib="$lib"
46: # where important rn things are kept
47: rnlib="$rnlib"
48: ;;
49: esac
50:
51: # your organization name
52: orgname="$orgname"
53: # what pager you use--if you have kernal paging use cat
54: pager="\${PAGER-$pager}"
55: # how you derive full names, bsd, usg, or other
56: nametype="$nametype"
57: # default editor
58: defeditor="$defeditor"
59: # how not to echo with newline
60: n="$n"
61: c="$c"
62:
63: # You should also look at the distribution warnings below marked !DIST!
64: # to make sure any distribution regions you are a member of are included.
65: # The following are some prototypical distribution groups. If you do not
66: # use them all set the unused ones to a non-null string such as 'none'.
67: loc="$locpref"
68: org="$orgpref"
69: city="$citypref"
70: state="$statepref"
71: cntry="$cntrypref"
72: cont="$contpref"
73:
74: test=${test-test}
75: sed=${sed-sed}
76: echo=${echo-echo}
77: cat=${cat-cat}
78: egrep=${egrep-egrep}
79: grep=${grep-grep}
80: rm=${rm-rm}
81: tr=${tr-tr}
82: inews=${inews-inews}
83:
84: !GROK!THIS!
85: $spitshell >>Pnews <<'!NO!SUBS!'
86: if $test -f ${DOTDIR-${HOME-$LOGDIR}}/.pnewsexpert; then
87: expertise=expert
88: else
89: $cat <<'EOM'
90: I see you've never used this version of Pnews before. I will give you extra
91: help this first time through, but then you must remember what you learned.
92: If you don't understand any question, type h and a CR (carriage return) for
93: help.
94:
95: If you've never posted an article to the net before, it is HIGHLY recommended
96: that you read the netiquette document found in net.announce.newusers so
97: that you'll know to avoid the commonest blunders. To do that, interrupt
98: Pnews, and get to the top-level prompt of rn. Say "g net.announce.newusers"
99: and you are on your way.
100:
101: EOM
102: expertise=beginner
103: fi
104:
105: case $cntry in
106: can) stpr=Province ;;
107: *) stpr=State ;;
108: esac
109:
110: tmpart=/tmp/article$$
111:
112: headerfile=""
113: case $# in
114: 0) ;;
115: *) case $1 in
116: -h)
117: headerfile="$2"
118: shift
119: shift
120: case $# in
121: 0)
122: oldart=""
123: ;;
124: *)
125: oldart="$1"
126: shift
127: ;;
128: esac
129: ;;
130: esac
131: ;;
132: esac
133:
134: case $headerfile in
135: '')
136: . $rnlib/Pnews.header
137: ;;
138: *)
139: $cat < $headerfile > $tmpart
140: ;;
141: esac
142: rescue="sleep 1; $cat $tmpart >>${HOME-$LOGDIR}/dead.article ; $echo saved in ${HOME-$LOGDIR}/dead.article ; $rm -f $tmpart; exit"
143: trap "$rescue" 1
144: trap "$rescue" 2
145:
146: $echo ""
147: set X `$sed < $tmpart -n -e '/^Distribution: /{' -e p -e q -e '}' -e '/^$/q'`
148: shift
149: case $# in
150: 0|1)
151: set X `$sed < $tmpart -n -e '/^Newsgroups: /{' -e p -e q -e '}'`
152: shift
153: case $# in
154: 0|1)
155: set "x net.whatever"
156: ;;
157: esac
158: ;;
159: *)
160: set $1 $2.whatever
161: ;;
162: esac
163: shift
164:
165: #: play recorded message
166: #if $test -s ${lib}/recording ; then
167: # ng=`$echo $1 | $sed "s/,.*//"`
168: # _rec1=${lib}/`$sed -n "/^$ng/s/^.* //p" ${lib}/recording`
169: # _tmp=`$echo $ng |$sed "s/\..*//"`
170: # _rec2=${lib}/`$cat -s ${lib}/recording|$grep ${_tmp}.all|$sed "s/^.* //"`
171: # if $test -f ${_rec1} ; then
172: # $cat -s ${_rec1}
173: # fi
174: # if $test -f ${_rec2} ; then
175: # $cat -s ${_rec2}
176: # fi
177: #fi
178:
179: # tell them what we think they are doing... !DIST!
180: case $1 in
181: net.*)
182: $echo 'This program posts news to many hundreds of machines throughout the world.'
183: ;;
184: $cont.*)
185: $echo 'This program posts news to many machines throughout the continent.'
186: ;;
187: $cntry.*)
188: $echo 'This program posts news to many machines throughout the country.'
189: ;;
190: $state.*)
191: $echo 'This program posts news to many machines throughout the state.'
192: ;;
193: $city.*)
194: $echo 'This program posts news to many machines throughout the city.'
195: ;;
196: $org.*)
197: $echo 'This program posts news to machines throughout the organization.'
198: ;;
199: $loc.*)
200: $echo 'This program posts news to machines throughout the local organization.'
201: ;;
202: *.*)
203: $echo 'This program may post news to many machines.'
204: ;;
205: *)
206: $echo 'This program posts news to everyone on the machine.'
207: ;;
208: esac
209: ans=""
210: while $test "$ans" = "" ; do
211: $echo $n "Are you absolutely sure that you want to do this? [ny] $c"
212: read ans
213: case $ans in
214: y*) ;;
215: f*) suppressmess=y ;;
216: h*) $cat <<'EOH'
217:
218: Type n or CR to exit, y to post.
219:
220: EOH
221: ans="" ;;
222: *) exit ;;
223: esac
224: done
225:
226: file=h
227: while $test "$file" = h ; do
228: $echo ""
229: $echo $n "Prepared file to include [none]: $c"
230: read file
231: case $file in
232: h)
233: $cat <<'EOH'
234:
235: If you have already produced the body of your article, type the filename
236: for it here. If you just want to proceed directly to the editor, type a
237: RETURN. In any event, you will be allowed to edit as many times as you
238: want before you send off the article.
239: EOH
240: ;;
241: '')
242: $echo "" >> $tmpart
243: state=edit
244: ;;
245: *)
246: $cat $file >>$tmpart
247: state=ask
248: ;;
249: esac
250: done
251:
252: $echo ""
253:
254: while true ; do
255: case $state in
256: edit)
257: case $expertise in
258: beginner)
259: $cat </dev/null >${DOTDIR-${HOME-$LOGDIR}}/.pnewsexpert
260: $cat <<'EOMessage'
261: A temporary file has been created for you to edit. Be sure to leave at
262: least one blank line between the header and the body of your message.
263: (And until a certain bug is fixed all over the net, don't start the body of
264: your message with any indentation, or it may get eaten.)
265:
266: Within the header may be fields that you don't understand. If you don't
267: understand a field (or even if you do), you can simply leave it blank, and
268: it will go away when the article is posted.
269:
270: Type return to get the default editor, or type the name of your favorite
271: editor.
272:
273: EOMessage
274: ;;
275: esac
276: case "${VISUAL-${EDITOR-}}" in
277: '')
278: tmp=h
279: ;;
280: *)
281: tmp=''
282: ;;
283: esac
284: while $test "$tmp" = h ; do
285: $echo $n "Editor [${VISUAL-${EDITOR-$defeditor}}]: $c"
286: read tmp
287: case $tmp in
288: h)
289: $cat <<'EOH'
290:
291: Type a return to get the default editor, or type the name of the editor you
292: prefer. The default editor depends on the VISUAL and EDITOR environment
293: variables.
294:
295: EOH
296: ;;
297: '')
298: ;;
299: *)
300: VISUAL=$tmp
301: export VISUAL
302: ;;
303: esac
304: done
305: trap : 2
306: ${VISUAL-${EDITOR-$defeditor}} $tmpart $oldart
307: trap "$rescue" 2
308: state=ask
309: ;;
310:
311: ask)
312: $echo ""
313: $echo $n "Send, abort, edit, or list? $c"
314: read ans
315:
316: case $ans in
317: a*)
318: state=rescue
319: ;;
320: e*)
321: state=edit
322: ;;
323: l*)
324: $pager $tmpart
325: state=ask
326: ;;
327: s*)
328: state=send
329: ;;
330: h*)
331: $cat <<'EOH'
332:
333: Type s to send the article, a to abort and append the article to dead.article,
334: e to edit the article again, or l to list the article.
335: EOH
336: esac
337: ;;
338:
339: send)
340: set X `$sed < $tmpart -n -e '/^Newsgroups: /{' -e p -e q -e '}'`
341: shift
342: case $# in
343: 2)
344: state=cleanup
345: if $test -f $lib/moderators; then
346: tryinews=no
347: shift
348: case "$1" in
349: *,*) set `$echo $1 | tr ',' ' '`;;
350: esac
351: for newsgroup in $*; do
352: # the following screwy sed should prevent Eunice from hanging on no match
353: moderator=`$sed <$lib/moderators \
354: -e "/^$newsgroup[ ]/!s/.*//" \
355: -e "s/^$newsgroup[ ]//"`
356: case ${moderator}X in
357: X) tryinews=yes
358: ;;
359: *)
360: $echo Mailing to moderator $moderator
361: case "$mailer" in
362: *recmail)
363: $echo To: $moderator | $cat - $tmpart | $mailer
364: ;;
365: *)
366: $mailer $moderator < $tmpart
367: ;;
368: esac
369: case $? in
370: 0) ;;
371: *)
372: $echo Unable to mail to moderator $moderator
373: state=rescue
374: ;;
375: esac
376: ;;
377: esac
378: done
379: else
380: tryinews=yes
381: fi
382: case "$tryinews" in
383: yes)
384: if $inews -h < $tmpart ; then
385: : null
386: else
387: state=rescue
388: fi
389: ;;
390: esac
391: ;;
392: *)
393: $echo ""
394: $echo "Malformed Newsgroups line."
395: $echo ""
396: sleep 1
397: state=edit
398: ;;
399: esac
400: ;;
401: rescue)
402: $cat $tmpart >> ${HOME-$LOGDIR}/dead.article
403: $echo "Article saved to ${HOME-$LOGDIR}/dead.article"
404: state=cleanup
405: ;;
406: cleanup)
407: $rm -f $tmpart
408: exit
409: ;;
410: esac
411: done
412: !NO!SUBS!
413: $eunicefix Pnews
414: chmod 755 Pnews
415: $spitshell >Pnews.header <<'!NO!SUBS!'
416: case $# in
417: 0)
418: ng=h
419: while $test "$ng" = h ; do
420: $echo ""
421: $echo $n "Newsgroup(s): $c"
422: read ng
423: case $ng in
424: h)
425: $cat <<'EOH'
426:
427: Type the name of one or more newsgroups to which you wish to post an article.
428: If you want to post to multiple newsgroups, it is better to do them all at
429: once than to post to each newsgroup individually, which defeats the news
430: reading programs' strategies of eliminating duplicates.
431:
432: Separate multiple newsgroup names with commas.
433: EOH
434: ;;
435: esac
436: done
437: ;;
438: *)
439: ng=$1
440: shift
441: ;;
442: esac
443: case $ng in
444: *\ *)
445: ng=`$echo "$ng" | $sed 's/[, ] */,/g'`
446: ;;
447: esac
448: case $ng in
449: net.*|fa.*|mod.*)
450: defdist=net
451: dist=h
452: ;;
453: *.*)
454: defdist=`expr "X$ng" : 'X\([a-z0-9]*\)'`
455: dist=h
456: ;;
457: *)
458: defdist=''
459: dist=''
460: ;;
461: esac
462:
463: while $test "$dist" = h ; do
464: if $test -f $lib/distributions; then
465: $echo " "
466: $echo "Your local distribution prefixes are:"
467: $cat $lib/distributions
468: else
469: $egrep -v '[ ]none$' <<EOM
470:
471: Your local distribution prefixes are:
472: Local organization: $loc
473: Organization: $org
474: City: $city
475: $stpr: $state
476: Country: $cntry
477: Continent: $cont
478: Everywhere: net,mod,fa
479:
480: EOM
481: fi
482: $echo $n "Distribution ($defdist): $c"
483: read dist
484: case $dist in
485: '') dist=$defdist ;;
486: esac
487: case $dist in
488: h)
489: $cat <<'EOH'
490:
491: The Distribution line may be used to limit the distribution of an article
492: to some subset of the systems that would receive the article based only on
493: the Newsgroups line. For example, if you want to sell your car in net.auto,
494: and you live in New Jersey, you might want to put "nj" on the Distribution
495: line to avoid advertising in California, which has enough problems of its own.
496: The actual area designators to use depend on where you are, of course.
497: EOH
498: ;;
499: ''|$loc*|$org*|$city*|$state*|$cntry*|$cont*|fa*|mod*)
500: ;;
501: net*|world*)
502: dist=''
503: ;;
504: *)
505: if $test -f $lib/distributions && \
506: $egrep "^$dist[ ]" $lib/distributions >$tmpart && \
507: $test -s $tmpart; then
508: : null
509: else
510: $echo "Unrecognized distribution prefix--type h for help."
511: dist=h
512: fi
513: ;;
514: esac
515: done
516:
517: case $ng in
518: *net.general*)
519: follow=`echo "$ng" | sed 's/net\.general/net.followup/g'`
520: ;;
521: *)
522: follow=""
523: ;;
524: esac
525:
526: case $# in
527: 0)
528: title=h
529: while $test "$title" = h ; do
530: $echo ""
531: $echo $n "Title/Subject: $c"
532: read title
533: case $title in
534: h)
535: $cat <<'EOH'
536:
537: Type the title for your article. Please make it as informative as possible
538: (within reason) so that people who aren't interested won't have to read the
539: article to find out they aren't interested. This includes marking movie
540: spoilers as (spoiler), and rotated jokes as (rot 13).
541: EOH
542: ;;
543: esac
544: done
545: ;;
546: *)
547: title="$*"
548: ;;
549: esac
550:
551: # now build a file with a header for them to edit
552:
553: set X ${USER-${LOGNAME-`who am i`}}
554: shift
555: logname=$1
556: case $logname in
557: *!*) logname=`expr "$logname" : '!\(.*\)$'` ;;
558: esac
559: case ${NAME-$nametype} in
560: bsd)
561: fullname=`$sed </etc/passwd -e "/^$logname:/{s/^[^:]*:[^:]*:[^:]*:[^:]*:\([^,:;]*\).*"'$'"/\1/" -e "q" -e "}" -e "d"`
562: case $fullname in
563: *'&'*) : GACK
564: lname=`$echo $logname | $tr 'a-z' 'A-Z'`
565: lname=`$echo $lname $logname | $sed 's/^\(.\)[^ ]* ./\1/'`
566: fullname=`$echo "$fullname" | $sed "s/&/${lname}/"`
567: ;;
568: esac
569: ;;
570: usg)
571: fullname=`$sed </etc/passwd -e "/^$logname:/{s/^[^:]*:[^:]*:[^:]*:[^:]*:\([^(:]*\).*"'$'"/\1/" -e "s/^.*-//" -e "q" -e "}" -e "d"`
572: ;;
573: *)
574: fullname=${NAME-`$cat ${HOME-$LOGDIR}/.fullname`}
575: ;;
576: esac
577:
578: orgname=${ORGANIZATION-$orgname}
579: case $orgname in
580: /*) orgname=`$cat $orgname` ;;
581: esac
582:
583: $cat > $tmpart <<EOHeader
584: Newsgroups: $ng
585: Subject: $title
586: Expires:
587: References:
588: Sender:
589: Reply-To: $logname@$sitename.UUCP ($fullname)
590: Followup-To: $follow
591: Distribution: $dist
592: Organization: $orgname
593: Keywords:
594:
595: EOHeader
596:
597: !NO!SUBS!
598: $eunicefix Pnews.header
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.