home *** CD-ROM | disk | FTP | other *** search
/ chilidog.highland.cc.ks.us / chilidog.highland.cc.ks.us.zip / chilidog.highland.cc.ks.us / backup / bradford.20101108.etc.tar.gz / bradford.20101108.etc.tar / etc / init.d / portmap < prev    next >
Text File  |  2006-04-22  |  4KB  |  131 lines

  1. #! /bin/sh
  2. # Copyright (c) 2000, 2001 SuSE GmbH Nuernberg, Germany.  All rights reserved.
  3. #
  4. # Author: Thorsten Kukuk <kukuk@suse.de>
  5. #
  6. # /etc/init.d/portmap
  7. #
  8. #   and symbolic its link
  9. #
  10. # /sbin/rcportmap
  11. #
  12. # System startup script for the RPC program number mapper
  13. #
  14. ### BEGIN INIT INFO
  15. # Provides: portmap
  16. # Required-Start: $network $syslog
  17. # Required-Stop: $network $syslog
  18. # Default-Start: 3 5
  19. # Default-Stop: 0 1 2 4 6
  20. # Description: DARPA port to RPC program number mapper
  21. ### END INIT INFO
  22.  
  23. PORTMAP_BIN=/sbin/portmap
  24. test -x $PORTMAP_BIN || exit 5
  25.  
  26. # Shell functions sourced from /etc/rc.status:
  27. #      rc_check         check and set local and overall rc status
  28. #      rc_status        check and set local and overall rc status
  29. #      rc_status -v     ditto but be verbose in local rc status
  30. #      rc_status -v -r  ditto and clear the local rc status
  31. #      rc_failed        set local and overall rc status to failed
  32. #      rc_reset         clear local rc status (overall remains)
  33. #      rc_exit          exit appropriate to overall rc status
  34. . /etc/rc.status
  35.  
  36. # First reset status of this service
  37. rc_reset
  38.  
  39. # Return values acc. to LSB for all commands but status:
  40. # 0 - success
  41. # 1 - misc error
  42. # 2 - invalid or excess args
  43. # 3 - unimplemented feature (e.g. reload)
  44. # 4 - insufficient privilege
  45. # 5 - program not installed
  46. # 6 - program not configured
  47. # 7 - program is not running
  48. #
  49. # Note that starting an already running service, stopping
  50. # or restarting a not-running service as well as the restart
  51. # with force-reload (in case signalling is not supported) are
  52. # considered a success.
  53.  
  54. case "$1" in
  55.     start)
  56.     echo -n "Starting RPC portmap daemon"
  57.     startproc $PORTMAP_BIN
  58.         rc_status -v
  59.     ;;
  60.     stop)
  61.     echo -n "Shutting down RPC portmap daemon"
  62.     killproc -TERM $PORTMAP_BIN
  63.     rc_status -v
  64.     ;;
  65.     try-restart)
  66.         ## Do a restart only if the service was active before.
  67.         $0 status >/dev/null && $0 restart
  68.  
  69.         # Remember status and be quiet
  70.         rc_status
  71.         ;;
  72.     restart)
  73.         ## Stop the service and regardless of whether it was
  74.         ## running or not, start it again.
  75.         pmap_dump > /var/run/portmap.state
  76.         $0 stop
  77.         $0 start
  78.     pmap_set < /var/run/portmap.state
  79.     rm -f /var/run/portmap.state
  80.  
  81.         # Remember status and be quiet
  82.         rc_status
  83.         ;;
  84.     force-reload)
  85.         ## Signal the daemon to reload its config. Most daemons
  86.         ## do this on signal 1 (SIGHUP).
  87.         ## If it does not support it, restart.
  88.  
  89.         echo -n "Reload RPC portmap daemon"
  90.         ## if it supports it:
  91.         #killproc -HUP $PORTMAP_BIN
  92.         #rc_status -v
  93.  
  94.         ## Otherwise:
  95.         pmap_dump > /var/run/portmap.state
  96.         $0 stop
  97.         $0 start
  98.     pmap_set < /var/run/portmap.state
  99.     rm -f /var/run/portmap.state
  100.  
  101.         # Remember status and be quiet
  102.         rc_status
  103.         ;;
  104.     reload)
  105.     # portmap does not support SIGHUP signaling
  106.         echo -n "Reload RPC portmap daemon"
  107.     rc_failed 3
  108.         rc_status -v
  109.         ;;
  110.     status)
  111.         echo -n "Checking for RPC portmap daemon: "
  112.         ## Check status with checkproc(8), if process is running
  113.         ## checkproc will return with exit status 0.
  114.  
  115.         # Status has a slightly different for the status command:
  116.         # 0 - service running
  117.         # 1 - service dead, but /var/run/  pid  file exists
  118.         # 2 - service dead, but /var/lock/ lock file exists
  119.         # 3 - service not running
  120.  
  121.         checkproc $PORTMAP_BIN
  122.         rc_status -v
  123.         ;;
  124.     *)
  125.     echo "Usage: $0 {start|stop|restart|force-reload|reload|status}"
  126.     exit 1
  127.     ;;
  128. esac
  129. rc_exit
  130.  
  131.