home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / N / CNEWS / _CNEWS.TAR / usr / lib / newsbin / expire / doexpire next >
Encoding:
Text File  |  1994-09-02  |  1.7 KB  |  81 lines

  1. #! /bin/sh
  2. # doexpire - overall administration for expire
  3.  
  4. # =()<. ${NEWSCONFIG-@<NEWSCONFIG>@}>()=
  5. . ${NEWSCONFIG-/var/lib/news/bin/config}
  6.  
  7. PATH=$NEWSCTL/bin:$NEWSBIN/expire:$NEWSBIN:$NEWSPATH ; export PATH
  8. umask $NEWSUMASK
  9.  
  10. lock="$NEWSCTL/LOCKexpire"
  11. ltemp="$NEWSCTL/L.$$"
  12. echo $$ >$ltemp
  13. trap "rm -f $ltemp ; exit 0" 0 1 2 15
  14. if newslock $ltemp $lock
  15. then
  16.     trap "rm -f $ltemp $lock ; exit 0" 0 1 2 15
  17. else
  18.     echo "$0: expire apparently already running" | mail "$NEWSMASTER"
  19.     exit 1
  20. fi
  21.  
  22. hopt=
  23. if test " `spacefor 1 archive`" -le 0
  24. then
  25.     (
  26.         echo "$0:"
  27.         echo "    Space shortage in archiving area!"
  28.         echo "    Unable to archive old articles -- holding them in"
  29.         echo "    current directories using \`expire -h'.  If shortage"
  30.         echo "    persists, human action is urgently needed."
  31.     ) | mail "$NEWSMASTER"
  32.     hopt=-h
  33. fi
  34.  
  35. cd $NEWSCTL
  36. forcer=no
  37. for o
  38. do
  39.     if test " $o" = " -r"
  40.     then
  41.         forcer=yes
  42.         ropt=
  43.     fi
  44. done
  45. case "$forcer" in
  46. no)    ropt=-r
  47.     for counter in x x x x        # four tries
  48.     do
  49.         rm -f history.o        # it's about to vanish anyway
  50.         size="`sizeof history history.pag history.dir`"
  51.         if test " `spacefor $size control`" -gt 0
  52.         then
  53.             ropt=
  54.             break
  55.         fi
  56.         sleep 600        # and hope it will improve
  57.     done
  58.     if test " $ropt" = " -r"
  59.     then
  60.         (
  61.             echo "$0:"
  62.             echo "    SEVERE SPACE SHORTAGE in $NEWSCTL !"
  63.             echo "    Unable to rebuild history files due to insufficient"
  64.             echo "    space for temporaries -- resorting to \`expire -r'."
  65.             echo "    Growth of the history files will make things worse;"
  66.             echo "    if shortage persists, human action is urgently needed."
  67.         ) | mail "$NEWSMASTER"
  68.     fi
  69.     ;;
  70. esac
  71.  
  72. expire $ropt $hopt $* $NEWSCTL/explist 2>/tmp/doex$$
  73. if test -s /tmp/doex$$
  74. then
  75.     (echo 'expire problems:' ; cat /tmp/doex$$ ) | mail "$NEWSMASTER"
  76.     rm -f /tmp/doex$$
  77.     exit 1
  78. fi
  79. rm -f /tmp/doex$$
  80. exit 0
  81.