home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 98 / Skunkware 98.iso / osr5 / sco / scripts / admin / news / nntp < prev    next >
Encoding:
Korn shell script  |  1997-08-26  |  1.3 KB  |  54 lines

  1. #!/bin/ksh
  2. # @(#) nntp.ksh 1.1 96/06/17
  3. # 94/12/18 john h. dubois iii (john@armory.com)
  4. # 95/01/22 Also print nntp processes when no args given
  5. # 96/06/17 Added help.
  6.  
  7. Name=${0##*/}
  8.  
  9. StatusFile=/etc/nntp.shut
  10. Usage="Usage: $Name [-h|on|off]"
  11.  
  12. function nntpprocs {
  13.     typeset out
  14.  
  15.     out=$(ps -fu news|grep nntpd)
  16.     [ -n "$out" ] && print "nntpd processes running:\n$out"
  17. }
  18.  
  19. case "$1" in
  20. "")
  21.     print -n "nntp service is "
  22.     [ -f $StatusFile ] && print off || print on
  23.     nntpprocs
  24.     ;;
  25. -h)
  26.     print \
  27. "$Name: turn NNTP service on or off.
  28. $Usage
  29. $Name turns NNTP service on or off by creating or removing a status file
  30. read by nntpd, $StatusFile.  If $StatusFile exists, nntpd returns an NNTP
  31. status message indicating that the news server is shut down (note, this
  32. requires a modified nntpd or a front end for nntpd).
  33. Options:
  34. on:  Turn on NNTP service by removing the status file.
  35. off: Turn off NNTP service and report how many NNTP connections are currently
  36.      active.  These nntpd processes are not killed.
  37. If $Name is invoked without arguments, it tells whether NNTP service is on or
  38. off."
  39.     ;;
  40. on)
  41.     [ ! -f $StatusFile ] && print -u2 "$Name: nntp was already on." ||
  42.     rm $StatusFile
  43.     ;;
  44. off)
  45.     [ -f $StatusFile ] && print -u2 "$Name: nntp was already off." ||
  46.     > $StatusFile
  47.     nntpprocs
  48.     ;;
  49. *)
  50.     print -u2 "$Usage"
  51.     exit 1
  52.     ;;
  53. esac
  54.