home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / N / NN / _NN-SPOO.TAR / usr / lib / nn / inst < prev    next >
Encoding:
Text File  |  1994-09-13  |  9.7 KB  |  561 lines

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