rsalz@bbn.com (Rich Salz) (01/04/91)
Submitted-by: Wayne Davison <0004475895@mcimail.com> Posting-number: Volume 23, Issue 61 Archive-name: trn/part02 #! /bin/sh # This is a shell archive. Remove anything before this line, then feed it # into a shell via "sh file" or similar. To overwrite existing files, # type "sh file -c". # The tool that generated this appeared in the comp.sources.unix newsgroup; # send mail to comp-sources-unix@uunet.uu.net if you want that tool. # Contents: Configure.01 INIT util.c # Wrapped by rsalz@litchi.bbn.com on Thu Dec 27 11:33:59 1990 PATH=/bin:/usr/bin:/usr/ucb ; export PATH echo If this archive is complete, you will see the following message: echo ' "shar: End of archive 2 (of 14)."' if test -f 'Configure.01' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'Configure.01'\" else echo shar: Extracting \"'Configure.01'\" \(49808 characters\) sed "s/^X//" >'Configure.01' <<'END_OF_FILE' X#!/bin/sh X# X# If these # comments don't work, trim them. Don't worry about the other X# shell scripts, Configure will trim # comments from them for you. X# X# $Header: Configure,v 4.3.3.2 90/08/20 16:09:59 davison Trn $ X# X# $Log: Configure,v $ X# Revision 4.3.3.2 90/08/20 16:09:59 davison X# Added MMDF support, revised sitename/domain/signal/tzset/PATH. X# X# Revision 4.3.3.1 90/07/24 21:56:31 davison X# Initial Trn Release X# X# Revision 4.3.2.25 90/05/12 17:34:53 sob X# Still more XENIX fixes and fixes for using socketlib when rrn and not when X# just rn. X# X# Revision 4.3.2.24 90/05/12 14:07:43 sob X# Fixed up LDFLAGS for xenix 286 X# X# Revision 4.3.2.23 90/05/04 00:42:31 sob X# Fixes for Pyramids, more on the return value of signal() and X# syncing up the use of socketlib. X# X# Revision 4.3.2.22 90/04/17 15:44:24 sob X# Added better directory structure detection. X# X# Revision 4.3.2.21 90/04/14 19:36:38 sob X# Added better support for the NeXT. X# X# Revision 4.3.2.20 90/04/14 01:53:36 sob X# Spelling Problem! X# X# Revision 4.3.2.19 90/03/17 21:33:21 sob X# Reworked VOIDSIG into SIGRET. X# X# Revision 4.3.2.18 90/03/17 17:45:25 sob X# Changes to detect when to use termio and when not to. X# X# Revision 4.3.2.17 90/03/17 16:53:11 sob X# Applied a patch to correctly determine being on a Sun running OS 4.0 or X# later. X# X# Revision 4.3.2.16 89/12/20 23:20:38 sob X# Added hp-ux support suggested by tml@hemuli.atk.vtt.fi. Also, X# corrected some bugs reported by tml@hemuli.atk.vtt.fi. X# X# Revision 4.3.2.15 89/12/18 00:02:04 sob X# Fixed bug reported by Jim Thompson <jthomp@sun.com> on the X# use of ypmatch against the so-called services.byname YP map. X# Sigh. Will YP EVER work? X# X# Revision 4.3.2.14 89/12/17 12:55:39 sob X# Minor bug fix to yp detection code. X# X# Revision 4.3.2.13 89/12/17 01:53:21 sob X# Changed from using ypcat to using ypmatch X# X# Revision 4.3.2.12 89/12/15 19:35:20 sob X# getpwent was not getting defined when YP is present. X# bug reported by dglo@ads.com X# X# Revision 4.3.2.11 89/12/13 00:42:59 sob X# Included suggested patches by weening@gang-of-four.stanford.edu. X# X# Revision 4.3.2.10 89/12/09 01:47:49 sob X# Configure now removes myread when exiting. X# X# Revision 4.3.2.9 89/12/08 22:41:14 sob X# Added minor changes suggested by weening@Gang-of-Four.Stanford.EDU and X# jik@pit-manager.mit.edu X# X# Revision 4.3.2.8 89/11/28 00:30:06 sob X# Attempted to make some of the references to the news software version X# levels more clear for the benefit of novice news installers. X# X# Revision 4.3.2.7 89/11/27 02:25:26 sob X# Better detection of SunOS 4.0 and getpwent will be used on systems X# that support YP, just in case. X# X# Revision 4.3.2.6 89/11/27 01:32:56 sob X# Added some changes suggested by various usenet postings. X# Limited support for NeXT. X# X# Revision 4.3.2.5 89/11/08 04:47:27 sob X# Added VOIDSIG handling for SunOS 4.X X# X# Revision 4.3.2.4 89/11/06 00:05:38 sob X# Added RRN support originally distributed with NNTP 1.5 X# X# Revision 4.3.2.3 89/11/05 23:35:43 sob X# Added checks for ultrix and sun X# X# Revision 4.3.1.6 86/07/24 14:41:18 lwall X# Handles missing Relay-Version: from news 2.10.3 headers. X# X# Revision 4.3.1.5 85/05/23 11:23:22 lwall X# filexp flubs sed command. X# X# Revision 4.3.1.4 85/05/20 17:13:11 lwall X# Makes sure -lcurses is really a terminfo library. X# Puts single instead of double quotes around defs in config.sh. X# X# Revision 4.3.1.3 85/05/16 16:48:48 lwall X# Took space from end of filexp output. X# X# Revision 4.3.1.2 85/05/13 15:54:35 lwall X# Libraries in /usr/local/lib shouldn't use -l switch. X# X# Revision 4.3.1.1 85/05/10 11:29:20 lwall X# Branch for patches. X# X# Revision 4.3 85/05/01 11:31:23 lwall X# Baseline for release with 4.3bsd. X# X X# Yes, you may rip this off to use in other distribution packages. X XWHITE='[ ]'; : there should be a tab and a space between the brackets. XCTRLA=''; : there should be a control-A between the single-quotes. X Xn='' Xc='' Xlibc='' Xeunicefix='' Xeunice='' Xcpp='' Xshsharp='' Xspitshell='' Xstartsh='' Xtest='' Xexpr='' Xsed='' Xecho='' Xcat='' Xrm='' Xmv='' Xcp='' Xtail='' Xtr='' Xmkdir='' Xsort='' Xuniq='' Xinews='' Xgrep='' Xegrep='' Xypmatch='' Xcontains='' Xlib='' Xnametype='' Xcc='' Xiandd='' Xinclude='' Xrrninclude='' Xtermlib='' Xjobslib='' Xndirlib='' Xsocketlib='' Xdirtype='' Xdirinc='' Xlibndir='' Xusendir='' Xndirc='' Xndiro='' Xpager='' Xmailer='' Xinternet='' Xrnbin='' Xfilexp='' Xdistlist='' XLog='' XHeader='' Xsitename='' Xhostfile='' Xdomain='' Xorgname='' Xisadmin='' Xnewsadmin='' Xrnlib='' Xmansrc='' Xmanext='' Xmaildir='' Xspool='' Xactive='' Xmyactive='' Xmininact='' Xpref='' Xdefeditor='' Xrootid='' Xmboxchar='' Xlocpref='' Xorgpref='' Xcitypref='' Xstatepref='' Xcntrypref='' Xcontpref='' Xstrchr='' Xmemcpy='' Xrename='' Xtruncate='' Xchsize='' Xsysptem='' Xtzset='' Xthreaddef='' Xselectdef='' Xthreaddir='' Xnovoid='' Xnovfork='' Xportable='' Xpassnam='' Xberknam='' Xusgnam='' Xwhoami='' Xtermio='' Xfcntl='' Xioctl='' Xnormsig='' Xsigblock='' Xsigret='' Xgetuidgid='' Xgetcwd='' Xhavetlib='' Xgetpwent='' Xgethostname='' Xdouname='' Xphostname='' Xhostcmd='' Xnorelay='' Xisrrn='' Xrdchk='' Xserverfile='' XNNTPSRC='' XCONFIG='' X Xecho "Beginning of configuration questions for trn." X: Eunice requires " " instead of "", can you believe it Xecho " " X X: sanity checks XPATH='.:/bin:/usr/bin:/usr/local/bin:/usr/ucb:/usr/local:/usr/lbin:/etc:/usr/bsd' Xexport PATH || (echo "OOPS, this isn't sh. Desperation time. I will feed myself to sh."; sh $0; kill $$) X Xif test ! -t 0; then X echo "Type 'sh Configure', not 'sh <Configure'" X exit 1 Xfi X X: some greps do not return status, grrr. Xecho "grimblepritz" >grimble Xif grep blurfldyick grimble >/dev/null 2>&1 ; then X contains=contains Xelse X if grep grimblepritz grimble >/dev/null 2>&1 ; then X contains=grep X else X contains=contains X fi Xfi X X: the following should work in any shell Xcase $contains in Xcontains*) X echo " " X echo "AGH! Grep doesn't return a status. Attempting remedial action." X cat >contains <<'EOSS' Xgrep "$1" "$2" >.greptmp && cat .greptmp && test -s .greptmp XEOSS Xchmod 755 contains Xesac X X: first determine how to suppress newline on echo command Xecho "Checking echo to see how to suppress newlines..." X(echo "hi there\c" ; echo " ") >.echotmp Xif $contains c .echotmp >/dev/null 2>&1 ; then X echo "...using -n." X n='-n' X c='' Xelse X echo "...using \\\c." X n='' X c='\c' Xfi Xecho $n "Type carriage return to continue. Your cursor should be here-->$c" Xread ans Xrm .echotmp X X: now set up to do reads with possible shell escape X: if this does not work on your machine, 1,$s/. myread/read ans/ Xcat <<EOSC >myread Xans='!' Xwhile expr "X\$ans" : "X!" >/dev/null; do X read ans X case "\$ans" in X !) X sh X echo " " X echo $n "Your answer: $c" X ;; X !*) X set \`expr "X\$ans" : "X!\(.*\)\$"\` X sh -c "\$*" X echo " " X echo $n "Your answer: $c" X ;; X esac Xdone XEOSC X X: general instructions Xcat <<'EOH' X XThis installation shell script will examine your system and ask you questions Xto determine how trn and its auxiliary files should be installed. If you Xget stuck on a question, you may use a ! shell escape to start a subshell or Xexecute a command. Many of the questions will have default answers in Xsquare brackets--typing carriage return will give you the default. X XOn some of the questions which ask for file or directory names you are Xallowed to use the ~name construct to specify the login directory belonging Xto "name", even if you don't have a shell which knows about that. Questions Xwhere this is allowed will be marked "(~name ok)". X XMuch effort has been expended to ensure that this shell script will run Xon any Unix system. If despite that it blows up on you, your best bet is to Xedit Configure and run it again. (Trying to install trn without having run XConfigure is well nigh impossible.) Also, tell Wayne (davison@drivax.UUCP) Xhow he blew it. X XThis installation script affects things in two ways: 1) it does direct Xvariable substitutions on some of the files included in this kit, and X2) it builds a config.h file for inclusion in C programs. You may edit Xany of these files as the need arises after running this script. X XEOH Xecho $n "[Type carriage return to continue] $c" X. myread X: get old answers, if there is a config file out there Xif test -f config.sh; then X echo " " X echo "(Fetching default answers from your old config.sh file...)" X . config.sh Xfi X X: get list of predefined functions in a handy place Xecho " " Xif test -f /lib/libc.a; then X echo "Your C library is in /lib/libc.a. You're normal." X libc=/lib/libc.a Xelse X if test -f /lib/Llibc.a; then X echo "Your C library is in /lib/Llibc.a. I smell Xenix!" X libc=/lib/Llibc.a X else X if test -f /usr/lib/libc.a; then X echo "Your C library is in /usr/lib/libc.a, of all places." X libc=/usr/lib/libc.a X else X if test -f "$libc"; then X echo "Your C library is in $libc, like you said before." X else X cat <<'EOM' X XI can't seem to find your C library. I've looked for /lib/libc.a and X/usr/lib/libc.a, but neither of those are there. What is the full name XEOM X echo $n "of your C library? $c" X . myread X libc="$ans" X fi X fi X fi Xfi Xecho " " Xecho $n "Extracting names from $libc for later perusal...$c" Xif ar t $libc > libc.list; then X echo "done" Xelse X echo " " X echo "The archiver doesn't think $libc is a reasonable library." X exit 1 Xfi X: make some quick guesses about what we are up against Xecho " " Xecho $n "Hmm... $c" Xif $contains SIGTSTP /usr/include/signal.h >/dev/null 2>&1 ; then X echo "Looks kind of like a BSD system, but we'll see..." X echo exit 0 >bsd X echo exit 1 >usg X echo exit 1 >v7 Xelse X if $contains SIGTSTP /usr/include/sys/signal.h >/dev/null 2>&1 ; then X echo "Looks sort of like a BSD system, but we'll see..." X echo exit 0 >bsd X echo exit 1 >usg X echo exit 1 >v7 X else X if $contains fcntl.o libc.list >/dev/null 2>&1 ; then X echo "Looks kind of like a USG system, but we'll see..." X echo exit 1 >bsd X echo exit 0 >usg X echo exit 1 >v7 X else X echo "Looks kind of like a version 7 system, but we'll see..." X echo exit 1 >bsd X echo exit 1 >usg X echo exit 0 >v7 X fi X fi Xfi Xif $contains vmssystem.o libc.list >/dev/null 2>&1 ; then X cat <<'EOI' XThere is, however, a strange, musty smell in the air that reminds me of Xsomething...hmm...yes...I've got it...there's a VMS nearby, or I'm a Blit. XEOI X echo "exit 0" >eunice X eunicefix=unixtovms X eunice=define X: it so happens the Eunice I know will not run shell scripts in Unix format Xelse X echo " " X echo "Congratulations. You aren't running Eunice." X eunicefix=':' X eunice=undef X echo "exit 1" >eunice Xfi Xchmod 755 bsd usg v7 eunice X$eunicefix bsd usg v7 eunice X: see how we invoke the C preprocessor Xecho " " Xecho "Checking to see how your C preprocessor is invoked..." Xcat <<'EOT' >testcpp.c X#define ABC abc X#define XYZ xyz XABC+XYZ XEOT Xecho 'Maybe "cc -E" will work...' Xcc -E testcpp.c >testcpp.out 2>&1 Xif $contains 'abc+xyz' testcpp.out >/dev/null 2>&1 ; then X echo "Yup, it does." X cpp='cc -E' Xelse X echo 'Nope...maybe "cc -P" will work...' X cc -P testcpp.c >testcpp.out 2>&1 X if $contains 'abc+xyz' testcpp.out >/dev/null 2>&1 ; then X echo "Yup, that does." X cpp='cc -P' X else X echo 'Nixed again...maybe "/lib/cpp" will work...' X /lib/cpp testcpp.c >testcpp.out 2>&1 X if $contains 'abc+xyz' testcpp.out >/dev/null 2>&1 ; then X echo "Hooray, it works! I was beginning to wonder." X cpp='/lib/cpp' X else X if $contains 'abc +xyz' testcpp.out >/dev/null 2>&1 ; then X echo "Found it! You're on a NeXT, aren't you?" X cpp='/lib/cpp' X else X echo 'Hmm...maybe you already told me...' X case "$cpp" in X '') ;; X *) $cpp testcpp.c >testcpp.out 2>&1;; X esac X if $contains 'abc+xyz' testcpp.out >/dev/null 2>&1 ; then X echo "Hooray, you did! I was beginning to wonder." X else X echo "Nope. I can't find a C preprocessor. Name one: $c" X . myread X cpp="$ans" X $cpp testcpp.c >testcpp.out 2>&1 X if $contains 'abc+xyz' testcpp.out >/dev/null 2>&1 ; then X echo "OK, that will do." X else X echo "Sorry, I can't get that to work. Go find one." X exit 1 X fi X fi X fi X fi X fi Xfi Xrm -f testcpp.c testcpp.out X: check for pdp11 Xecho " " Xcat <<'EOT' >pdp11.c X#ifdef pdp11 Xexit 0 X#else Xexit 1 X#endif XEOT X$cpp pdp11.c | grep exit >pdp11 Xchmod 755 pdp11 X$eunicefix pdp11 Xrm pdp11.c Xif pdp11; then X echo "This looks like a pdp11 to me." Xfi X: check for ultrix Xcat <<'EOT' >ultrix.c X#ifdef ultrix Xexit 0 X#else Xexit 1 X#endif XEOT X$cpp ultrix.c | grep exit >ultrix Xchmod 755 ultrix X$eunicefix ultrix Xrm ultrix.c Xif ultrix; then X echo "Running ultrix, eh?" Xfi X X: check for sun 4.0 Xcat <<'EOT' >sun.c X#ifdef sun Xexit 0 X#else Xexit 1 X#endif XEOT X$cpp sun.c | grep exit >sun Xchmod 755 sun X$eunicefix sun Xrm sun.c Xif sun; then X echo "This looks like a sun to me." X if test -f /etc/ld.so.cache ; then X echo "And it appears you are running SunOS 4.0 or greater." X fi Xfi X: check for hp-ux Xcat <<'EOT' >hp-ux.c X#ifdef hpux Xexit 0 X#else Xexit 1 X#endif XEOT X$cpp hp-ux.c | grep exit >hp-ux Xchmod 755 hp-ux X$eunicefix hp-ux Xrm hp-ux.c Xif hp-ux; then X echo "Hewlett-Packard must have built this..." X socketlib=-lbsdipc Xfi X X: check for sgi Xcat <<'EOT' >sgi.c X#ifdef sgi Xexit 0 X#else Xexit 1 X#endif XEOT X$cpp sgi.c | grep exit >sgi Xchmod 755 sgi X$eunicefix sgi Xrm sgi.c Xif sgi; then X echo "Silicon Graphics must have built this..." X include=-I/usr/include/bsd X rrninclude="-I/usr/include/bsd -DUSG" X socketlib=-lbsd Xfi X X: check for XENIX Xcat <<'EOT' >xenix Xtest -f /xenix; exit $? XEOT Xchmod 755 xenix X$eunicefix xenix Xif xenix; then X echo "Kinda looks like XENIX....hmmm" X rrninclude="-DUSG -DLAI_TCP" X socketlib=-lsocket X rdchk=define X dirtype=dirent Xelse X rdchk=undef Xfi X X: check for Pyramid OSx Xcat <<'EOT' >pyr.c X#ifdef pyr Xexit 0 X#else Xexit 1 X#endif XEOT X$cpp pyr.c | grep exit >pyr Xchmod 755 pyr X$eunicefix pyr Xrm pyr.c Xif pyr; then X echo "This looks like a Pyramid to me." Xfi X Xif bsd; then X getuidgid=define Xelse X getuidgid=undef Xfi X X: see if sh knows # comments Xecho " " Xecho "Checking your sh to see if it knows about # comments..." Xif sh -c '#' >/dev/null 2>&1 ; then X echo "Your sh handles # comments correctly." X shsharp=true X spitshell=cat X echo " " X echo "Okay, let's see if #! works on this system..." X echo "#!/bin/echo hi" > try X $eunicefix try X chmod 755 try X try > today X if test -s today; then X echo "It does." X sharpbang='#!' X else X echo "#! /bin/echo hi" > try X $eunicefix try X chmod 755 try X try > today X if test -s today; then X echo "It does." X sharpbang='#! ' X else X echo "It doesn't." X sharpbang=': use ' X fi X fi Xelse X echo "Your sh doesn't grok # comments--I will strip them later on." X shsharp=false X echo "exec grep -v '^#'" >spitshell X chmod 755 spitshell X $eunicefix spitshell X spitshell=`pwd`/spitshell X echo "I presume that if # doesn't work, #! won't work either!" X sharpbang=': use ' Xfi X X: figure out how to guarantee sh startup Xecho " " Xecho "Checking out how to guarantee sh startup..." Xstartsh=$sharpbang'/bin/sh' Xecho "Let's see if '$startsh' works..." Xcat >try <<EOSS X$startsh Xset abc Xtest "$?abc" != 1 XEOSS X Xchmod 755 try X$eunicefix try Xif try; then X echo "Yup, it does." Xelse X echo "Nope. You may have to fix up the shell scripts to make sure sh runs them." Xfi Xrm -f try today X X: find out where common programs are Xecho " " Xecho "Locating common programs..." Xpth="/usr/ucb /bin /usr/bin /usr/local /usr/local/bin /usr/lbin /etc /usr/lib /usr/etc /usr/5bin" Xcat <<EOSC >loc X$startsh Xthing=\$1 Xshift Xdflt=\$1 Xshift Xfor dir in \$*; do X case "\$thing" in X .) X if test -d \$dir/\$thing; then X echo \$dir X exit 0 X fi X ;; X *) X if test -f \$dir/\$thing; then X echo \$dir/\$thing X exit 0 X fi X ;; X esac Xdone Xecho \$dflt Xexit 1 XEOSC Xchmod 755 loc X$eunicefix loc Xloclist="expr sed echo cat rm mv cp tail tr mkdir sort uniq grep" Xtrylist="test inews egrep more pg Mcc ypmatch" Xfor file in $loclist; do X xxx=`loc $file $file $pth` X eval $file=$xxx X case "$xxx" in X /*) X echo $file is in $xxx. X ;; X *) X echo "I don't know where $file is. I hope it's in everyone's PATH." X ;; X esac Xdone Xecho " " Xecho "Don't worry if any of the following aren't found..." Xfor file in $trylist; do X xxx=`loc $file $file $pth` X eval $file=$xxx X case "$xxx" in X /*) X echo $file is in $xxx. X ;; X *) X echo "I don't see $file out there, offhand." X ;; X esac Xdone Xcase $egrep in Xegrep) X echo "Substituting grep for egrep." X egrep=$grep X ;; Xesac Xcase $test in Xtest) X echo "Hopefully test is built into your sh." X ;; X/bin/test) X echo " " X echo $n 'Is your "test" built into sh? [n] (OK to guess) '"$c" X . myread X case $ans in X y*) test=test ;; X esac X ;; X*) X test=test X ;; Xesac Xcase $echo in Xecho) X echo "Hopefully echo is built into your sh." X ;; X/bin/echo) X echo " " X echo "Checking compatibility between /bin/echo and builtin echo (if any)..." X $echo $n "hi there$c" >foo1 X echo $n "hi there$c" >foo2 X if cmp foo1 foo2 >/dev/null 2>&1; then X echo "They are compatible. In fact, they may be identical." X else X echo "They are not compatible--the echo builtin will be used." X echo=echo X fi X $rm -f foo1 foo2 X ;; X*) X echo=echo X ;; Xesac X$echo " " X: test yp Xcase $ypmatch in Xypmatch) X $echo "I don't see ypmatch out there, so YP is not available. We'll search the" X $echo "passwd file the old fashioned way!" X ;; X*) X $ypmatch 513/tcp services > /dev/null 2>/dev/null X status=$? X if $test $status -ne 0 ; then X $echo "YP installed, but not operational. We won't use it." X else X $echo "YP installed and operational." X fi X X ;; Xesac Xif $test "$ypmatch" = "ypmatch"; then X ypmatch="" Xfi X X: decide how portable to be Xcase "$portable" in Xdefine) dflt=y;; X*) dflt=n;; Xesac X$cat <<'EOH' X XI can set things up so that your shell scripts and binaries are more portable, Xat what may be a noticable cost in performance. In particular, if you Xask to be portable, the following happens: X X 1) shell scripts will rely on the PATH variable rather than using X the paths derived above. X 2) ~username interpretations will be done at run time rather than X by Configure. X 3) the system name will be determined at run time, if at all possible. X XEOH X$echo $n "Do you expect to run these scripts and binaries on multiple machines? [$dflt] $c" X. myread Xcase $ans in X'') ans=$dflt;; Xesac Xcase $ans in X y*) portable=define X for file in $loclist; do X eval $file=$file X done X ;; X *) portable=undef ;; Xesac X X: set up shell script to do ~ expansion Xcat >filexp <<EOSS X$startsh X: expand filename Xcase \$1 in X~/*|~) X $echo \$1 | $sed "s|~|\${HOME-\$LOGDIR}|" X ;; X~*) X if $test -f /bin/csh; then X /bin/csh -f -c "glob \$1" X $echo "" X else X name=\`$expr x\$1 : '..\([^/]*\)'\` X if $test "$ypmatch" != ""; then X dir=\`$ypmatch \$name passwd 2>/dev/null | $sed "s/^[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:\([^:]*\).*"'\$'"/\1/"'\` X fi X if $test "\$dir" = ""; then X dir=\`$sed </etc/passwd -n -e "/^\${name}:/{s/^[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:\([^:]*\).*"'\$'"/\1/" -e p -e q -e '}'\` X fi X if $test ! -d "\$dir"; then X me=\`basename \$0\` X $echo "\$me: can't locate home directory for: \$name" >&2 X exit 1 X fi X case \$1 in X */*) X $echo \$dir/\`$expr x\$1 : '..[^/]*/\(.*\)'\` X ;; X *) X $echo \$dir X ;; X esac X fi X ;; X*) X $echo \$1 X ;; Xesac XEOSS Xchmod 755 filexp X$eunicefix filexp X X: try to deal with domains X$cat << 'EOH' X XPlease enter your domain name. This will be used in conjunction with the Xsite name for return addresses on news articles and mail. If you use the X4.3ism of having your domain in your hostname, all the posting programs Xwill figure this out on the fly, so don't worry. X XExamples of some valid domains: X berkeley.edu X nasa.gov XExample of an invalid domain in common use: X uucp XEOH X Xcase "$domain" in X'') dflt="uucp";; X*) dflt="$domain" ;; Xesac X$echo $n "Your domain: [$dflt] $c" X. myread Xcase "$ans" in X'') domain="$dflt";; X*) domain="$ans" ;; Xesac X X: now get the site name X$echo " " X$echo "Figuring out site name..." X$echo 'Maybe "hostname" will work...' Xif ans=`sh -c hostname 2>&1` ; then X sitename=$ans X hostcmd=hostname Xelse X $echo 'No, maybe "uuname -l" will work...' X if ans=`sh -c 'uuname -l' 2>&1` ; then X sitename=$ans X hostcmd='uuname -l' X else X $echo 'Strange. Maybe "uname -n" will work...' X if ans=`sh -c 'uname -n' 2>&1` ; then X sitename=$ans X hostcmd='uname -n' X else X $echo 'Oh well, maybe I can mine it out of whoami.h...' X if ans=`sh -c $contains' sysname /usr/include/whoami.h' 2>&1` ; then X sitename=`$echo "$ans" | $sed 's/^.*"\(.*\)"/\1/'` X hostcmd="sed -n -e '"'/sysname/s/^.*\"\\(.*\\)\"/\1/{'"' -e p -e q -e '}' </usr/include/whoami.h" X else X case "$sitename" in X '') $echo "Does this machine have an identity crisis or something?" X hostcmd='' X ;; X *) $echo "Well, you said $sitename before...";; X esac X fi X fi X fi Xfi X: you do not want to know about this Xset $sitename Xsitename=$1 X X: translate upper to lower case. This is mostly to help UUCP work right. Xcase $sitename in X *[A-Z]*) X sitename=`$echo $sitename | tr '[A-Z]' '[a-z]'` X $echo "(Normalizing case in your site name)" X ;; Xesac X X: verify site name and allow them to override it Xif $test "$sitename" ; then X $echo 'Your site name appears to be "'$sitename'".' Xelse X sitename='unknown' Xfi Xcase "$hostfile" in X/*) dflt="$hostfile" ;; X*) dflt="$sitename" ;; Xesac X$cat <<'EOM' X XIn some cases it is not desirable to use the actual site name in your return Xaddresses (if, for example, all mail gets routed first to one site). In this Xcase trn allows you to either hard-wire a site name or read the site name from Xa file. To indicate a file, start the name with a slash (e.g. /etc/sitename). XTo use just your domain name, re-enter it here. A period-less site name will Xautomatically get your domain name added to it. X XEOM Xwhile $test $dflt ; do X $echo $n "What site name goes in return addresses? [$dflt] $c" X . myread X case $ans in X '') ans=$dflt;; X esac X case $ans in X /*) X if $test -f $ans ; then X hostfile="$ans" X hostcmd="$cat $ans" X sitename=`$hostcmd` X $echo "Trn will read the site name from $ans: $sitename." X dflt='' X else X $echo "Unable to locate $ans." X fi X ;; X *) hostfile='' X if $test "X$sitename" = "X$ans" ; then X $echo "Using the site name derived by $hostcmd: $sitename." X else X hostcmd='' X sitename="$ans" X $echo "Using a hard-wired site name: $sitename." X fi X dflt='' X ;; X esac Xdone X Xif $test $portable = "undef" ; then X case $sitename in X *.*) ;; X *) sitename=$sitename.$domain X ;; X esac Xfi X X: get organizaton name Xlongshots='/usr/src/new /usr/src/local /usr/local/src' Xcase "$orgname" in X'') if xxx=`loc news/src/defs.h x $longshots`; then X dflt=`$sed -n 's/^.*MYORG[ ]*"\(.*\)".*$/\1/p' $xxx` X else X dflt='no default' X fi X ;; X*) dflt="$orgname";; Xesac X$cat << 'EOH' X XPlease type the name of your organization as you want it to appear on the XOrganization line of outgoing articles. (It's nice if this also specifies Xyour location. Your city name is probably sufficient if well known.) XFor example: X X University of Southern North Dakota, Hoople X XYou may also put the name of a file, as long as it begins with a slash. XFor example: X X /etc/organization X XEOH Xorgname="no default" Xwhile test "X$orgname" = "Xno default"; do X $echo $n "Organization: [$dflt] $c" X . myread X case "$ans" in X '') orgname="$dflt";; X *) orgname="$ans" ;; X esac Xdone X X: get news administrator name Xcase "$newsadmin" in X'') X if $contains "^news:" /etc/passwd >/dev/null 2>&1 ; then X dflt=news X else X if $contains "^usenet:" /etc/passwd >/dev/null 2>&1 ; then X dflt=usenet X else X if eunice; then X dflt=system X else X dflt=root X fi X fi X fi X ;; X*) dflt="$newsadmin" X ;; Xesac Xcat <<'EOM' X XMany systems keep their news in a private directory, or have a non-superuser Xin charge of administering news. (If you don't have such a user, take the Xdefault answer.) What is the login name (not directory) that is used for news XEOM X$echo $n "administration? [$dflt] $c" X. myread Xnewsadmin="$ans" Xcase $newsadmin in X'') newsadmin=$dflt ;; Xesac Xcase $newsadmin in Xroot) isadmin=undef ;; X*) isadmin=define ;; Xesac X X: figure out news library Xcase "$lib" in X'') X dflt=/usr/lib/news X ;; X*) dflt=$lib ;; Xesac Xlibexp=$lib Xlibexp='blurfl/dyick' Xwhile $test ! -d "$libexp"; do X $echo " " X case "$libexp" in X blurfl*) ;; X *) $echo "Directory $libexp not found";; X esac X $echo $n "Where is your news library (~name okay)? [$dflt] $c" X . myread X case "$ans" in X '') ans="$dflt";; X esac X lib="$ans" X case $lib in X ~*) X libexp=`filexp $lib` X $echo "(That is $libexp on this particular system.)" X case $portable in X undef) lib=$libexp ;; X esac X ;; X *) X libexp=$lib X ;; X esac Xdone Xif $test -f $libexp/inews; then X $echo "Aha! Inews is really in $libexp!" X $echo "Maybe this is Bnews 2.10.2 or later." X inews=$libexp/inews Xfi X X: determine where manual pages go Xcase "$mansrc" in X'') X dflt=`loc . /usr/man/man1 /usr/man/mann /usr/man/local/man1 /usr/man/u_man/man1 /usr/man/man1` X ;; X*) dflt="$mansrc" X ;; Xesac Xmansrc='blurfl/dyick' Xwhile $test ! -d "$mansrc" ; do X case $mansrc in X blurfl*) ;; X *) $echo "$mansrc does not appear to exist." ;; X esac X $echo " " X $echo $n "Where do the manual pages (source) go? [$dflt] $c" X . myread X mansrc=`filexp "$ans"` X case $mansrc in X '') mansrc=$dflt ;; X esac Xdone Xcase "$mansrc" in X*l) X manext=l X ;; X*n) X manext=n X ;; X*) X manext=1 X ;; Xesac X X: determine where mail is spooled Xcase "$maildir" in X'') X dflt=`loc . /usr/spool/mail /usr/spool/mail /usr/mail` X ;; X*) dflt="$maildir" X ;; Xesac Xcase "$dflt" in X*%L*) ;; X*) dflt="$dflt/%L" Xesac X$cat <<'EOM' X XTrn needs to know where to find yet-to-be-read mail. Sendmail sites Xuse /usr/spool/mail/%L (where '%L' is the user's login name). Some XMMDF sites use /usa/%L/.mail instead. X XEOM X$echo $n "Where is yet-to-be-read mail spooled? [$dflt] $c" X. myread Xmaildir="$ans" Xcase $maildir in X'') maildir=$dflt ;; Xesac X X: find out how to find out full name X$echo " " Xcase "$berknam" in Xdefine) X dflt=y;; Xundef) X dflt=n;; X*) X if bsd || xenix; then X dflt=y X else X dflt=n X fi X ;; Xesac X$echo "Does your /etc/passwd file keep full names in Berkeley/V7 format (name first" X$echo $n "thing after ':' in GCOS field)? [$dflt] $c" X. myread Xcase $ans in X '') ans=$dflt ;; Xesac Xcase $ans in X y*) X passnam=define X berknam=define X usgnam=undef X nametype=bsd X ;; X *) X $echo " " X case "$usgname" in X define) X dflt=y;; X undef) X dflt=n;; X *) X if usg; then X dflt=y X else X dflt=n X fi X ;; X esac X $echo "Does your passwd file keep full names in USG format (name sandwiched" X $echo $n "between a '-' and a '(')? [$dflt] $c" X . myread X case $ans in X '') ans=$dflt ;; X esac X case $ans in X n*) X $echo "Full name will be taken from ~/.fullname" X passnam=undef X berknam=undef X usgnam=undef X nametype=other X ;; X *) X passnam=define X berknam=undef X usgnam=define X nametype=usg X ;; X esac X ;; Xesac X X: see if we need a special compiler X$echo " " Xif usg; then X case "$cc" in X '') X case "$Mcc" in X /*) dflt='Mcc' X ;; X *) X if $contains '\-M' $mansrc/cc.1 >/dev/null 2>&1 ; then X dflt='cc -M' X else X dflt='cc' X fi X ;; X esac X ;; X *) dflt="$cc";; X esac X $cat <<'EOM' X XOn some systems the default C compiler will not resolve multiple global Xreferences that happen to have the same name. On some such systems the X"Mcc" command may be used to force these to be resolved. On other systems Xa "cc -M" command is required. What command will force resolution on XEOM X $echo $n "this system? [$dflt] $c" X . myread X cc="$ans" X case "$cc" in X '') cc="$dflt" ;; X esac Xelse X $echo "Not a USG system--assuming cc can resolve multiple definitions." X cc=cc Xfi X X: see if we should throw a -i into the Makefile X$echo " " Xif pdp11; then X if $contains '\-i' $mansrc/cc.1 >/dev/null 2>&1 ; then X $echo $n "Your system appears to have separate I and D space. Is this true? [y] $c" X . myread X case $ans in X n*|f*) iandd='' ;; X *) iandd='-i' ;; X esac X else X $echo "Your system appears to NOT have separate I and D space." X $echo $n "Is this correct? [y] $c" X . myread X case $ans in X n*|f*) iandd='-i' ;; X *) iandd='' ;; X esac X fi Xelse X $echo "Not a pdp11--assuming no separate I and D." Xfi X X: index or strcpy X$echo " " Xif $contains index.o libc.list >/dev/null 2>&1 ; then X $echo "Your system appears to use index() and rindex() rather than strchr()" X $echo $n "and strrchr(). Is this correct? [y] $c" X . myread X case $ans in X n*|f*) strchr='define' ;; X *) strchr='undef' ;; X esac Xelse X $echo "Your system appears to use strchr() and strrchr() rather than index()" X $echo $n "and rindex(). Is this correct? [y] $c" X . myread X case $ans in X n*|f*) strchr=undef ;; X *) strchr=define ;; X esac Xfi X X: bcopy/bzero or memcpy/memset X$echo " " Xif $contains bcopy.o libc.list >/dev/null 2>&1 ; then X $echo "Your system appears to use bcopy() and bzero() rather than memcpy()" X $echo $n "and memset(). Is this correct? [y] $c" X . myread X case $ans in X n*|f*) memcpy='define' ;; X *) memcpy='undef' ;; X esac Xelse X $echo "Your system appears to use memcpy() and memset() rather than bcopy()" X $echo $n "and bzero(). Is this correct? [y] $c" X . myread X case $ans in X n*|f*) memcpy='undef' ;; X *) memcpy='define' ;; X esac Xfi X X: check for tzset. X$echo " " Xif $contains tzset libc.list >/dev/null 2>&1 || X $contains mktime libc.list >/dev/null 2>&1 || X $contains tzset /usr/include/time.h >/dev/null 2>&1 ; then X $echo "Your system appears to use tzset() rather than ftime()." X $echo $n "Is this correct? [y] $c" X . myread X case $ans in X n*|f*) tzset='undef' ;; X *) tzset='define' ;; X esac Xelse X $echo "Your system appears to use ftime() rather than tzset()." X $echo $n "Is this correct? [y] $c" X . myread X case $ans in X n*|f*) tzset='define' ;; X *) tzset='undef' ;; X esac Xfi X X: determine how to determine when a file is a mailbox Xcase "$mboxchar" in X'') dflt=F;; X*) dflt="$mboxchar";; Xesac X$cat <<'EOM' X XIn saving articles, trn wants to differentiate between saving to mailbox Xformat files and normal files. It does this by examining the first character Xof the file in question. On most systems the first line starts "From...", Xso the first character is F. On other systems there are magic cookies like Xcontrol codes between articles, so one of those would be first. For example, XMMDF messages are seperated with lines of 4 control-A's. On your system, if a XEOM X$echo $n "file is in mailbox format, what is the first character of that file? [$dflt] $c" X. myread Xmboxchar="$ans" Xcase $mboxchar in X'') mboxchar="$dflt" ;; Xesac Xcase $mboxchar in X'F') ;; X"$CTRLA") ;; X*) cat <<'EOM' XYou will need to edit the shell script mbox.saver to properly append an Xarticle to a mailbox. The arguments to the script are documented in XEOM X case $shsharp in X false) X $echo "comments in mbox.saver.std." X ;; X true) X $echo "comments in the shell script itself." X ;; X esac Xesac X$rm -f grimble X: where do we get termlib routines from X$echo " " Xans=`loc libcurses.a x /usr/lib /usr/local/lib /lib` Xcase "$ans" in X/*) X ar t $ans >grimble X if $contains tputs.o grimble >/dev/null 2>&1; then X termlib='-lcurses' X havetlib=define X $echo "Terminfo library found." X else X ans=x X fi X ;; Xesac Xcase "$ans" in Xx) X ans=`loc libtermlib.a x /usr/lib /usr/local/lib /lib` X case "$ans" in X /usr/lib*|/lib*) X termlib='-ltermlib' X havetlib=define X $echo "Termlib library found." X ;; X /*) X termlib="$ans" X havetlib=define X $echo "Termlib library found." X ;; X *) X if xenix; then X ans=/lib/Llibtermcap.a X else X ans=`loc libtermcap.a x /usr/lib /usr/local/lib /lib` X fi X case "$ans" in X /usr/lib*|/lib*) X termlib='-ltermcap' X havetlib=define X $echo "Termcap library found." X ;; X /*) X termlib="$ans" X havetlib=define X $echo "Termcap library found." X ;; X *) X case "$termlib" in X '') X $echo $n "Your system appears to NOT have termlib-style routines. Is this true? [y] $c" X . myread X case $ans in X n*|f*) havetlib=define X $echo "Then where are the termlib-style routines kept (specify either -llibname" X $echo $n " or full pathname (~name ok))? $c" X . myread X termlib=`filexp $ans` X ;; X *) havetlib=undef X termlib='' X $echo "You will have to play around with term.c then." X ;; X esac X $echo " " X ;; X *) $echo "You said termlib was $termlib before." X ;; X esac X ;; X esac X ;; X esac X ;; Xesac X: see if there is a whoami file Xif $test -r /usr/include/whoami.h ; then X whoami=define X $echo "whoami.h found." Xelse X whoami=undef Xfi X X: check for a ptem file Xif $test -r /usr/include/sys/ptem.h ; then X sysptem=define X $echo "ptem.h found." Xelse X sysptem=undef Xfi X X: see if this is a termio system Xultrix ; ultrix=$? Xsun ; sun=$? Xpyr ; pyr=$? Xif $test -r /usr/include/termio.h -a $ultrix -ne 0 -a $sun -ne 0 -a $pyr -ne 0; then X termio=define X $echo "termio.h found." X else X if $test -r /usr/include/sgtty.h ; then X termio=undef X $echo "sgtty.h found." X else X termio=undef X $echo "Neither termio.h nor sgtty.h found--you could have problems." X fi Xfi X X: see if this system has fcntl Xif $test -r /usr/include/fcntl.h ; then X fcntl=define X $echo "fcntl.h found." Xelse X fcntl=undef X $echo "No fcntl.h found, but that's ok." Xfi X X: see if ioctl defs are in sgtty/termio or sys/ioctl Xif $test -r /usr/include/sys/ioctl.h ; then X ioctl=define X $echo "sys/ioctl.h found." Xelse X ioctl=undef X $echo "sys/ioctl.h not found, assuming ioctl args are defined in sgtty.h." Xfi X X: see if the system has sigblock Xif $contains sigblock.o libc.list >/dev/null 2>&1 ; then X $echo "sigblock() found." X sigblock=define Xelse X sigblock=undef Xfi X X: see if the system has getwd Xif $contains getwd.o libc.list >/dev/null 2>&1 ; then X $echo "getwd() found." X getcwd=undef Xelse X: see if the system has getcwd Xif $contains getcwd.o libc.list >/dev/null 2>&1 ; then X $echo "getcwd() found." X getcwd=define Xelse X getcwd=undef Xfi Xfi X X: see if there is a vfork Xif $contains vfork.o libc.list >/dev/null 2>&1 ; then X $echo "vfork() found." X novfork='undef' Xelse X $echo "No vfork() found--will use fork() instead." X novfork='define' Xfi X X: check for rename Xif $contains rename.o libc.list >/dev/null 2>&1 ; then X $echo "rename() found." X rename='define' Xelse X $echo "No rename() found -- we'll emulate it." X rename='undef' Xfi X X: check for truncate Xif $contains truncate.o libc.list >/dev/null 2>&1 ; then X $echo "truncate() found." X truncate='define' Xelse X $echo "No truncate() found -- we'll emulate it." X truncate='undef' Xfi X X: see if YP could be running here Xif $contains yp_master.o libc.list >/dev/null 2>&1 ; then X $echo "YP may be running -- will use getpwent(), just in case." X getpwent='define' Xelse X: see if there is a getpw Xif $contains getpw.o libc.list >/dev/null 2>&1 ; then X $echo "getpw() found." X getpwent='undef' Xelse X $echo "No getpw() found--will use getpwent() instead." X getpwent='define' Xfi Xfi X X: default Xsigret=int X: determine type of signal function Xif [ -f /usr/include/signal.h ] Xthen X $cpp /usr/include/signal.h >sigtest Xelse Xif [ -f /usr/include/sys/signal.h ] Xthen X $cpp /usr/include/sys/signal.h >sigtest Xfi Xfi Xif grep "$WHITE*void$WHITE*(\*signal())();" sigtest >/dev/null Xthen X sigret=void Xfi X$echo "signal() returns $sigret on this system" X: see how we will look up site name Xdouname=undef Xgethostname=undef Xphostname=undef Xif $test ! "X$hostfile" = X ; then X gethostname=define Xelse Xif $test "X$hostcmd" = X ; then X : it is already compiled in Xelse Xif $contains gethostname.o libc.list >/dev/null 2>&1 ; then X $echo "gethostname() found." X gethostname=define Xelse X if $contains uname.o libc.list >/dev/null 2>&1 ; then X $echo "uname() found." X douname=define X else X case $hostcmd in X '') ;; X *) X $cat <<EOT X XThere is no gethostname() or uname() on this system. You have two Xpossibilites at this point: X X1) You can have your site name ($sitename) compiled into trn, which lets X trn start up faster, but makes your binaries non-portable, or X2) you can have trn use a X X popen("$hostcmd","r") X X which will start slower but be more portable. X XOption 1 will use whoami.h if you have one. If you want option 2 but with Xa different command, you can edit config.h after this shell script is done. X XEOT X case "$phostname" in X define) dflt=n;; X undef) dflt=y;; X '') X case $portable in X define) dflt=n ;; X *) dflt=y ;; X esac X ;; X esac X $echo $n "Do you want your site name compiled in? [$dflt] $c" X . myread X case $ans in X '') ans=$dflt;; X esac X case $ans in X n*) phostname=define ;; X *) hostcmd='' phostname=undef;; X esac X ;; X esac X case $hostcmd in X '') X case $whoami in X define) X $echo 'No hostname function--using whoami.h.' X ;; X undef) X $echo 'No hostname function--hardwiring "'$sitename'".' X ;; X esac X ;; X esac X fi Xfi Xfi Xfi X X: see if we need -ljobs and if we have sigset, etc. Xif $test -r /usr/lib/libjobs.a || $test -r /usr/local/lib/libjobs.a ; then X $echo "Jobs library found." X normsig=undef X jobslib='-ljobs' Xelse X if bsd; then X $echo "No jobs library found. (I suppose this is at least 4.2...)" X else X $echo "No jobs library found. (That's okay, we all have our faults.)" X fi X normsig=define X jobslib='' Xfi X: set the right options for cc and include the x library for XENIX Xif xenix; then X if $test -d /lib/386 ; then X iandd="-M3e" X else X iandd="-M2let8 -LARGE -F 3000" X fi X jobslib=-lx X chsize=define Xelse Xif $test -r /lib/libx.a ; then X $echo "Found Xenix library; using chsize()" X jobslib=-lx X chsize=define Xelse X chsize=undef Xfi Xfi X: see if there are directory access routines out there Xif $test -r /usr/lib/libndir.a || $test -r /usr/local/lib/libndir.a ; then X $echo "Ndir library found." X if $test -r /usr/lib/libndir.a; then X ndirlib='-lndir' X else X ndirlib="/usr/local/lib/libndir.a" X fi X libndir=define X usendir=undef X ndirc='' X ndiro='' X dirtype=direct Xelse X ndirlib='' X libndir=undef X if $contains readdir.o libc.list >/dev/null 2>&1 ; then X $echo "No ndir library found, but you have readdir() so we'll use that." X usendir=undef X ndirc='' X ndiro='' X if sgi ; then X dirtype=direct X dirinc="<sys/dir.h>" X $echo "Using direct directory structure." X else X if $test -r /usr/include/dirent.h ; then X $echo "Using dirent directory structure." X dirtype=dirent X dirinc="<dirent.h>" X else X $echo "Using direct directory structure." X dirtype=direct X dirinc="<sys/dir.h>" X fi X fi X else X if xenix; then X $echo "Using Xenix readdir() from -lx." X usendir=undef X ndirc='' X ndiro='' X dirtype=direct X dirinc="<sys/ndir.h>" X $echo "Using direct directory structure." X else X $echo "No ndir library and no readdir()--using ./ndir.c." X usendir=define X ndirc='ndir.c' X ndiro='ndir.o' X dirtype=direct X fi X fi Xfi X X: check if they want threads by default Xcase "$threaddef" in X F*) dflt="n";; X *) dflt="y";; Xesac X$cat <<EOT X XTrn has two distinct operating modes (selected by the -x option): Xtraditional rn and threaded rn. If you like, trn will check the first Xletter of the command name and default to threaded mode (-x) if it is Xa 't', or run as traditional rn (+x) if it isn't (this lets you install Xas both trn and rn, linked together). Otherwise, you can install trn Xto default to threaded rn (-x) no matter what its name is. Would you XEOT X$echo $n "prefer the latter? (defaults to -x, regardless of name)? [$dflt] $c" X. myread Xcase "$ans" in X'') ans="$dflt";; Xesac Xcase "$ans" in X n*|f*) threaddef='FALSE' X ans=' when -x is specified';; X *) threaddef='TRUE' X ans='';; Xesac X: check if they want the thread selector used by default Xcase "$selectdef" in X F*) dflt="n";; X *) dflt="y";; Xesac X$cat <<EOT X XWhen the -X option is specified, trn will set the default command Xfor starting a newsgroup to be the thread selector. Should the -X XEOT X$echo $n "option be on by default$ans? [$dflt] $c" X. myread Xcase "$ans" in X'') ans="$dflt";; Xesac Xcase "$ans" in X n*|f*) selectdef='FALSE';; X *) selectdef='TRUE';; Xesac X X: locate spool directory and check if rrn Xcase "$isrrn" in Xdefine) X dflt="y";; X*) X dflt="n";; Xesac Xisrrn='' Xwhile $test -z "$isrrn" ; do X $echo " " X $echo $n "Do you want to build the NNTP versions of trn (trrn) and mthreads? [$dflt] $c" X . myread X case "$ans" in X '') ans="$dflt";; X esac X case "$ans" in X n*) X isrrn=undef;; X y*) X isrrn=define X spool=/tmp X $echo "net.foobar 00001 00001 y" > .falseactive X X case "$serverfile" in X '') dflt="no default" ;; X *) dflt="$serverfile";; X esac X X $cat <<'EOM' X XTrrn determines the machine to use as a news server by two means: X X 1. It examines the environment variable NNTPSERVER for X a machine name; this allows users to use server machines X other than the default. X X 2. It looks in a file which contains the name of a server X machine. X XYou must create the file mentioned in (2), above. Simply put the name Xof the machine you wish to use as your news server in this file. XIf you really want, you can use # for comments and blank lines in Xthis file as well. X XEOM X X ans='blurfl/dyick' X while $test ! -r "$ans" ; do X $echo $n "Enter the name of the news server file: [$dflt] $c" X . myread X case "$ans" in X '') ans="$dflt";; X esac X ans=`filexp "$ans"` X if $test ! -r $ans ; then X $echo "Can't find $ans" X ans='blurfl/dyick' X fi X done X serverfile="$ans" X X case "$NNTPSRC" in X '') dflt="no default";; X *) dflt="$NNTPSRC";; X esac X X ans='blurfl/dyick' X while $test ! -d "$ans"; do X $echo $n "Enter the pathname of the NNTP source directory: [$dflt] $c" X . myread X case "$ans" in X '') ans="$dflt";; X esac X ans=`filexp "$ans"` X if $test ! -r $ans/common/nntp.h ; then X $echo "Can't find $ans/common/nntp.h!" X ans='blurfl/dyick' X fi X done X NNTPSRC="$ans" Xcat > server.h <<EOF_SERVE X#ifdef SERVER X XEXT char *getserverbyfile(); XEXT int server_init(); XEXT void put_server(); XEXT int get_server(); XEXT void close_server(); X X#include "$NNTPSRC/common/nntp.h" X#endif XEOF_SERVE X X esac X Xdone X: hack for Unisys NET-5000 Xcase "$isrrn" in Xdefine) X if $test -d /usr/include/NET-5000 ; then X $echo "I sense you are on a Unisys 5000 computer...poor soul." X rrninclude="-I/usr/include/NET-5000 -DEXCELAN -DUSG" X socketlib=-lsocket X fi X ;; X*) ;; Xesac X X Xcase "$spool" in X'') X dflt=/usr/spool/news X ;; X*) dflt="$spool";; Xesac Xcase "$isrrn" in Xdefine) ans=/tmp;; X*) ans='blurfl/dyick';; Xesac Xwhile $test ! -d $ans; do X $echo " " X case "$ans" in X blurfl*);; X *) $echo "Directory $ans not found.";; X esac X $echo $n "Where is news spooled (~name ok)? [$dflt] $c" X . myread X case "$ans" in X '') ans="$dflt";; X esac X spool="$ans" X case $spool in X ~*) X ans=`filexp $spool` X $echo "(That is $ans on this particular system.)" X case $portable in X undef) spool=$ans ;; X esac X ;; X *) X ans=$spool X ;; X esac Xdone X X: check on .thread file placement Xcase "$isrrn" in Xdefine) X case "$threaddir" in X ''|'.') dflt="/usr/spool/threads";; X *) dflt="$threaddir";; X esac X $echo " " X $echo "Pick a directory where you would like the thread files to" X $echo $n "be placed: [$dflt] $c" X . myread X case "$ans" in X ''|'.') ans="$dflt";; X esac X ;; X*) X case "$threaddir" in X ''|'.') dflt=".";; X *) dflt="$threaddir";; X esac X $cat <<EOT X XBy default we place each group's .thread file in the same spool Xdirectory as the article files. Alternately, you can place the Xdata files in a separate directory if space is tight on the news Xdrive. Where would you like them put? (use '.' to specify the XEOT X $echo $n "default): [$dflt] $c" X . myread X case "$ans" in X '') ans="$dflt";; X esac X ;; Xesac Xthreaddir="$ans" X X: locate active file Xcase "$active" in X'') X dflt=$lib/active X ;; X*) dflt="$active";; Xesac Xcase "$isrrn" in Xdefine) myactive=.falseactive;; X*) myactive='blurfl/dyick' Xesac Xwhile $test ! -f "$myactive"; do X $echo " " X case "$myactive" in X blurfl*);; X *) "File $myactive not found.";; X esac X $echo $n "Where is the active file (~name ok)? [$dflt] $c" X . myread X case "$ans" in X '') ans="$dflt";; X esac X active="$ans" X case $active in X ~*) X myactive=`filexp $active` X $echo "(That is $myactive on this particular system.)" X case $portable in X undef) active=$myactive ;; X esac X ;; X *) X myactive=$active X ;; X esac X if $test -d $myactive ; then X myactive=$myactive/active X active=$active/active X fi Xdone X X: check for 2.10.2 and above X$echo " " Xif $contains ' [0-9][0-9]* [0-9]' "$myactive" >/dev/null 2>&1; then X case "$norelay" in X undef) dflt="y";; X *) dflt="n";; X esac X case "$isrrn" in X define) X $echo "Is your NNTP server running an old version of news software," ;; X *) $echo "Is your system running an old version of news software," ;; X esac X $echo $n "predating B News 2.10.3? [${dflt}] $c" X . myread X case "$ans" in X '') ans=$dflt;; X esac X case "$ans" in X y*) X norelay='undef' X $echo "Looks like you are running at least 2.10.2 news." X ;; X *) norelay='define' ;; X esac X mininact=define Xelse X $echo "It doesn't look like you are running 2.10.2 news yet. Are you planning" X $echo $n "to install it in the near future? [y] $c" X . myread X case $ans in X n*) mininact=undef ;; X *) mininact=define ;; X esac X norelay='undef' Xfi X X X: check for void type X$echo " " X$echo "Checking to see if your C compiler groks the void type..." X$cat >try.c <<'EOCP' Xvoid main(); XEOCP Xif cc -c try.c >/dev/null 2>&1 ; then X novoid='undef' X $echo "Yup, it does." Xelse X novoid='define' X $echo "Nope, it doesn't (boo hiss). I will substitute int." Xfi X$rm try.* X X: find out which shell people like to use most Xans='blurfl/dyick' Xwhile $test ! -f "$ans" ; do X case $ans in X blurfl*) ;; X *) $echo "$ans does not appear to exist." ;; X esac X case "$pref" in X '') X if $test -f /bin/ksh; then X dflt='/bin/ksh' X else X if $test -f /bin/csh; then X dflt='/bin/csh' X else X dflt='/bin/sh' X fi X fi X ;; X *) dflt="$pref";; X esac X $echo " " X $echo "Give the full path name of the shell most people like to use on your" X $echo $n "system: [$dflt] $c" X . myread X case $ans in X '') ans=$dflt ;; X esac Xdone Xpref=$ans X X: locate the preferred pager for this system Xcase "$pager" in X'') X case $pg in X /*) dflt=$pg X ;; X esac X case $more in X /*) dflt=$more X ;; X esac X case $dflt in X '') dflt=/usr/ucb/more X ;; X esac X ;; X*) dflt="$pager";; Xesac Xpager='blurfl/dyick' Xwhile $test ! -f "$pager" ; do X case $pager in X blurfl*) X $echo " " X $echo "(If your kernel does terminal paging then you may answer this with '/bin/cat'.)" X ;; X /*) $echo "$pager does not appear to exist." X $echo " " X ;; X *) $echo "Please give the full path name." X $echo " " X ;; X esac X $echo $n "What pager is used on your system? [$dflt] $c" X . myread X pager="$ans" X case $pager in X '') pager="$dflt" ;; X esac Xdone X X: determine default editor Xcase "$defeditor" in X'') X dflt=`loc vi /usr/ucb $pth` X ;; X*) dflt="$defeditor" X ;; Xesac Xdefeditor='blurfl/dyick' Xwhile $test ! -f "$defeditor" ; do X case $defeditor in X blurfl*) ;; X *) $echo "$defeditor does not appear to exist." ;; X esac X $echo " " X $echo $n "What is the default editor on your system? [$dflt] $c" X . myread X defeditor="$ans" X case $defeditor in X '') defeditor=$dflt ;; X esac Xdone X X: determine mailer for Rnmail to use X$echo " " Xif $test ! -f "$mailer"; then X mailer= X for x in /usr/lib/sendmail /bin/smail /usr/bin/smail \ X /usr/lib/mail/execmail; do X if $test "$mailer" = "" -a -f $x; then X mailer=$x X fi X done X if $test ! -f "$mailer"; then X if usg && $test -f $libexp/recmail; then X mailer=$libexp/recmail X else X mailer=/bin/mail X fi X fi Xfi X$echo "Mail sender is $mailer" X X: check for internet mailer Xcase "$internet" in Xdefine) dflt=y;; Xundef) dflt=n;; X*) X case "$isrrn" in X define) dflt=y ;; X *) dflt=n ;; X esac X ;; Xesac Xcat <<EOM X XSome newer mailers can deliver mail to addresses of the INTERNET persuasion, Xsuch as user@host.UUCP. Other older mailers require the complete path to Xthe destination to be specified in the address. Does your mailer understand XEOM X$echo $n "INTERNET addresses? [$dflt] $c" X. myread Xcase "$ans" in X'') ans=$dflt;; Xesac Xcase "$ans" in Xy*) internet=define;; X*) internet=undef;; Xesac X X: determine where public executables go Xcase "$rnbin" in X'') END_OF_FILE echo shar: 1 control character may be missing from \"'Configure.01'\" if test 49808 -ne `wc -c <'Configure.01'`; then echo shar: \"'Configure.01'\" unpacked with wrong size! fi # end of 'Configure.01' fi if test -f 'INIT' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'INIT'\" else echo shar: Extracting \"'INIT'\" \(18 characters\) sed "s/^X//" >'INIT' <<'END_OF_FILE' X-ESAMPLE="sample" END_OF_FILE if test 18 -ne `wc -c <'INIT'`; then echo shar: \"'INIT'\" unpacked with wrong size! fi # end of 'INIT' fi if test -f 'util.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'util.c'\" else echo shar: Extracting \"'util.c'\" \(10242 characters\) sed "s/^X//" >'util.c' <<'END_OF_FILE' X/* $Header: util.c,v 4.3.3.2 90/08/20 16:51:44 davison Trn $ X * X * $Log: util.c,v $ X * Revision 4.3.3.2 90/08/20 16:51:44 davison X * Fixed getcwd call to not overflow any buffers. X * X * Revision 4.3.3.1 90/07/21 20:34:10 davison X * Initial Trn Release X * X * Revision 4.3.2.6 90/04/23 00:24:42 sob X * A bit of clean up. X * X * Revision 4.3.2.5 90/03/17 21:34:21 sob X * Reworked VOIDSIG into SIGRET. X * X * Revision 4.3.2.4 89/12/14 23:58:54 sob X * Fixed small bug reported by fletcher@cs.utexas.edu in getwd(). X * X * Revision 4.3.2.3 89/11/08 04:47:11 sob X * Added VOIDSIG handling for SunOS 4.X X * X * Revision 4.3.2.2 89/11/07 23:19:35 sob X * Bug fixes for SIGSTP problems X * X * Revision 4.3.2.1 89/11/06 01:03:21 sob X * Added RRN support from NNTP 1.5 X * X * Revision 4.3.1.2 85/05/15 14:44:27 lwall X * Last arg of execl changed from 0 to Nullch [(char*)0]. X * X * Revision 4.3.1.1 85/05/10 11:41:30 lwall X * Branch for patches. X * X * Revision 4.3 85/05/01 11:51:44 lwall X * Baseline for release with 4.3bsd. X * X */ X X#include "EXTERN.h" X#include "common.h" X#include "final.h" X#include "ndir.h" X#include "INTERN.h" X#include "util.h" X Xvoid Xutil_init() X{ X ; X} X X/* fork and exec a shell command */ X Xint Xdoshell(shl,s) Xchar *s, *shl; X{ X int status, pid, w; X SIGRET (*signal())(); X char *shell; X X#ifdef SIGTSTP X sigset(SIGTSTP,SIG_DFL); X sigset(SIGTTOU,SIG_DFL); X sigset(SIGTTIN,SIG_DFL); X#endif X if (shl != Nullch) X shell = shl; X else if ((shell = getenv("SHELL")) == Nullch || !*shell) X shell = PREFSHELL; X if ((pid = vfork()) == 0) { X#ifdef SERVER X int i; X X /* This is necessary to keep bourne shell from puking */ X X for (i = 3; i < 10; ++i) X close(i); X#endif /* SERVER */ X X if (*s) X execl(shell, shell, "-c", s, Nullch); X else X execl(shell, shell, Nullch, Nullch, Nullch); X _exit(127); X } X signal(SIGINT, SIG_IGN); X signal(SIGQUIT, SIG_IGN); X waiting = TRUE; X while ((w = wait(&status)) != pid && w != -1) X ; X if (w == -1) X status = -1; X waiting = FALSE; X sigset(SIGINT, int_catcher); /* always catch interrupts */ X signal(SIGQUIT, SIG_DFL); X#ifdef SIGTSTP X sigset(SIGTSTP,stop_catcher); X sigset(SIGTTOU,stop_catcher); X sigset(SIGTTIN,stop_catcher); X#endif X return status; X} X Xstatic char nomem[] = "rn: out of memory!\n"; X X/* paranoid version of malloc */ X Xchar * Xsafemalloc(size) XMEM_SIZE size; X{ X char *ptr; X char *malloc(); X X ptr = malloc(size ? size : (MEM_SIZE)1); X if (ptr != Nullch) X return ptr; X else { X fputs(nomem,stdout) FLUSH; X sig_catcher(0); X } X /*NOTREACHED*/ X} X X/* paranoid version of realloc */ X Xchar * Xsaferealloc(where,size) Xchar *where; XMEM_SIZE size; X{ X char *ptr; X char *realloc(); X X ptr = realloc(where,size?size:1); /* realloc(0) is NASTY on our system */ X if (ptr != Nullch) X return ptr; X else { X fputs(nomem,stdout) FLUSH; X sig_catcher(0); X } X /*NOTREACHED*/ X} X X/* safe version of string copy */ X Xchar * Xsafecpy(to,from,len) Xchar *to; Xregister char *from; Xregister int len; X{ X register char *dest = to; X X if (from != Nullch) X for (len--; len && (*dest++ = *from++); len--) ; X *dest = '\0'; X return to; X} X X/* safe version of string concatenate, with \n deletion and space padding */ X Xchar * Xsafecat(to,from,len) Xchar *to; Xregister char *from; Xregister int len; X{ X register char *dest = to; X X len--; /* leave room for null */ X if (*dest) { X while (len && *dest++) len--; X if (len) { X len--; X *(dest-1) = ' '; X } X } X if (from != Nullch) X while (len && (*dest++ = *from++)) len--; X if (len) X dest--; X if (*(dest-1) == '\n') X dest--; X *dest = '\0'; X return to; X} X X/* copy a string up to some (non-backslashed) delimiter, if any */ X Xchar * Xcpytill(to,from,delim) Xregister char *to, *from; Xregister int delim; X{ X for (; *from; from++,to++) { X if (*from == '\\' && from[1] == delim) X from++; X else if (*from == delim) X break; X *to = *from; X } X *to = '\0'; X return from; X} X X/* return ptr to little string in big string, NULL if not found */ X Xchar * Xinstr(big, little) Xchar *big, *little; X X{ X register char *t, *s, *x; X X for (t = big; *t; t++) { X for (x=t,s=little; *s; x++,s++) { X if (!*x) X return Nullch; X if (*s != *x) X break; X } X if (!*s) X return t; X } X return Nullch; X} X X/* effective access */ X X#ifdef SETUIDGID Xint Xeaccess(filename, mod) Xchar *filename; Xint mod; X{ X int protection, euid; X X mod &= 7; /* remove extraneous garbage */ X if (stat(filename, &filestat) < 0) X return -1; X euid = geteuid(); X if (euid == ROOTID) X return 0; X protection = 7 & (filestat.st_mode >> X (filestat.st_uid == euid ? 6 : X (filestat.st_gid == getegid() ? 3 : 0) X )); X if ((mod & protection) == mod) X return 0; X errno = EACCES; X return -1; X} X#endif X X/* X * Get working directory X */ X#ifdef GETCWD Xchar * Xgetwd(np) Xchar *np; X{ X char * name; X extern char * getcwd(); X name = getcwd(np,512); X return(name); X} X#else X#ifndef GETWD Xchar * Xgetwd(np) /* shorter but slower */ Xchar *np; X{ X FILE *popen(); X FILE *pipefp = popen("/bin/pwd","r"); X X if (pipefp == Nullfp) { X printf("Can't run /bin/pwd\n") FLUSH; X finalize(1); X } X fgets(np,512,pipefp); X np[strlen(np)-1] = '\0'; /* wipe out newline */ X pclose(pipefp); X return np; X} X#endif X#endif X/* just like fgets but will make bigger buffer as necessary */ X Xchar * Xget_a_line(original_buffer,buffer_length,fp) Xchar *original_buffer; Xregister int buffer_length; XFILE *fp; X{ X register int bufix = 0; X register int nextch; X register char *some_buffer_or_other = original_buffer; X X do { X if (bufix >= buffer_length) { X buffer_length *= 2; X if (some_buffer_or_other == original_buffer) { X /* currently static? */ X some_buffer_or_other = safemalloc((MEM_SIZE)buffer_length+1); X strncpy(some_buffer_or_other,original_buffer,buffer_length/2); X /* so we must copy it */ X } X else { /* just grow in place, if possible */ X some_buffer_or_other = saferealloc(some_buffer_or_other, X (MEM_SIZE)buffer_length+1); X } X } X if ((nextch = getc(fp)) == EOF) X return Nullch; X some_buffer_or_other[bufix++] = (char) nextch; X } while (nextch && nextch != '\n'); X some_buffer_or_other[bufix] = '\0'; X len_last_line_got = bufix; X return some_buffer_or_other; X} X X/* copy a string to a safe spot */ X Xchar * Xsavestr(str) Xchar *str; X{ X register char *newaddr = safemalloc((MEM_SIZE)(strlen(str)+1)); X X strcpy(newaddr,str); X return newaddr; X} X Xint Xmakedir(dirname,nametype) Xregister char *dirname; Xint nametype; X{ X#ifdef MAKEDIR X register char *end; X register char *s; X char tmpbuf[1024]; X register char *tbptr = tmpbuf+5; X X for (end = dirname; *end; end++) ; /* find the end */ X if (nametype == MD_FILE) { /* not to create last component? */ X for (--end; end != dirname && *end != '/'; --end) ; X if (*end != '/') X return 0; /* nothing to make */ X *end = '\0'; /* isolate file name */ X } X strcpy(tmpbuf,"mkdir"); X X s = end; X for (;;) { X if (stat(dirname,&filestat) >= 0 && (filestat.st_mode & S_IFDIR)) { X /* does this much exist as a dir? */ X *s = '/'; /* mark this as existing */ X break; X } X s = rindex(dirname,'/'); /* shorten name */ X if (!s) /* relative path! */ X break; /* hope they know what they are doing */ X *s = '\0'; /* mark as not existing */ X } X X for (s=dirname; s <= end; s++) { /* this is grody but efficient */ X if (!*s) { /* something to make? */ X sprintf(tbptr," %s",dirname); X tbptr += strlen(tbptr); /* make it, sort of */ X *s = '/'; /* mark it made */ X } X } X if (nametype == MD_DIR) /* don't need final slash unless */ X *end = '\0'; /* a filename follows the dir name */ X X return (tbptr==tmpbuf+5 ? 0 : doshell(sh,tmpbuf)); X /* exercise our faith */ X#else X sprintf(cmd_buf,"%s %s %d", filexp(DIRMAKER), dirname, nametype); X return doshell(sh,cmd_buf); X#endif X} X X#ifdef SETENV Xstatic bool firstsetenv = TRUE; Xextern char **environ; X Xvoid Xsetenv(nam,val) Xchar *nam, *val; X{ X register int i=envix(nam); /* where does it go? */ X X if (!environ[i]) { /* does not exist yet */ X if (firstsetenv) { /* need we copy environment? */ X int j; X#ifndef lint X char **tmpenv = (char**) /* point our wand at memory */ X safemalloc((MEM_SIZE) (i+2) * sizeof(char*)); X#else X char **tmpenv = Null(char **); X#endif /* lint */ X X firstsetenv = FALSE; X for (j=0; j<i; j++) /* copy environment */ X tmpenv[j] = environ[j]; X environ = tmpenv; /* tell exec where it is now */ X } X#ifndef lint X else X environ = (char**) saferealloc((char*) environ, X (MEM_SIZE) (i+2) * sizeof(char*)); X /* just expand it a bit */ X#endif /* lint */ X environ[i+1] = Nullch; /* make sure it's null terminated */ X } X environ[i] = safemalloc((MEM_SIZE) strlen(nam) + strlen(val) + 2); X /* this may or may not be in */ X /* the old environ structure */ X sprintf(environ[i],"%s=%s",nam,val);/* all that work just for this */ X} X Xint Xenvix(nam) Xchar *nam; X{ X register int i, len = strlen(nam); X X for (i = 0; environ[i]; i++) { X if (strnEQ(environ[i],nam,len) && environ[i][len] == '=') X break; /* strnEQ must come first to avoid */ X } /* potential SEGV's */ X return i; X} X#endif X Xvoid Xnotincl(feature) Xchar *feature; X{ X printf("\nNo room for feature \"%s\" on this machine.\n",feature) FLUSH; X} X Xchar * Xgetval(nam,def) Xchar *nam,*def; X{ X char *val; X X if ((val = getenv(nam)) == Nullch || !*val) X val = def; X return val; X} X X/* grow a static string to at least a certain length */ X Xvoid Xgrowstr(strptr,curlen,newlen) Xchar **strptr; Xint *curlen; Xint newlen; X{ X if (newlen > *curlen) { /* need more room? */ X if (*curlen) X *strptr = saferealloc(*strptr,(MEM_SIZE)newlen); X else X *strptr = safemalloc((MEM_SIZE)newlen); X *curlen = newlen; X } X} X Xvoid Xsetdef(buffer,dflt) Xchar *buffer,*dflt; X{ X#ifdef STRICTCR X if (*buffer == ' ') X#else X if (*buffer == ' ' || *buffer == '\n') X#endif X { X if (*dflt == '^' && isupper(dflt[1])) X *buffer = Ctl(dflt[1]); X else X *buffer = *dflt; X } X} END_OF_FILE if test 10242 -ne `wc -c <'util.c'`; then echo shar: \"'util.c'\" unpacked with wrong size! fi # end of 'util.c' fi echo shar: End of archive 2 \(of 14\). cp /dev/null ark2isdone MISSING="" for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have unpacked all 14 archives. rm -f ark[1-9]isdone ark[1-9][0-9]isdone else echo You still must unpack the following archives: echo " " ${MISSING} fi exit 0 exit 0 # Just in case... -- Please send comp.sources.unix-related mail to rsalz@uunet.uu.net. Use a domain-based address or give alternate paths, or you may lose out.