PageRenderTime 144ms CodeModel.GetById 136ms app.highlight 4ms RepoModel.GetById 2ms app.codeStats 0ms

/rc4.d/S50cups

http://github.com/brinkman83/bashrc
Shell | 116 lines | 88 code | 14 blank | 14 comment | 24 complexity | f4412c6b8ae3c5ac5491e418d2a23a2b MD5 | raw file
  1#! /bin/sh
  2### BEGIN INIT INFO
  3# Provides:          cups
  4# Required-Start:    $syslog $remote_fs
  5# Required-Stop:     $syslog $remote_fs
  6# Should-Start:      $network avahi
  7# Should-Stop:       $network
  8# X-Start-Before:    samba
  9# X-Stop-After:      samba
 10# Default-Start:     2 3 4 5
 11# Default-Stop:      1
 12# Short-Description: CUPS Printing spooler and server
 13### END INIT INFO
 14
 15PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
 16DAEMON=/usr/sbin/cupsd
 17NAME=cupsd
 18PIDFILE=/var/run/cups/$NAME.pid
 19DESC="Common Unix Printing System"
 20
 21unset TMPDIR
 22
 23test -x $DAEMON || exit 0
 24
 25mkdir -p /var/run/cups/certs
 26
 27if [ -r /etc/default/cups ]; then
 28  . /etc/default/cups
 29fi
 30
 31. /lib/lsb/init-functions
 32
 33# Get the timezone set.
 34if [ -z "$TZ" -a -e /etc/timezone ]; then
 35    TZ=`cat /etc/timezone`
 36    export TZ
 37fi
 38
 39restart_xprint() {
 40    if [ -n "$success" ] && [ -x /etc/init.d/xprint ]; then
 41        invoke-rc.d xprint force-reload || true
 42    fi
 43}
 44
 45coldplug_usb_printers() {
 46    if type udevadm > /dev/null 2>&1 && [ -x /lib/udev/udev-configure-printer ]; then
 47	for printer in `udevadm trigger --verbose --dry-run --subsystem-match=usb \
 48		--attr-match=bInterfaceClass=07 --attr-match=bInterfaceSubClass=01 2>/dev/null || true; \
 49	                udevadm trigger --verbose --dry-run --subsystem-match=usb \
 50		--sysname-match='lp[0-9]*' 2>/dev/null || true`; do
 51	    /lib/udev/udev-configure-printer add "${printer#/sys}"
 52	done
 53    fi
 54}
 55
 56case "$1" in
 57  start)
 58	log_begin_msg "Starting $DESC: $NAME"
 59	chown root:lpadmin /usr/share/ppd/custom 2>/dev/null || true
 60	chmod 3775 /usr/share/ppd/custom 2>/dev/null || true
 61
 62	mkdir -p `dirname "$PIDFILE"`
 63	if [ "$LOAD_LP_MODULE" = "yes" -a -f /usr/lib/cups/backend/parallel \
 64             -a -f /proc/devices -a -f /proc/modules -a -x /sbin/modprobe ]; then
 65	  modprobe -q -b lp || true
 66	  modprobe -q -b ppdev || true
 67	fi
 68
 69	start-stop-daemon --start --quiet --oknodo --pidfile "$PIDFILE" --exec $DAEMON && success=1
 70
 71	coldplug_usb_printers
 72	log_end_msg $?
 73	restart_xprint
 74	;;
 75  stop)
 76	log_begin_msg "Stopping $DESC: $NAME"
 77	start-stop-daemon --stop --quiet --retry 5 --oknodo --pidfile $PIDFILE --name $NAME && success=1
 78	log_end_msg $?
 79	restart_xprint
 80	;;
 81  reload|force-reload)
 82       log_begin_msg "Reloading $DESC: $NAME"
 83       start-stop-daemon --stop --quiet --pidfile $PIDFILE --name $NAME --signal 1 && success=1
 84       log_end_msg $?
 85	restart_xprint
 86       ;;
 87  restart)
 88	log_begin_msg "Restarting $DESC: $NAME"
 89	if start-stop-daemon --stop --quiet --retry 5 --oknodo --pidfile $PIDFILE --name $NAME; then
 90		start-stop-daemon --start --quiet --pidfile "$PIDFILE" --exec $DAEMON && success=1
 91	fi
 92	log_end_msg $?
 93	restart_xprint
 94	;;
 95  status)
 96	echo -n "Status of $DESC: "
 97	if [ ! -r "$PIDFILE" ]; then
 98		echo "$NAME is not running."
 99		exit 3
100	fi
101	if read pid < "$PIDFILE" && ps -p "$pid" > /dev/null 2>&1; then
102		echo "$NAME is running."
103		exit 0
104	else
105		echo "$NAME is not running but $PIDFILE exists."
106		exit 1
107	fi
108	;;
109  *)
110	N=/etc/init.d/${0##*/}
111	echo "Usage: $N {start|stop|restart|force-reload|status}" >&2
112	exit 1
113	;;
114esac
115
116exit 0