]>
Commit | Line | Data |
---|---|---|
03de21a2 | 1 | #!/bin/sh |
2 | # | |
3 | # LPRng This shell script takes care of starting and stopping | |
4 | # LPRng lpd (printer daemon). | |
5 | # | |
6 | # chkconfig: 2345 60 60 | |
7 | # | |
8 | # description: LPRng lpd is the print daemon required for lpr to work properly. \ | |
9 | # It is basically a server that arbitrates print jobs to printer(s). | |
10 | # | |
11 | # processname: lpd | |
12 | # config: /etc/printcap | |
13 | ||
14 | ||
15 | # Source function library | |
16 | . /etc/rc.d/init.d/functions | |
17 | ||
18 | # Get network config | |
19 | . /etc/sysconfig/network | |
20 | ||
21 | # Get service config | |
22 | [ -f /etc/sysconfig/lpd ] && . /etc/sysconfig/lpd | |
23 | ||
24 | # Check that networking is up. | |
aece03f3 | 25 | if is_yes "${NETWORKING}"; then |
1967e0c9 | 26 | if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then |
aece03f3 | 27 | msg_network_down LPRng |
28 | exit 1 | |
29 | fi | |
30 | else | |
31 | exit 0 | |
03de21a2 | 32 | fi |
33 | ||
34 | # Sanity check | |
35 | [ -f /etc/printcap ] || exit 0 | |
36 | ||
1c76017a | 37 | start() { |
03de21a2 | 38 | # Check if the service is already running? |
39 | if [ ! -f /var/lock/subsys/lpd ]; then | |
40 | msg_starting LPRng | |
41 | daemon lpd | |
42 | RETVAL=$? | |
43 | [ $RETVAL -eq 0 ] && touch /var/lock/subsys/lpd | |
44 | else | |
2b575342 | 45 | msg_already_running "LPRng" |
03de21a2 | 46 | fi |
1c76017a JB |
47 | } |
48 | ||
49 | stop() { | |
03de21a2 | 50 | if [ -f /var/lock/subsys/lpd ]; then |
51 | msg_stopping "LPRng" | |
52 | killproc lpd | |
53 | rm -f /var/lock/subsys/lpd >/dev/null 2>&1 | |
54 | else | |
2b575342 | 55 | msg_not_running "LPRng" |
03de21a2 | 56 | fi |
1c76017a JB |
57 | } |
58 | ||
59 | condrestart() { | |
60 | if [ -f /var/lock/subsys/lpd ]; then | |
61 | stop | |
62 | start | |
63 | else | |
64 | msg_not_running "LPRng" | |
65 | RETVAL=$1 | |
66 | fi | |
67 | } | |
68 | ||
69 | RETVAL=0 | |
70 | # See how we were called. | |
71 | case "$1" in | |
72 | start) | |
73 | start | |
74 | ;; | |
75 | stop) | |
76 | stop | |
77 | ;; | |
78 | restart) | |
79 | stop | |
80 | start | |
81 | ;; | |
82 | try-restart) | |
83 | condrestart 0 | |
84 | ;; | |
85 | force-reload) | |
86 | condrestart 7 | |
aece03f3 | 87 | ;; |
03de21a2 | 88 | status) |
89 | status lpd | |
90 | exit $? | |
91 | ;; | |
03de21a2 | 92 | *) |
1c76017a | 93 | msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}" |
e4a04cd1 | 94 | exit 3 |
03de21a2 | 95 | esac |
96 | ||
97 | exit $RETVAL |