home *** CD-ROM | disk | FTP | other *** search
/ Unix System Administration Handbook 1997 October / usah_oct97.iso / news / cnews.tar / quiz < prev    next >
Text File  |  1995-04-27  |  20KB  |  558 lines

  1. #! /bin/sh
  2. PATH=:/bin:/usr/bin
  3.  
  4. # configuration variables to remember for next time
  5. vars='newsuid newsgid newsarts newsov newsctl
  6.     newsbin newspath newsumask newsconfig newscrisis newsmaster
  7.     addrsize fake storeval faststdio fakehdrs ranlib make include
  8.     cc copts ldopts postlibs uucptype dftype dfdirs
  9.     archive spacelow nfsgroup server rbin bin faststrchr sftype'
  10. # where to remember them, by default
  11. memory=conf/quiz.def
  12.  
  13. cat <<!
  14. This interactive command will set up control files needed to build
  15. and install C News.  It will not actually build or install anything
  16. itself, so feel free to abort and start again.
  17.  
  18. You probably need your system manuals handy.  You definitely need pencil
  19. and paper handy, for taking notes.
  20.  
  21. When a question is asked in the form \`How are you [okay]? ', the
  22. answer in brackets is what you will get if you just hit RETURN.
  23. (If you want to give an empty string as the answer, type a single
  24. \`-' instead.)  If you type a line starting with \`!', the rest of
  25. the line will be run as a shell command, and the question will be
  26. asked again.
  27. !
  28.  
  29. ask=conf/ask
  30. yesno=conf/yesno
  31. notinlist=conf/notinlist
  32. chmod +x $ask $yesno $notinlist conf/useanswers
  33.  
  34. case $# in
  35. 0)    ;;
  36. *)    memory="$1"    ;;
  37. esac
  38. if test -r $memory
  39. then
  40.     echo
  41.     tmp=`$yesno 'Do you want to use your previous answers as defaults' no`
  42.     case "$tmp" in
  43.     yes)    echo
  44.         echo 'Picking up defaults, from last run...'
  45.         . $memory
  46.         echo 'got them'
  47.         ;;
  48.     esac
  49. fi
  50.  
  51. cat <<!
  52.  
  53. C News wants to keep most of its files under a uid which preferably
  54. should be all its own.  Its programs, however, can and probably should
  55. be owned by another user, typically the same one who owns most of the
  56. rest of the system.  (Note that on a system running NFS, any program
  57. not owned by "root" is a gaping security hole.)
  58. !
  59. newsuid=`$ask 'What user id should be used for news files' ${newsuid-news}`
  60. newsgid=`$ask 'What group id should be used for news files' ${newsgid-news}`
  61.  
  62. cat <<!
  63.  
  64. You have to decide the locations, in the file system, of four major
  65. parts of C News:  the article tree, the overview files (which may be
  66. in the article tree, or may be elsewhere), the control files, and the
  67. programs.  These locations are known, within much of the software, by
  68. the names of the environment variables used to hold them.  There are
  69. some traditional choices, not always the most reasonable in retrospect,
  70. that some reader software may depend on.
  71.  
  72. purpose        variable    traditional location    reasonable location
  73. -------        --------    --------------------    -------------------
  74. article tree    NEWSARTS    /usr/spool/news        /var/news
  75. overview files    NEWSOV        /usr/spool/news        /var/news
  76. control files    NEWSCTL        /usr/lib/news        /etc/news
  77. programs    NEWSBIN        /usr/lib/newsbin    /usr/libexec/news
  78.  
  79. !
  80. newsarts=`$ask 'Where should the article tree go' ${newsarts-/var/news}`
  81. newsov=`$ask 'Where should overview files go' ${newsov-/var/news}`
  82. newsctl=`$ask 'Where should control files go' ${newsctl-/etc/news}`
  83. newsbin=`$ask 'Where should programs go' ${newsbin-/usr/libexec/news}`
  84.  
  85. case "$newspath" in
  86. '')    pathok=no    ;;
  87. *)    echo
  88.     echo "Is   $newspath"
  89.     echo 'the correct path to follow to find standard programs on your'
  90.     pathok=`$yesno 'system' yes`
  91.     ;;
  92. esac
  93.  
  94. case "$pathok" in
  95. no)    newspath='/bin:/usr/bin'
  96.     echo
  97.     echo 'C News by default assumes that all normal Unix programs can be'
  98.     echo 'found in /bin or /usr/bin.  Modern systems mostly have messed'
  99.     echo 'this up, sometimes pretty badly, and other directories like'
  100.     echo '/usr/ucb or /usr/contrib/bin often must be searched to find'
  101.     echo 'programs which one would think would be standard.'
  102.     while :
  103.     do
  104.         echo 'Is there any other directory which should be searched'
  105.         more=`$yesno 'to find standard programs on your system' no`
  106.         case "$more" in
  107.         no)    break    ;;
  108.         esac
  109.         dir=`$ask 'What is the full name of the directory' /urk`
  110.         bef=`$yesno 'Should it go after (as opposed to before) the others' yes`
  111.         case "$bef" in
  112.         no)    newspath="$dir:$newspath"    ;;
  113.         yes)    newspath="$newspath:$dir"    ;;
  114.         esac
  115.     done
  116.     ;;
  117. esac
  118.  
  119. cat <<!
  120.  
  121. C News normally uses a umask of 022, turning off only the others-write and
  122. group-write bits in the permissions of files it creates.  (The correspondence
  123. between bits and number is:  rwx = 421, so turning off group-write bits and
  124. all others-access bits would be a mask of 027, for example.)  Usually
  125. a umask of 002 or 022 is appropriate.
  126. !
  127. newsumask=`$ask 'What umask should C News use' ${newsumask-022}`
  128. case "$newsumask" in
  129. 0*)    ;;
  130. *)    newsumask="0$newsumask"    ;;
  131. esac
  132.  
  133. echo
  134. echo 'The shell files that are everywhere in C News want to pick up their'
  135. echo 'configuration parameters (mostly, the last few questions you have'
  136. echo 'answered) from a file at a known location; this is very hard to avoid'
  137. echo 'unless you play tricks with environment variables (see documentation).'
  138. echo 'Where should the shell configuration file be'
  139. newsconfig=`$ask 'located' ${newsconfig-$newsctl/bin/config}`
  140.  
  141. cat <<!
  142.  
  143. C News wants to mail some kinds of trouble and status reports.  These are
  144. divided into urgent reports (something went badly wrong) and non-urgent
  145. reports (routine status info).  The mailing addresses for these should
  146. probably be system mailboxes, rather than those of specific people, so you
  147. won't have to change the software when you get a new administrator.
  148. !
  149. newscrisis=`$ask 'Where should C News mail urgent reports' ${newscrisis-newscrisis}`
  150. newsmaster=`$ask 'Where should C News mail non-urgent reports' ${newsmaster-newsmaster}`
  151.  
  152. cat <<!
  153.  
  154. C News has libraries for "small" address spaces (16 bits) and "big"
  155. ones (preferably 32 bits, but anything rather bigger than 16).
  156. !
  157. while :
  158. do
  159.     addrsize=`$ask 'Which best describes your system' ${addrsize-big}`
  160.     case "$addrsize" in
  161.     big|small)    break    ;;
  162.     esac
  163.     echo 'Sorry, no such library is supplied.'
  164. done
  165.  
  166. cat <<!
  167.  
  168. Systems vary in whether certain library functions and system calls
  169. are present.  C News contains reasonably-portable versions of the
  170. possibly-missing library functions, and fake versions of the
  171. possibly-missing system calls, but it needs to know which are missing.
  172. !
  173. newfake=
  174. mightfake='fcntl fgetline getopt gettimeofday memcpy mkdir putenv
  175.     remove rename strchr strerror strspn symlink'
  176. for fn in $mightfake
  177. do
  178.     has=`$notinlist "$fake" $fn.o`
  179.     tmp=`$yesno "Does your system have  $fn()" $has`
  180.     case "$tmp" in
  181.     no)    newfake="$newfake $fn.o"    ;;
  182.     esac
  183. done
  184. if test " `$notinlist "$newfake" memcpy.o`" != " yes"
  185. then
  186.     newfake="$newfake memchr.o memcmp.o memset.o"
  187. fi
  188. if test " `$notinlist "$newfake" strchr.o`" != " yes"
  189. then
  190.     newfake="$newfake strrchr.o"
  191. fi
  192. if test " `$notinlist "$newfake" strspn.o`" != " yes"
  193. then
  194.     newfake="$newfake strcspn.o strpbrk.o strtok.o"
  195. fi
  196.  
  197. cat <<!
  198.  
  199. We strongly, repeat STRONGLY, recommend that all news processing
  200. (as opposed to reading) be done on the machine that has the disks.
  201. NFS's imitation of the Unix filesystem semantics is too sloppy for
  202. reliable processing.  Keeping processing local also speeds it up,
  203. and permits C News to take some shortcuts.
  204. !
  205. tmp=`$notinlist "$fake" fsync.o`
  206. tmp=`$yesno 'Will processing be done over NFS' $tmp`
  207. case "$tmp" in
  208. no)    newfake="$newfake fsync.o"    ;;
  209. esac
  210.  
  211. cat <<!
  212.  
  213. The news software uses an indexing package to maintain an index into
  214. its history file.  Originally this was the old Version Seven "dbm".
  215. Nowadays the "dbz" package, which is specialized for news (and runs
  216. much faster, with much smaller files) is normally used.  Everything
  217. using the news database has to be compiled with the same package, as
  218. they are generally not file-compatible.
  219. !
  220. has=`$notinlist "$fake" dbz.o`
  221. tmp=`$yesno 'Do you want to use the "dbz" package' $has`
  222. case "$tmp" in
  223. no)    echo 'Presumably you want to use the dbm library or some local'
  224.     echo 'equivalent, then.  You will need to include appropriate'
  225.     echo 'filenames or compiler options when asked about libraries'
  226.     echo 'a bit later.  Be warned that support for non-dbz indexes'
  227.     echo 'is increasingly poor, and you may have to work around'
  228.     echo 'dbz-specific assumptions in the installation procedure.'
  229.     newfake="$newfake dbz.o"    # make dbm look like dbz
  230.     has=`$notinlist "$fake" dbmclose.o`
  231.     tmp=`$yesno 'Does your dbm/dbz have a dbmclose() function' $has`
  232.     case "$tmp" in
  233.     no)    newfake="$newfake dbmclose.o"    ;;
  234.     esac
  235.     echo 'Does the store() function in your dbm/dbz return a'
  236.     storeval=`$yesno 'value (some old dbms did not)' ${storeval-yes}`
  237.     case "$storeval" in
  238.     no)    echo 'You will need to modify libfake/dbz.c/dbzstore() not'
  239.         echo 'to return the nonexistent value of store().'
  240.         ;;
  241.     esac
  242.     ;;
  243. esac
  244.  
  245. fake="$newfake"
  246.  
  247. cat <<!
  248.  
  249. Some old systems have implementations of the Standard I/O library ("stdio")
  250. in which fgets, fputs, fread, and fwrite are quite slow.  We supply versions
  251. of these functions which are faster; they are compatible with most old
  252. AT&T-derived stdios.  (They tend not to work on modern systems, but modern
  253. stdio implementations are usually respectably fast.)  They can be a major
  254. performance win for C News.  There is a fairly thorough compatibility check
  255. run before a commitment is made to use our speedups; as far as we know, if
  256. the test works, the functions do.
  257. !
  258. faststdio=`$yesno 'Do you want to use our stdio speedups' ${faststdio-no}`
  259.  
  260. has=`$notinlist "$fake" strchr.o`
  261. case "$has" in
  262. yes)    echo
  263.     echo 'The strchr() function is usually slower than in-line C code'
  264.     echo 'when small strings are involved, unless your compiler is very'
  265.     echo 'clever and can generate in-line code for strchr().  Is your'
  266.     faststrchr=`$yesno 'compiler that good (okay to guess)' ${faststrchr-no}`
  267.     ;;
  268. esac
  269.  
  270. newfakehdrs=
  271. #if test " `$notinlist "$newfake" ftime.o`" != " yes"
  272. #then
  273. #    newfakehdrs="$newfakehdrs sys/timeb.h"
  274. #fi
  275. newfakehdrs="$newfakehdrs sys/timeb.h"
  276. if test " `$notinlist "$newfake" gettimeofday.o`" != " yes"
  277. then
  278.     newfakehdrs="$newfakehdrs sys/time.h"
  279. fi
  280. if test " `$notinlist "$newfake" fcntl.o`" != " yes"
  281. then
  282.     newfakehdrs="$newfakehdrs fcntl.h"
  283. fi
  284. echo
  285. echo 'Some systems have header files that others lack, and C News'
  286. echo 'is prepared to fake missing ones.'
  287. mightfakehdrs='string.h stdlib.h stddef.h'
  288. for h in $mightfakehdrs
  289. do
  290.     has=`$notinlist "$fakehdrs" $h`
  291.     tmp=`$yesno "Does your system have an ANSI-C-conforming <$h>" $has`
  292.     case "$tmp" in
  293.     no)    newfakehdrs="$newfakehdrs $h"    ;;
  294.     esac
  295. done
  296. fakehdrs="$newfakehdrs"
  297.  
  298. cat <<!
  299.  
  300. Very old Unix systems needed the order of object modules in a library
  301. chosen very carefully.  V7 introduced "ranlib" which removes the need
  302. for this.  Many modern systems have the same facility built into "ar"
  303. (look for the "symdef" or "symbol table" feature in the "ar" manual page)
  304. so ranlib is not needed.  (Caution:  some SCO systems reportedly have
  305. a ranlib, but use it only for cross-compiling, not for native programs.)
  306. C News can cope with either (if you have neither, you're in trouble).
  307. !
  308. ranlib=`$yesno 'Does your system use ranlib' ${ranlib-no}`
  309.  
  310. cat <<!
  311.  
  312. Usually "make" is named just "make", but sometimes there is more than
  313. one version on a system.
  314. !
  315. make=`$ask 'What is the name of the make to be used' ${make-make}`
  316. case "$make" in
  317. make)    ;;
  318. *)    echo "You might also have to change the 'MAKE=make' line in the"
  319.     echo "top-level makefile."
  320.     ;;
  321. esac
  322.  
  323. cat <<!
  324.  
  325. C News relies heavily on being able to put an "include" command in
  326. a makefile, so that the contents of another file is automatically
  327. inserted there when make runs.  The syntax for this varies.  The
  328. possibilities for including a file named "../include/config.make" are:
  329.  
  330.     svr4    include ../include/config.make
  331.     bsd    .include "../include/config.make"
  332.     other    something else
  333.     noway    make has no such feature
  334.  
  335. Sun systems use the svr4 syntax, as does GNU make.
  336. !
  337. while :
  338. do
  339.     include=`$ask 'Which one is appropriate' ${include-bsd}`
  340.     case "$include" in
  341.     svr4|bsd)    break    ;;
  342.     other)    echo "You will have to modify conf/makeinc appropriately"
  343.         echo "before running make."
  344.         include=svr4
  345.         break
  346.         ;;
  347.     noway)    echo "conf/maker is an imitation make that fudges this on"
  348.         echo "the fly; it may suffice.  It's not well tested yet."
  349.         break
  350.         ;;
  351.     esac
  352.     echo "*** no such choice available"
  353. done
  354.  
  355. echo
  356. echo 'Historically the C compiler is named "cc", but this is not true on'
  357. echo 'some systems, and on others there are several different C compilers.'
  358. echo '"Make" usually has a default C compiler, but you may want another.'
  359. case "$cc" in
  360. '')    tmp=no    ;;
  361. *)    tmp=yes    ;;
  362. esac
  363. tmp=`$yesno "Do you want to use a compiler other than make's default" $tmp`
  364. case "$tmp" in
  365. yes)    cc=`$ask 'What is the name of the C compiler to be used' ${cc-cc}`
  366.     ;;
  367. *)    cc=
  368.     ;;
  369. esac
  370.  
  371. echo
  372. echo 'Historically the only normal compilation option needed for most'
  373. echo 'programs is -O, but again compilers, especially newer ones, differ.'
  374. echo '(NOTE:  many 386/486 compilers miscompile dbz if -O is used!)'
  375. copts="`$ask 'What options should be given to the compiler' \"${copts--O}\"`"
  376.  
  377. echo
  378. echo 'The final linking ("ld") step of compiling might need an option,'
  379. echo 'such as -n or -i, to produce the preferred form of executable file.'
  380. echo 'On most modern systems the default is right.  What options, if any,'
  381. ldopts="`$ask 'should be given for linking' \"${ldopts-}\"`"
  382.  
  383. echo
  384. echo 'On unusual systems it may be necessary to link C News programs with'
  385. echo 'libraries other than the usual C library.  These can be specified as'
  386. echo 'either full pathnames or -l... options.  What libraries, in addition'
  387. echo 'to the one(s) picked up automatically by the compiler, should be used'
  388. postlibs="`$ask 'when linking C News' \"${postlibs-}\"`"
  389.  
  390. echo
  391. echo 'C News tries to limit the backlog of news batches spooled up for'
  392. echo 'transmission to a site, to control use of disk space.  To do this,'
  393. echo 'it needs to be able to determine the length of the queue of news'
  394. echo 'batches for a particular site.  This is UUCP-version-dependent.'
  395. echo 'There is a good chance that you will have to customize the "queuelen"'
  396. echo 'program.  C News knows about several versions:'
  397. echo '    svr4    System V Release 4 uucp'
  398. echo '    hdb    pre-SVR4 Honey DanBer, aka Basic Networking Utilities'
  399. echo '    tay    Taylor UUCP, native mode'
  400. echo '    sub    old uucp with subdirectories (e.g. /usr/spool/uucp/C.)'
  401. echo '    vo    very old uucp, no subdirectories'
  402. echo '    pre    prehistoric uucp, no subdirectories, no -g option on uux'
  403. echo "    null    don't run uucp or don't care about queue lengths"
  404. while :
  405. do
  406.     uucptype=`$ask 'Which one is most appropriate' ${uucptype-hdb}`
  407.     case "$uucptype" in
  408.     svr4|hdb|tay|sub|vo|pre|null)    break    ;;
  409.     esac
  410.     echo 'Sorry, no such choice is available.'
  411. done
  412.  
  413. echo
  414. echo 'C News often wants to ask how much disk space is available.  The'
  415. echo 'format of output from the "df" command unfortunately varies a lot,'
  416. echo 'as does the availability of a system call to get the same information.'
  417. echo 'C News knows about several different versions (the first four are'
  418. echo 'preferred):'
  419. echo '    statfs    system with standard statfs() (4.4BSD, some System Vs)'
  420. echo "    ultrix    DEC Ultrix with DEC's own bizarre statfs()"
  421. echo '    statvfs    system with statvfs() (many modern System Vs)'
  422. echo '    ustat    system with ustat() (most System Vs)'
  423. echo '    bsd    4.2/4.3BSD'
  424. echo '    sysv    old System Vs'
  425. echo '    xenix    some (all?) Xenixes; some System Vs, e.g. Microport, HP?'
  426. echo '    sgi    Silicon Graphics Iris systems'
  427. echo '    v7    plain old style:  no headers or fluff, just name and number'
  428. echo "    null    don't know or don't care how much space is available"
  429. while :
  430. do
  431.     dftype=`$ask 'Which one is most appropriate' ${dftype-statfs}`
  432.     case "$dftype" in
  433.     sysv|xenix)
  434.         echo 'Beware -- test "spacefor" to make sure it works.'
  435.         echo 'System V "df" formats vary widely, indeed wildly.'
  436.         echo '"Consider it standard".  Sure.'
  437.         ;;
  438.     ustat)    echo 'The block size defined in util/doustat.c (512) may be'
  439.         echo 'too conservative, as many modern System V filesystems'
  440.         echo 'use a 1024-byte block.  There is no way to determine'
  441.         echo 'this automatically and portably.'
  442.         ;;
  443.     esac
  444.     case "$dftype" in
  445.     ustat|statfs|statvfs|ultrix|null)    askdf=no    ;;
  446.     bsd|sysv|sgi|xenix|v7)    askdf=yes            ;;
  447.     esac
  448.     case "$dftype" in
  449.     ustat|statfs|statvfs|ultrix)    sftype=c ; break    ;;
  450.     bsd|sysv|sgi|xenix|v7|null)    sftype=sh ; break    ;;
  451.     esac
  452.     echo 'Sorry, no such choice is available.'
  453. done
  454.  
  455. case "$askdf" in
  456. yes)    echo
  457.     echo 'Some "df" commands, especially on old systems, must be given'
  458.     echo 'the name of a device.  Modern ones can be given any directory'
  459.     echo 'name and the system handles the details of figuring out what'
  460.     echo 'device is meant.  A few will take a directory only if it is'
  461.     echo 'the "top" of a filesystem.  Will "df" accept any directory'
  462.     dfdirs=`$yesno 'name as an argument' ${dfdirs-yes}`
  463.     case "$dfdirs" in
  464.     no)    echo 'You are going to have to customize "spacefor" for your'
  465.         echo 'system.  It will be generated assuming that directory'
  466.         echo 'names do work.'
  467.         ;;
  468.     esac
  469.     ;;
  470. esac
  471.  
  472. echo
  473. archive=`$yesno 'Are you planning to use expire to archive news on disk' ${archive-no}`
  474. case "$archive" in
  475. yes)    echo 'You probably want to customize the "archive" entry in'
  476.     echo '"spacefor" so it knows where your archiving is done and how'
  477.     echo 'much space you want free there.'
  478.     ;;
  479. esac
  480.  
  481. echo
  482. spacelow=`$yesno 'Are you particularly short of disk space' ${spacelow-no}`
  483. case "$spacelow" in
  484. yes)    echo 'You may want to reconsider whether you really want to get'
  485.     echo 'news, unless you are getting only a very small set of groups.'
  486.     echo 'In any case, you definitely want to inspect "spacefor" and'
  487.     echo 'change some of its thresholds for free space.  BE WARNED'
  488.     echo 'that C News is not built to run on a brim-full file system;'
  489.     echo 'it relies on simple, rough space checks on the assumption that'
  490.     echo 'there is a substantial cushion of free space.'
  491.     ;;
  492. no)    echo 'You may want to inspect "spacefor" to make sure its defaults'
  493.     echo 'for things like desired free space are appropriate for your'
  494.     echo 'system, although the defaults are fairly conservative.'
  495.     ;;
  496. esac
  497.  
  498. echo
  499. echo 'Are you running C News on a group of machines hooked together with NFS,'
  500. echo 'run essentially as a single system with a single administration,'
  501. nfsgroup=`$yesno 'with articles filed on one "server" machine' ${nfsgroup-no}`
  502. case "$nfsgroup" in
  503. yes)
  504.     echo
  505.     hostname=`$yesno 'Does your system have a "hostname" command' ${hostname-yes}`
  506.     case "$hostname" in
  507.     no)    echo 'With a server but no "hostname" command, you will have'
  508.         echo 'problems and will probably have to tinker by hand to'
  509.         echo 'get a fake "hostname" that does the right thing.  The'
  510.         echo 'generated files will assume you have "hostname".'
  511.         hostname=yes
  512.         ;;
  513.     esac
  514.     server=`$ask "What is the \"hostname\" name of the server" ${server-newsie}`
  515.     ;;
  516. *)    server=newsie    ;;
  517. esac
  518.  
  519. echo
  520. echo 'The "rnews" and "cunbatch" commands (which are identical, the latter'
  521. echo 'being purely for backward compatibility with seriously-old systems)'
  522. echo 'have to be installed somewhere where uucp can find them to execute'
  523. echo 'them.  It is not normally necessary for users to be able to run'
  524. echo 'them, so they need not go in the directories searched for normal'
  525. echo 'commands... although uucp often searches only those directories.'
  526. rbin=`$ask 'Where should "rnews" and "cunbatch" be put' ${rbin-$newsbin/input}`
  527.  
  528. echo
  529. echo "The inews command, and also readnews+postnews+checknews if you're"
  530. echo 'going to use them, should go in one of the directories searched for'
  531. echo 'normal commands, so users can run them without special arrangements.'
  532. bin=`$ask 'What directory should these commands go in' ${bin-/usr/bin}`
  533.  
  534. echo
  535. echo 'saving defaults...'
  536. rm -f $memory
  537. >$memory
  538. warn='# These answers are interdependent; do not edit this file!'
  539. if test ! -w $memory
  540. then
  541.     echo 'It appears that I cannot save the defaults.'
  542. else
  543.     (
  544.         for v in $vars
  545.         do
  546.             echo "$warn"
  547.             # even this horror botches metachars in var
  548.             eval "echo $v=\\\"\"\$$v\"\\\""
  549.         done
  550.     ) >>$memory
  551. fi
  552. chmod -w $memory
  553.  
  554. echo
  555. conf/useanswers -v $memory conf/makeinc conf/substitutions include/config.make
  556.  
  557. echo done
  558.