Mercurial > vanilla
diff print/cups/cupsd @ 700:98351d3f57eb
print/cups: initial import, closes #1232
author | David Demelier <markand@malikania.fr> |
---|---|
date | Fri, 02 Aug 2019 20:10:00 +0200 |
parents | |
children | 3dfef64b81c1 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/print/cups/cupsd Fri Aug 02 20:10:00 2019 +0200 @@ -0,0 +1,74 @@ +#!/bin/sh +# +# /etc/rc.d/cupsd -- run control script for cupsd +# +# Copyright (c) 2019 David Demelier <markand@malikania.fr> +# +# Permission to use, copy, modify, and/or distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +# + +if [ -f /etc/rc.conf ]; then + . /etc/rc.conf +fi + +: ${TEMPLATE_CMD:=/bin/cupsd} +: ${TEMPLATE_ARGS:=} +: ${TEMPLATE_PID:=/var/run/cups/cupsd.pid} + +cupsd_start() +{ + echo "Starting cupsd: $TEMPLATE_CMD $TEMPLATE_ARGS" + $TEMPLATE_CMD $TEMPLATE_ARGS -p $TEMPLATE_PID +} + +cupsd_status() +{ + if [ -s $TEMPLATE_PID ]; then + echo "cupsd is running with pid: $(cat $TEMPLATE_PID)" + else + echo "cupsd is not running" + fi +} + +cupsd_stop() +{ + if [ -s $TEMPLATE_PID ]; then + echo "Stopping cupsd." + kill -QUIT $(cat $TEMPLATE_PID) + fi +} + +cupsd_restart() +{ + cupsd_stop + sleep 3 + cupsd_start +} + +case $1 in +start) + cupsd_start + ;; +status) + cupsd_status + ;; +stop) + cupsd_stop + ;; +restart) + cupsd_restart + ;; +*) + echo "usage: $(basename $0) restart|start|status|stop" + ;; +esac