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 / cups < prev    next >
Text File  |  2010-02-10  |  5KB  |  179 lines

  1. #! /bin/sh
  2. #
  3. # Copyright (c) 1995-2001 SuSE GmbH Nuernberg, Germany.
  4. # Copyright (c) 2002 SuSE Linux AG, Nuernberg, Germany.
  5. # Copyright (C) 2002--2008  Klaus Singvogel, SUSE / Novell Inc.
  6. #
  7. # Author: Kurt Garloff <feedback@suse.de>, 2000
  8. #      Klaus Singvogel <feedback@suse.de>, 2002--2008
  9. #
  10. # /etc/init.d/cupsd
  11. #
  12. #   and symbolic its link
  13. #
  14. # /sbin/rccupsd
  15. #
  16. # System startup script for the CUPS printer daemon
  17. #
  18. ### BEGIN INIT INFO
  19. # Provides:            cupsd
  20. # Required-Start:      $local_fs $remote_fs $syslog
  21. # Required-Stop:       $remote_fs $syslog
  22. # Should-Start:        dbus $named $portmap ptal slpd printbill
  23. # Should-Stop:         $portmap
  24. # Default-Start:       2 3 5
  25. # Default-Stop:        0 1 6
  26. # Short-Description:   CUPS printer daemon
  27. # Description:         Start CUPS to provide spooling and printing files
  28. #    functionality for local and remote printers. Even required if
  29. #    printers are broadcasted ("Browsing") into (sub)nets.
  30. ### END INIT INFO
  31.  
  32. # Source SuSE config, only if exists with size greater zero
  33. test -s /etc/rc.config && \
  34.     . /etc/rc.config
  35.  
  36. # Shell functions sourced from /etc/rc.status:
  37. #      rc_check         check and set local and overall rc status
  38. #      rc_status        check and set local and overall rc status
  39. #      rc_status -v     ditto but be verbose in local rc status
  40. #      rc_status -v -r  ditto and clear the local rc status
  41. #      rc_failed        set local and overall rc status to failed
  42. #      rc_failed <num>  set local and overall rc status to <num><num>
  43. #      rc_reset         clear local rc status (overall remains)
  44. #      rc_exit          exit appropriate to overall rc status
  45.  
  46. CUPSD_BIN=/usr/sbin/cupsd
  47.  
  48. test -s /etc/rc.status && \
  49.      . /etc/rc.status
  50.  
  51. test -s /etc/sysconfig/cups && \
  52.      . /etc/sysconfig/cups
  53.  
  54. test -x $CUPSD_BIN || exit 5
  55.  
  56. # First reset status of this service
  57. rc_reset
  58.  
  59. # Return values acc. to LSB for all commands but status:
  60. # 0 - success
  61. # 1 - generic or unspecified error
  62. # 2 - invalid or excess argument(s)
  63. # 3 - unimplemented feature (e.g. "reload")
  64. # 4 - insufficient privilege
  65. # 5 - program is not installed
  66. # 6 - program is not configured
  67. # 7 - program is not running
  68. # Note that starting an already running service, stopping
  69. # or restarting a not-running service as well as the restart
  70. # with force-reload (in case signalling is not supported) are
  71. # considered a success.
  72.  
  73. # change umask to avoid problems in wrong file permission of /etc/printcap
  74. # (see Novell/Suse Bugzilla bnc#31567 formerly SuSE buzilla #16567)
  75. umask 022
  76.  
  77. # silence the Avahi Bonjour compat warning, since this can cause SIGPIPE
  78. # if stderr is not available when cupsd does not run in the foreground
  79. # which lets cupsd crash with "cupsd: Child exited on signal 13"
  80. # (see Novell/Suse Bugzilla bnc#576507 and CUPS STR #2931)
  81. export AVAHI_COMPAT_NOWARN=1
  82.  
  83. case "$1" in
  84.     start)
  85.     echo -n "Starting cupsd"
  86.     ## Start daemon with startproc(8). If this fails
  87.     ## the echo return value is set appropriate.
  88.  
  89.     # NOTE: startproc return 0, even if service is 
  90.     # already running to match LSB spec.
  91.     startproc $CUPSD_BIN $CUPSD_OPTIONS
  92.  
  93.     # Remember status and be verbose
  94.     rc_status -v
  95.     ;;
  96.     stop)
  97.     echo -n "Shutting down cupsd"
  98.     ## Stop daemon with killproc(8) and if this fails
  99.     ## set echo the echo return value.
  100.  
  101.     killproc -TERM $CUPSD_BIN
  102.  
  103.     # Remember status and be verbose
  104.     rc_status -v
  105.     ;;
  106.     try-restart)
  107.     ## Stop the service and if this succeeds (i.e. the 
  108.     ## service was running before), start it again.
  109.     ## Note: try-restart is not (yet) part of LSB (as of 0.7.5)
  110.     $0 status >/dev/null &&  $0 restart
  111.  
  112.     # Remember status and be quiet
  113.     rc_status
  114.     ;;
  115.     restart)
  116.     ## Stop the service and regardless of whether it was
  117.     ## running or not, start it again.
  118.     $0 stop
  119.     $0 start
  120.  
  121.     # Remember status and be quiet
  122.     rc_status
  123.     ;;
  124.     force-reload)
  125.     ## Signal the daemon to reload its config. Most daemons
  126.     ## do this on signal 1 (SIGHUP).
  127.     ## If it does not support it, restart.
  128.  
  129.     if ps -C cupsd -o user | grep -q '^root$'; then
  130.         echo -n "Reload service cupsd"
  131.         killproc -HUP $CUPSD_BIN
  132.         rc_status -v
  133.     else
  134.         $0 restart
  135.     fi
  136.     ;;
  137.     reload)
  138.     ## Like force-reload, but if daemon does not support
  139.     ## signalling, do nothing (!)
  140.  
  141.     # If it supports signalling:
  142.     if ps -C cupsd -o user | grep -q '^root$'; then
  143.         echo -n "Reload service cupsd"
  144.         killproc -HUP $CUPSD_BIN
  145.         rc_status -v
  146.     else
  147.         echo -n '"reload" not possible in RunAsUser mode - use "restart" instead'
  148.         rc_status -s
  149.     fi
  150.     ;;
  151.     status)
  152.     echo -n "Checking for cupsd: "
  153.     ## Check status with checkproc(8), if process is running
  154.     ## checkproc will return with exit status 0.
  155.  
  156.     # Status has a slightly different for the status command:
  157.     # 0 - service running
  158.     # 1 - service dead, but /var/run/  pid  file exists
  159.     # 2 - service dead, but /var/lock/ lock file exists
  160.     # 3 - service not running
  161.  
  162.     # NOTE: checkproc returns LSB compliant status values.
  163.     checkproc $CUPSD_BIN
  164.     rc_status -v
  165.     ;;
  166.     probe)
  167.     ## Optional: Probe for the necessity of a reload,
  168.     ## give out the argument which is required for a reload.
  169.  
  170.     rc_failed 3
  171.     ;;
  172.     *)
  173.     echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|probe}"
  174.     exit 1
  175.     ;;
  176. esac
  177. rc_exit
  178.