home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume22 / nn6.4 / part18 / inst.sh next >
Encoding:
Text File  |  1990-06-07  |  7.4 KB  |  436 lines

  1.  
  2. # (Large) prefix inserted above by Make
  3.  
  4. # BSD systems keep chown in /etc
  5. PATH="$PATH:/etc"
  6.  
  7. case "$1" in
  8. mkdir)
  9.     if [ -n "$2" -a ! -d "$2"/. ]
  10.     then
  11.         mkdir $2
  12.         if [ ! -d "$2" ] ; then
  13.             echo "Cannot create directory $2"
  14.             exit 1
  15.         fi
  16.         chmod $3 $2
  17.         chgrp $GROUP $2
  18.         chown $OWNER $2
  19.         echo Created directory $2
  20.     fi
  21.     exit 0
  22.     ;;
  23. copy)
  24.     cp $4 $3
  25.     chmod $2 $3/$4
  26.     chgrp $GROUP $3/$4
  27.     chown $OWNER $3/$4
  28.     echo "$4 -> $3/$4"
  29.     exit 0
  30.     ;;
  31. chmod)
  32.     chmod $2 $3
  33.     chgrp $GROUP $3
  34.     chown $OWNER $3
  35.     exit 0
  36.     ;;
  37.  
  38. inews)
  39.     if [ ! -d "${INEWS_DIR}"/. ]
  40.     then
  41.         ../inst mkdir ${INEWS_DIR} 755 || exit 1
  42.     fi
  43.     echo Installing $2 in $INEWS
  44.     cp $2 $INEWS && ../inst chmod 755 $INEWS
  45.     exit 0
  46.     ;;
  47. esac
  48.  
  49. set -u
  50.  
  51. (
  52. if $NNTP
  53. then
  54.     :
  55. else
  56.     if [ ! -d "$SPOOL"/. ]
  57.     then
  58.         echo Error: News spool directory $SPOOL not found.
  59.     fi
  60.  
  61.     if [ ! -d "$NLIB"/. ]
  62.     then
  63.         echo Error: News lib directory $NLIB not found.
  64.     fi
  65. fi
  66.  
  67. set $INEWS
  68. if [ ! -f "$1" ]
  69. then
  70.     echo ERROR: Inews program $INEWS not found.
  71. fi
  72.  
  73. set $RECMAIL
  74. if [ ! -f "$1" ]
  75. then
  76.     echo ERROR: Mailer program $RECMAIL not found.
  77. fi
  78. ) > ErrorCheck
  79.  
  80. if [ -s ErrorCheck ]
  81. then
  82.     cat ErrorCheck
  83.     echo "Hit return to continue"
  84.     read X
  85. fi
  86. rm -f ErrorCheck
  87.  
  88. LOOP=true
  89. while $LOOP
  90. do
  91.  
  92. if [ $# -ge 1 ]
  93. then
  94.     OPT="$1"
  95.     shift
  96.     if [ $# -eq 0 ]
  97.     then
  98.         LOOP=false
  99.     fi
  100.     PAUSE=false
  101. else
  102.     PAUSE=true
  103.  
  104. echo
  105. echo
  106. echo "INSTALLATION"
  107. echo ""
  108. echo "1) Master programs (machine dependent)"
  109. echo "2) User programs (machince dependent, shareable)"
  110. echo "3) Help files and auxiliary programs (shareable)"
  111. echo "4) Documentation (shareable)"
  112. echo "5) Online manual (shareable with 3)"
  113. echo ""
  114. echo "INIT) Initialize database"
  115. echo ""
  116. echo "s) Server installation:  1 + 2 + 3 + 4 + 5"
  117. echo "n) Network installation:     2 + 3 + 4 + 5"
  118. echo "m) Master installation:  1"
  119. echo "c) Client installation:      2"
  120. echo "u) Update after patch"
  121. echo "q) Quit"
  122. echo ""
  123. if ./usercheck 0 ; then
  124.     :
  125. else
  126.   echo "Warning: not running as super user"
  127.   echo ""
  128. fi
  129. ${AWK} 'BEGIN{printf "Select option: "}' < /dev/null
  130. read OPT
  131. echo
  132.  
  133. fi
  134.  
  135. case $OPT in
  136.  
  137. s*|a*)
  138.     OPT="master bin aux help online man"
  139.     ;;
  140. u*)
  141.     OPT=""
  142.     if [ -f "$MASTER/nnmaster" ]
  143.     then
  144.         OPT="$OPT master"
  145.     fi
  146.     if [ -f "$BIN/nn" ]
  147.     then
  148.         OPT="$OPT bin"
  149.     fi
  150.     if [ -f "$LIB/aux" ]
  151.     then
  152.         OPT="$OPT aux help"
  153.     fi
  154.     if [ -f "$DMAN_DIR/nnmaster.$DMAN_SECT" ]
  155.     then
  156.         OPT="$OPT man"
  157.     fi
  158.     if [ -f "$HELP/Manual" ]
  159.     then
  160.         OPT="$OPT online"
  161.     fi
  162.     ;;
  163. 1|m)
  164.     OPT=master
  165.     ;;
  166. n)
  167.     OPT="bin aux help online man"
  168.     ;;
  169. 2|c)
  170.     OPT=bin
  171.     ;;
  172. 3)
  173.     OPT="aux help"
  174.     ;;
  175. x)
  176.     OPT=aux
  177.     ;;
  178. h)
  179.     OPT=help
  180.     ;;
  181. 4)
  182.     OPT="man"
  183.     ;;
  184. 5)
  185.     OPT="online"
  186.     ;;
  187. INIT)
  188.     OPT=init
  189.     ;;
  190. q*|"")
  191.     if [ -f $MASTER/nnmaster -a ! -f $MASTER/MPID ]
  192.     then
  193.         echo "Remember to restart $MASTER/nnmaster"
  194.     fi
  195.     exit 0
  196.     ;;
  197. *)
  198.     echo "Unrecognized option: $OPT"
  199.     exit 1
  200.     ;;
  201. esac
  202.  
  203. for OP in $OPT
  204. do
  205. case "$OP" in
  206.  
  207. master)
  208.     ./inst mkdir $MASTER 755 || exit 1
  209.  
  210.     if [ -f $MASTER/nnmaster ]
  211.     then
  212.         (
  213.         cd $MASTER
  214.         if [ -f MPID ]
  215.         then
  216.             echo "Stopping running master..."
  217.             kill -1 `cat MPID`
  218.             sleep 5
  219.             rm -f MPID
  220.         fi
  221.         mv nnmaster nnmaster.old
  222.        )
  223.     fi
  224.  
  225.     echo Installing master in $MASTER
  226.  
  227.     for prog in $MASTER_PROG
  228.     do
  229.         ./inst copy 755 $MASTER $prog
  230.     done
  231.  
  232.     chmod 4750 $MASTER/nnmaster
  233.     ;;
  234.  
  235. bin)
  236.     echo
  237.     if [ ! -d "$BIN"/. ]
  238.     then
  239.         echo Directory $BIN does not found!
  240.         exit 1
  241.     fi
  242.  
  243.     echo Installing user programs in $BIN
  244.  
  245.     if [ -f $BIN/nn ]
  246.     then
  247.          (
  248.         cd $BIN
  249.         mv nn nn.old
  250.         rm -f $BIN_PROG $BIN_LINK
  251.          )
  252.     fi
  253.  
  254.     for prog in $BIN_PROG
  255.     do
  256.         ./inst copy 755 $BIN $prog
  257.     done
  258.  
  259.     for link in $BIN_LINK
  260.     do
  261.         ln $BIN/nn $BIN/$link
  262.         echo $link linked to nn
  263.     done
  264.  
  265.     if [ -f $BIN/nnacct ] ; then
  266.         chmod 4755 $BIN/nnacct
  267.         echo nnacct is setuid ${OWNER}.
  268.     fi
  269.     ;;
  270.  
  271. aux)
  272.     echo
  273.     ./inst mkdir $LIB 755 || exit 1
  274.  
  275.     echo Installing auxiliary programs in $LIB
  276.  
  277.     for prog in $LIB_PROG
  278.     do
  279.         ./inst copy 755 $LIB $prog
  280.     done
  281.  
  282.     ./mkprefix conf > ${LIB}/conf
  283.     grep "^#" config.h |
  284.     sed -e '/_MAN_/d' -e 's/[     ]*\/\*.*$//' >> ${LIB}/conf
  285.     ./inst chmod 644 ${LIB}/conf
  286.     ;;
  287.  
  288. help)
  289.     ./inst mkdir $HELP 755 || exit 1
  290.  
  291.     echo
  292.     echo Installing help files in $HELP
  293.  
  294.     for h in `grep '^help/' MANIFEST | sed 's/^help\/\([a-z0-9.]*\).*$/\1/'`
  295.     do
  296.         ./cvt-help < help/$h > $HELP/$h
  297.         ./inst chmod 644 $HELP/$h
  298.         echo $h
  299.     done
  300.     ;;
  301.  
  302. man)
  303.     echo
  304.     echo Installing manuals
  305.  
  306.     {
  307.         echo $UMAN_DIR $UMAN_SECT .1
  308.         echo $SMAN_DIR $SMAN_SECT .1m
  309.         echo $DMAN_DIR $DMAN_SECT .8
  310.     } |
  311.     while read DIR SECT SRC
  312.     do
  313.  
  314.         if [ -d "$DIR"/. -a -w "$DIR"/. ]
  315.         then
  316.             for i in man/*$SRC
  317.             do
  318.                 MAN=`basename ${i} $SRC`
  319.                 NEW=$DIR/${MAN}.$SECT
  320.                 cp $i $NEW
  321.                 ./inst chmod 644 $NEW
  322.                 echo $MAN in $NEW
  323.             done
  324.         else
  325.             echo $DIR not found or not writeable
  326.         fi
  327.     done
  328.     ;;
  329.  
  330. online)
  331.     ./inst mkdir $HELP 755 || exit 1
  332.  
  333.     MAN=$HELP/Manual
  334.  
  335.     echo
  336.     echo "Formatting online manual $MAN"
  337.     echo ".... (continues in background) ...."
  338.  
  339.     rm -f $MAN
  340.  
  341.     (
  342.     sed     -e 's/\\f[BPI]//g' \
  343.         -e 's/\\-/-/g' -e 's/\\&//g' -e 's/\\e/\\/g' \
  344.         -e '/^\.\\"ta/p' -e '/^\.\\"/d' \
  345.         -e '/^\.nf/d' -e '/^\.fi/d' \
  346.         -e '/^\.if/d' -e '/^\.ta/d' -e '/^\.nr/d' \
  347.         -e '/^\.in/d' -e 's/^\.[BI] //' \
  348.         `grep '^man/' MANIFEST | ${AWK} '{print $1}'` |
  349.     ${AWK} -f format.awk - > $MAN
  350.  
  351.     ./inst chmod 644 $MAN
  352.     ) &
  353.     ;;
  354.  
  355. init)
  356.     echo
  357.     ./inst mkdir "$DB" 755 || exit 1
  358.     ./inst mkdir "$DBDATA" 755 || exit 1
  359.  
  360.     if $NNTP ; then
  361.         if [ x"$NNTPCACHE" != "x" ] ; then
  362.             ./inst mkdir "$NNTPCACHE" 777 || exit 1
  363.         fi    
  364.         ILIMIT=50
  365.         DFLT=50
  366.  
  367.         cat <<'EOF'
  368.     
  369. When nnmaster is started the first time after initializing nn's
  370. database, it will attempt to fetch all the articles from the nntp
  371. server.  It does this by successively requesting each article in the
  372. range min..last obtained from the NNTP server.  Often the 'min' number
  373. is unreliable or even zero (Cnews doesn't maintain it).  This means
  374. that the nnmaster will request a lot of non-existing articles from the
  375. server, causing a lot of network traffic.
  376.  
  377. To limit this activity, nn will normally only attempt to fetch the
  378. fifty newest articles in each group.  This shouldn't really be a
  379. problem since that will give you enough news to start with, and the
  380. older articles will probably be expired in a few days anyway.
  381.  
  382. You can change this limit if you like.  Or you can disable this
  383. limitation completely if you trust the min field by giving a 0 limit.
  384.  
  385. EOF
  386.     else
  387.         ILIMIT=""
  388.         DFLT="none"
  389.  
  390.         cat <<'EOF'
  391.  
  392. If the 'min' field in your active file is not reliable, nnmaster can
  393. waste a lot of time trying to locate non-existing articles in the news
  394. groups when it is collecting the available articles the first time it
  395. is started after the database is initialized.  This is especially true
  396. with Cnews where the min field is not normally maintained.
  397.  
  398. To limit the efforts during the initial collection, you can set a
  399. limit on the number of articles in each group which nnmaster should
  400. try to locate in each group.  This may get you running faster, and it
  401. shouldn't matter much anyway since the articles that may be ignored
  402. will be the oldest articles in the group, and they will probably be
  403. expired soon anyway.  A value in the range 100-500 should be more than
  404. enough.  If you don't specify a limit, all articles will be collected,
  405. but it may take quite some time if the min fields are unreliable.
  406. EOF
  407.     fi
  408.  
  409.     ${AWK} 'END{printf "Initial article limit ('"$DFLT"') "}' < /dev/null
  410.     read L
  411.     if [ -n "$L" ] ; then
  412.         ILIMIT="$L"
  413.     fi
  414.  
  415.     echo Running nnmaster -I $ILIMIT to initialize database....
  416.     echo
  417.     $MASTER/nnmaster -I $ILIMIT
  418.     echo
  419.     echo "Now start $MASTER/nnmaster [ -D ] [ -r ]"
  420.     ;;
  421. esac
  422.  
  423. done
  424.  
  425. if [ -f $LOG ]
  426. then
  427.     chmod 666 $LOG
  428. fi
  429.  
  430. if $PAUSE
  431. then
  432. ${AWK} 'BEGIN{printf("\nHit return to continue....")}' < /dev/null
  433. read X
  434. fi
  435. done
  436.