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