summaryrefslogtreecommitdiff
path: root/print/LPRng-core/files/LPRng.sh
blob: c6f2a4655da71ae709627f83ff94be55035172aa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/sh
#
# $NetBSD: LPRng.sh,v 1.1 2000/12/28 00:13:08 jlam Exp $
#
# PROVIDE: lpd
# REQUIRE: DAEMON

name="lpd"
command=@@PREFIX@@/sbin/${name}
pidfile="/var/run/${name}.pid"

if [ -f ${pidfile} ]
then
	pid=`head -1 ${pidfile}`
else
	pid=`ps -ax | awk '{print $1,$5}' | grep ${name} | awk '{print $1}'`
fi

cmd=${1:-start}

case ${cmd} in
start)
	if [ "$pid" = "" -a -x ${command} ]
	then
		echo "Starting LPRng."
		${command}
	fi
	;;

stop)
	if [ "$pid" != "" ]
	then
		echo "Stopping LPRng."
		kill $pid
	fi
	;;

restart)
	( $0 stop )
	sleep 5
	$0 start
	;;

status)
	if [ "$pid" != "" ]
	then
		echo "LPRng is running as pid ${pid}."
	else
		echo "LPRng is not running."
	fi
	;;

*)
	echo 1>&2 "Usage: ${name} [restart|start|stop|status]"
	exit 1
	;;
esac
exit 0