home *** CD-ROM | disk | FTP | other *** search
/ tusportal.tus.k12.pa.us / tusportal.tus.k12.pa.us.tar / tusportal.tus.k12.pa.us / Wyse / latest-image.raw / 0.img / etc / init.d / atd < prev    next >
Text File  |  2010-05-08  |  4KB  |  150 lines

  1. #! /bin/sh
  2. # Copyright (c) 1995-2002 SuSE GmbH Nuernberg, Germany.
  3. #
  4. # Author: Kurt Garloff <feedback@suse.de>
  5. #
  6. # /etc/init.d/at
  7. #
  8. #   and symbolic its link
  9. #
  10. # /sbin/rcat
  11. #
  12. # System startup script for the at daemon
  13. #
  14. ### BEGIN INIT INFO
  15. # Provides: at
  16. # Required-Start: $remote_fs $time
  17. # Required-Stop:  $remote_fs
  18. # X-UnitedLinux-Default-Enabled: no
  19. # Default-Start:  2 3 5
  20. # Default-Stop:   0 1 6
  21. # Description:    Start AT batch job daemon
  22. ### END INIT INFO
  23.  
  24. ATD_BIN=/usr/sbin/atd
  25. test -x $ATD_BIN || exit 5
  26.  
  27. ATD_CONFIG=/etc/sysconfig/atd
  28. test -r $ATD_CONFIG && source /etc/sysconfig/atd
  29.  
  30. # Shell functions sourced from /etc/rc.status:
  31. #      rc_check         check and set local and overall rc status
  32. #      rc_status        check and set local and overall rc status
  33. #      rc_status -v     ditto but be verbose in local rc status
  34. #      rc_status -v -r  ditto and clear the local rc status
  35. #      rc_failed        set local and overall rc status to failed
  36. #      rc_failed <num>  set local and overall rc status to <num><num>
  37. #      rc_reset         clear local rc status (overall remains)
  38. #      rc_exit          exit appropriate to overall rc status
  39. . /etc/rc.status
  40.  
  41. # First reset status of this service
  42. rc_reset
  43.  
  44. # Return values acc. to LSB for all commands but status:
  45. # 0 - success
  46. # 1 - generic or unspecified error
  47. # 2 - invalid or excess argument(s)
  48. # 3 - unimplemented feature (e.g. "reload")
  49. # 4 - insufficient privilege
  50. # 5 - program is not installed
  51. # 6 - program is not configured
  52. # 7 - program is not running
  53. # Note that starting an already running service, stopping
  54. # or restarting a not-running service as well as the restart
  55. # with force-reload (in case signalling is not supported) are
  56. # considered a success.
  57.  
  58. case "$1" in
  59.     start)
  60.     echo -n "Starting service at daemon"
  61.     ATD_ARGS=""
  62.     if [ -n "$ATD_BATCH_INTERVAL" ]; then 
  63.         ATD_ARGS="-b $ATD_BATCH_INTERVAL";
  64.     fi
  65.     if [ -n "$ATD_LOADAVG" ]; then 
  66.         ATD_ARGS="$ATD_ARGS -l $ATD_LOADAVG"
  67.     fi
  68.     ## Start daemon with startproc(8). If this fails
  69.     ## the echo return value is set appropriate.
  70.  
  71.     # NOTE: startproc return 0, even if service is 
  72.     # already running to match LSB spec.
  73.     startproc $ATD_BIN $ATD_ARGS
  74.  
  75.     # Remember status and be verbose
  76.     rc_status -v
  77.     ;;
  78.     stop)
  79.     echo -n "Shutting down service at daemon"
  80.     ## Stop daemon with killproc(8) and if this fails
  81.     ## set echo the echo return value.
  82.  
  83.     killproc -TERM $ATD_BIN
  84.  
  85.     # Remember status and be verbose
  86.     rc_status -v
  87.     ;;
  88.     try-restart)
  89.     ## Stop the service and if this succeeds (i.e. the 
  90.     ## service was running before), start it again.
  91.     ## Note: try-restart is not (yet) part of LSB (as of 0.7.5)
  92.     $0 status >/dev/null &&  $0 restart
  93.  
  94.     # Remember status and be quiet
  95.     rc_status
  96.     ;;
  97.     restart)
  98.     ## Stop the service and regardless of whether it was
  99.     ## running or not, start it again.
  100.     $0 stop
  101.     $0 start
  102.  
  103.     # Remember status and be quiet
  104.     rc_status
  105.     ;;
  106.     force-reload)
  107.     ## Signal the daemon to reload its config. Most daemons
  108.     ## do this on signal 1 (SIGHUP).
  109.     ## If it does not support it, restart.
  110.  
  111.     echo -n "Reload service at daemon"
  112.  
  113.     ## Otherwise:
  114.     $0 stop  &&  $0 start
  115.     rc_status
  116.     ;;
  117.     reload)
  118.     ## Like force-reload, but if daemon does not support
  119.     ## signalling, do nothing (!)
  120.  
  121.     # If it supports signalling:
  122.     echo -n "Reload service at daemon"
  123.     
  124.     ## Otherwise if it does not support reload:
  125.     rc_failed 3
  126.     rc_status -v
  127.     ;;
  128.     status)
  129.     echo -n "Checking for at daemon: "
  130.     ## Check status with checkproc(8), if process is running
  131.     ## checkproc will return with exit status 0.
  132.  
  133.     # Status has a slightly different for the status command:
  134.     # 0 - service running
  135.     # 1 - service dead, but /var/run/  pid  file exists
  136.     # 2 - service dead, but /var/lock/ lock file exists
  137.     # 3 - service not running
  138.  
  139.     # NOTE: checkproc returns LSB compliant status values.
  140.     checkproc $ATD_BIN
  141.     rc_status -v
  142.     ;;
  143.     *)
  144.     echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload}"
  145.     exit 1
  146.     ;;
  147. esac
  148. rc_exit
  149.