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 |
config () { |
28 |
# Is this a printconf system? |
29 |
if [[ -x /usr/sbin/printconf-backend ]]; then |
30 |
# run printconf-backend to rebuild printcap and spools |
31 |
if ! /usr/sbin/printconf-backend ; then |
32 |
# If the backend fails, we dont start no printers defined |
33 |
echo -n $"No Printers Defined" |
34 |
echo_success |
35 |
echo |
36 |
return 1 |
37 |
fi |
38 |
fi |
39 |
return 0 |
40 |
} |
41 |
|
42 |
start () { |
43 |
echo -n $"Starting $prog: " |
44 |
|
45 |
if ! config; then |
46 |
return 0 |
47 |
fi |
48 |
|
49 |
if ! [ -e /etc/printcap ] ; then |
50 |
echo_failure |
51 |
echo |
52 |
return 1 |
53 |
fi |
54 |
# run checkpc to fix whatever lpd would complain about |
55 |
/usr/sbin/checkpc -f |
56 |
# start daemon |
57 |
daemon /usr/sbin/lpd |
58 |
RETVAL=$? |
59 |
echo |
60 |
[ $RETVAL = 0 ] && touch /var/lock/subsys/lpd |
61 |
return $RETVAL |
62 |
} |
63 |
|
64 |
stop () { |
65 |
# stop daemon |
66 |
echo -n $"Stopping $prog: " |
67 |
killproc /usr/sbin/lpd |
68 |
RETVAL=$? |
69 |
echo |
70 |
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/lpd |
71 |
return $RETVAL |
72 |
} |
73 |
|
74 |
restart () { |
75 |
stop |
76 |
start |
77 |
RETVAL=$? |
78 |
return $RETVAL |
79 |
} |
80 |
|
81 |
# See how we were called. |
82 |
case "$1" in |
83 |
start) |
84 |
start |
85 |
;; |
86 |
stop) |
87 |
stop |
88 |
;; |
89 |
status) |
90 |
status /usr/sbin/lpd |
91 |
RETVAL=$? |
92 |
;; |
93 |
restart) |
94 |
restart |
95 |
;; |
96 |
condrestart) |
97 |
# only restart if it is already running |
98 |
[ -f /var/lock/subsys/lpd ] && restart || : |
99 |
;; |
100 |
reload) |
101 |
echo -n $"Reloading $prog: " |
102 |
if config; then |
103 |
killproc /usr/sbin/lpd -HUP |
104 |
RETVAL=$? |
105 |
else |
106 |
RETVAL=1 |
107 |
fi |
108 |
echo |
109 |
;; |
110 |
*) |
111 |
echo $"Usage: $0 {start|stop|restart|condrestart|reload|status}" |
112 |
RETVAL=1 |
113 |
esac |
114 |
|
115 |
exit $RETVAL |