1 |
slords |
1.1 |
#!/bin/sh |
2 |
|
|
# |
3 |
|
|
# lpd This shell script takes care of starting and stopping \ |
4 |
|
|
# lpd (printer daemon). |
5 |
|
|
# |
6 |
|
|
# chkconfig: 2345 60 60 |
7 |
|
|
# description: lpd is the print daemon required for lpr to work properly. \ |
8 |
|
|
# It is basically a server that arbitrates print jobs to printer(s). |
9 |
|
|
# processname: /usr/sbin/lpd |
10 |
|
|
# config: /etc/printcap |
11 |
|
|
|
12 |
|
|
# Source function library. |
13 |
|
|
. /etc/rc.d/init.d/functions |
14 |
|
|
|
15 |
|
|
# Source networking configuration and check that networking is up. |
16 |
|
|
if [ -f /etc/sysconfig/network ] ; then |
17 |
|
|
. /etc/sysconfig/network |
18 |
|
|
[ ${NETWORKING} = "no" ] && exit 0 |
19 |
|
|
fi |
20 |
|
|
|
21 |
|
|
[ -x /usr/sbin/lpd ] || exit 0 |
22 |
|
|
|
23 |
|
|
prog=lpd |
24 |
|
|
|
25 |
|
|
RETVAL=0 |
26 |
|
|
|
27 |
slords |
1.2 |
start () { |
28 |
|
|
echo -n $"Starting $prog: " |
29 |
slords |
1.1 |
# Is this a printconf system? |
30 |
|
|
if [[ -x /usr/sbin/printconf-backend ]]; then |
31 |
|
|
# run printconf-backend to rebuild printcap and spools |
32 |
|
|
if ! /usr/sbin/printconf-backend ; then |
33 |
|
|
# If the backend fails, we dont start no printers defined |
34 |
|
|
echo -n $"No Printers Defined" |
35 |
|
|
echo_success |
36 |
|
|
echo |
37 |
slords |
1.2 |
return 0 |
38 |
slords |
1.1 |
fi |
39 |
|
|
fi |
40 |
|
|
if ! [ -e /etc/printcap ] ; then |
41 |
|
|
echo_failure |
42 |
|
|
echo |
43 |
|
|
return 1 |
44 |
|
|
fi |
45 |
|
|
# run checkpc to fix whatever lpd would complain about |
46 |
|
|
/usr/sbin/checkpc -f |
47 |
|
|
# start daemon |
48 |
|
|
daemon /usr/sbin/lpd |
49 |
|
|
RETVAL=$? |
50 |
|
|
echo |
51 |
|
|
[ $RETVAL = 0 ] && touch /var/lock/subsys/lpd |
52 |
|
|
return $RETVAL |
53 |
|
|
} |
54 |
|
|
|
55 |
|
|
stop () { |
56 |
|
|
# stop daemon |
57 |
|
|
echo -n $"Stopping $prog: " |
58 |
|
|
killproc /usr/sbin/lpd |
59 |
|
|
RETVAL=$? |
60 |
|
|
echo |
61 |
|
|
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/lpd |
62 |
|
|
return $RETVAL |
63 |
|
|
} |
64 |
|
|
|
65 |
|
|
restart () { |
66 |
|
|
stop |
67 |
|
|
start |
68 |
|
|
RETVAL=$? |
69 |
|
|
return $RETVAL |
70 |
|
|
} |
71 |
|
|
|
72 |
|
|
# See how we were called. |
73 |
|
|
case "$1" in |
74 |
|
|
start) |
75 |
|
|
start |
76 |
|
|
;; |
77 |
|
|
stop) |
78 |
|
|
stop |
79 |
|
|
;; |
80 |
|
|
status) |
81 |
|
|
status /usr/sbin/lpd |
82 |
|
|
RETVAL=$? |
83 |
|
|
;; |
84 |
|
|
restart) |
85 |
|
|
restart |
86 |
|
|
;; |
87 |
|
|
condrestart) |
88 |
|
|
# only restart if it is already running |
89 |
|
|
[ -f /var/lock/subsys/lpd ] && restart || : |
90 |
|
|
;; |
91 |
|
|
reload) |
92 |
|
|
echo -n $"Reloading $prog: " |
93 |
slords |
1.2 |
killproc /usr/sbin/lpd -HUP |
94 |
|
|
RETVAL=$? |
95 |
slords |
1.1 |
echo |
96 |
|
|
;; |
97 |
|
|
*) |
98 |
|
|
echo $"Usage: $0 {start|stop|restart|condrestart|reload|status}" |
99 |
|
|
RETVAL=1 |
100 |
|
|
esac |
101 |
|
|
|
102 |
|
|
exit $RETVAL |