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