home *** CD-ROM | disk | FTP | other *** search
/ Unix System Administration Handbook 1997 October / usah_oct97.iso / news / cnews.tar / maint / newsflag < prev    next >
Text File  |  1994-08-17  |  740b  |  39 lines

  1. #! /bin/sh
  2. # newsflag - change the flag (4th field of active) for a newsgroup
  3.  
  4. # =()<. ${NEWSCONFIG-@<NEWSCONFIG>@}>()=
  5. . ${NEWSCONFIG-/etc/news/bin/config}
  6.  
  7. PATH=$NEWSCTL/bin:$NEWSBIN/maint:$NEWSBIN:$NEWSPATH ; export PATH
  8. umask $NEWSUMASK
  9.  
  10. usage="Usage: $0 groupname {y|n|m|x|=realgroup}"
  11.  
  12. case $# in
  13. 2)    ;;
  14. *)    echo "$usage" >&2 ; exit 2    ;;
  15. esac
  16.  
  17. cd $NEWSCTL
  18.  
  19. lock -v LOCK $$ 5 || exit 1
  20. status=1
  21. trap "unlock LOCK ; trap 0 ; exit \$status" 0 1 2 15
  22.  
  23. if awk 'BEGIN { found = 0 }
  24.     $1 == "'"$1"'" { $4 = "'"$2"'" ; found = 1 }
  25.     { print }
  26.     END {
  27.         if (found == 1)
  28.             exit 0
  29.         else
  30.             exit 1
  31.     }' active >active.new
  32. then
  33.     mv active active.old && mv active.new active
  34.     status=0
  35. else
  36.     echo "$0: cannot find newsgroup \`$1'" >&2
  37.     rm active.new
  38. fi
  39.