author | Jiri Sasek <Jiri.Sasek@Sun.COM> |
Mon, 09 May 2011 15:26:57 -0700 | |
changeset 220 | 3ff562b51ff5 |
permissions | -rw-r--r-- |
220
3ff562b51ff5
7040638 CUPS (Common Unix Printing System) should move to Userland.
Jiri Sasek <Jiri.Sasek@Sun.COM>
parents:
diff
changeset
|
1 |
#!/bin/ksh |
3ff562b51ff5
7040638 CUPS (Common Unix Printing System) should move to Userland.
Jiri Sasek <Jiri.Sasek@Sun.COM>
parents:
diff
changeset
|
2 |
# |
3ff562b51ff5
7040638 CUPS (Common Unix Printing System) should move to Userland.
Jiri Sasek <Jiri.Sasek@Sun.COM>
parents:
diff
changeset
|
3 |
# CDDL HEADER START |
3ff562b51ff5
7040638 CUPS (Common Unix Printing System) should move to Userland.
Jiri Sasek <Jiri.Sasek@Sun.COM>
parents:
diff
changeset
|
4 |
# |
3ff562b51ff5
7040638 CUPS (Common Unix Printing System) should move to Userland.
Jiri Sasek <Jiri.Sasek@Sun.COM>
parents:
diff
changeset
|
5 |
# The contents of this file are subject to the terms of the |
3ff562b51ff5
7040638 CUPS (Common Unix Printing System) should move to Userland.
Jiri Sasek <Jiri.Sasek@Sun.COM>
parents:
diff
changeset
|
6 |
# Common Development and Distribution License (the "License"). |
3ff562b51ff5
7040638 CUPS (Common Unix Printing System) should move to Userland.
Jiri Sasek <Jiri.Sasek@Sun.COM>
parents:
diff
changeset
|
7 |
# You may not use this file except in compliance with the License. |
3ff562b51ff5
7040638 CUPS (Common Unix Printing System) should move to Userland.
Jiri Sasek <Jiri.Sasek@Sun.COM>
parents:
diff
changeset
|
8 |
# |
3ff562b51ff5
7040638 CUPS (Common Unix Printing System) should move to Userland.
Jiri Sasek <Jiri.Sasek@Sun.COM>
parents:
diff
changeset
|
9 |
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE |
3ff562b51ff5
7040638 CUPS (Common Unix Printing System) should move to Userland.
Jiri Sasek <Jiri.Sasek@Sun.COM>
parents:
diff
changeset
|
10 |
# or http://www.opensolaris.org/os/licensing. |
3ff562b51ff5
7040638 CUPS (Common Unix Printing System) should move to Userland.
Jiri Sasek <Jiri.Sasek@Sun.COM>
parents:
diff
changeset
|
11 |
# See the License for the specific language governing permissions |
3ff562b51ff5
7040638 CUPS (Common Unix Printing System) should move to Userland.
Jiri Sasek <Jiri.Sasek@Sun.COM>
parents:
diff
changeset
|
12 |
# and limitations under the License. |
3ff562b51ff5
7040638 CUPS (Common Unix Printing System) should move to Userland.
Jiri Sasek <Jiri.Sasek@Sun.COM>
parents:
diff
changeset
|
13 |
# |
3ff562b51ff5
7040638 CUPS (Common Unix Printing System) should move to Userland.
Jiri Sasek <Jiri.Sasek@Sun.COM>
parents:
diff
changeset
|
14 |
# When distributing Covered Code, include this CDDL HEADER in each |
3ff562b51ff5
7040638 CUPS (Common Unix Printing System) should move to Userland.
Jiri Sasek <Jiri.Sasek@Sun.COM>
parents:
diff
changeset
|
15 |
# file and include the License file at usr/src/OPENSOLARIS.LICENSE. |
3ff562b51ff5
7040638 CUPS (Common Unix Printing System) should move to Userland.
Jiri Sasek <Jiri.Sasek@Sun.COM>
parents:
diff
changeset
|
16 |
# If applicable, add the following below this CDDL HEADER, with the |
3ff562b51ff5
7040638 CUPS (Common Unix Printing System) should move to Userland.
Jiri Sasek <Jiri.Sasek@Sun.COM>
parents:
diff
changeset
|
17 |
# fields enclosed by brackets "[]" replaced with your own identifying |
3ff562b51ff5
7040638 CUPS (Common Unix Printing System) should move to Userland.
Jiri Sasek <Jiri.Sasek@Sun.COM>
parents:
diff
changeset
|
18 |
# information: Portions Copyright [yyyy] [name of copyright owner] |
3ff562b51ff5
7040638 CUPS (Common Unix Printing System) should move to Userland.
Jiri Sasek <Jiri.Sasek@Sun.COM>
parents:
diff
changeset
|
19 |
# |
3ff562b51ff5
7040638 CUPS (Common Unix Printing System) should move to Userland.
Jiri Sasek <Jiri.Sasek@Sun.COM>
parents:
diff
changeset
|
20 |
# CDDL HEADER END |
3ff562b51ff5
7040638 CUPS (Common Unix Printing System) should move to Userland.
Jiri Sasek <Jiri.Sasek@Sun.COM>
parents:
diff
changeset
|
21 |
# |
3ff562b51ff5
7040638 CUPS (Common Unix Printing System) should move to Userland.
Jiri Sasek <Jiri.Sasek@Sun.COM>
parents:
diff
changeset
|
22 |
|
3ff562b51ff5
7040638 CUPS (Common Unix Printing System) should move to Userland.
Jiri Sasek <Jiri.Sasek@Sun.COM>
parents:
diff
changeset
|
23 |
# |
3ff562b51ff5
7040638 CUPS (Common Unix Printing System) should move to Userland.
Jiri Sasek <Jiri.Sasek@Sun.COM>
parents:
diff
changeset
|
24 |
# Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. |
3ff562b51ff5
7040638 CUPS (Common Unix Printing System) should move to Userland.
Jiri Sasek <Jiri.Sasek@Sun.COM>
parents:
diff
changeset
|
25 |
# |
3ff562b51ff5
7040638 CUPS (Common Unix Printing System) should move to Userland.
Jiri Sasek <Jiri.Sasek@Sun.COM>
parents:
diff
changeset
|
26 |
|
3ff562b51ff5
7040638 CUPS (Common Unix Printing System) should move to Userland.
Jiri Sasek <Jiri.Sasek@Sun.COM>
parents:
diff
changeset
|
27 |
. /lib/svc/share/smf_include.sh |
3ff562b51ff5
7040638 CUPS (Common Unix Printing System) should move to Userland.
Jiri Sasek <Jiri.Sasek@Sun.COM>
parents:
diff
changeset
|
28 |
|
3ff562b51ff5
7040638 CUPS (Common Unix Printing System) should move to Userland.
Jiri Sasek <Jiri.Sasek@Sun.COM>
parents:
diff
changeset
|
29 |
CUPS_SVC='cups/scheduler' |
3ff562b51ff5
7040638 CUPS (Common Unix Printing System) should move to Userland.
Jiri Sasek <Jiri.Sasek@Sun.COM>
parents:
diff
changeset
|
30 |
CUPS_BIN='/usr/lib/cups/bin/lp' |
3ff562b51ff5
7040638 CUPS (Common Unix Printing System) should move to Userland.
Jiri Sasek <Jiri.Sasek@Sun.COM>
parents:
diff
changeset
|
31 |
LP_BIN='/usr/lib/lp/bin/lp' |
3ff562b51ff5
7040638 CUPS (Common Unix Printing System) should move to Userland.
Jiri Sasek <Jiri.Sasek@Sun.COM>
parents:
diff
changeset
|
32 |
ACTIVE_SVC_PROP='general/active' |
3ff562b51ff5
7040638 CUPS (Common Unix Printing System) should move to Userland.
Jiri Sasek <Jiri.Sasek@Sun.COM>
parents:
diff
changeset
|
33 |
|
3ff562b51ff5
7040638 CUPS (Common Unix Printing System) should move to Userland.
Jiri Sasek <Jiri.Sasek@Sun.COM>
parents:
diff
changeset
|
34 |
is_cups_active() |
3ff562b51ff5
7040638 CUPS (Common Unix Printing System) should move to Userland.
Jiri Sasek <Jiri.Sasek@Sun.COM>
parents:
diff
changeset
|
35 |
{ |
3ff562b51ff5
7040638 CUPS (Common Unix Printing System) should move to Userland.
Jiri Sasek <Jiri.Sasek@Sun.COM>
parents:
diff
changeset
|
36 |
ACTIVE=$( /usr/bin/svcprop -C -p "$ACTIVE_SVC_PROP" "${CUPS_SVC}:default" \ |
3ff562b51ff5
7040638 CUPS (Common Unix Printing System) should move to Userland.
Jiri Sasek <Jiri.Sasek@Sun.COM>
parents:
diff
changeset
|
37 |
2>/dev/null ) |
3ff562b51ff5
7040638 CUPS (Common Unix Printing System) should move to Userland.
Jiri Sasek <Jiri.Sasek@Sun.COM>
parents:
diff
changeset
|
38 |
[[ "$ACTIVE" == 'true' ]] |
3ff562b51ff5
7040638 CUPS (Common Unix Printing System) should move to Userland.
Jiri Sasek <Jiri.Sasek@Sun.COM>
parents:
diff
changeset
|
39 |
} |
3ff562b51ff5
7040638 CUPS (Common Unix Printing System) should move to Userland.
Jiri Sasek <Jiri.Sasek@Sun.COM>
parents:
diff
changeset
|
40 |
|
3ff562b51ff5
7040638 CUPS (Common Unix Printing System) should move to Userland.
Jiri Sasek <Jiri.Sasek@Sun.COM>
parents:
diff
changeset
|
41 |
is_lp_installed() |
3ff562b51ff5
7040638 CUPS (Common Unix Printing System) should move to Userland.
Jiri Sasek <Jiri.Sasek@Sun.COM>
parents:
diff
changeset
|
42 |
{ |
3ff562b51ff5
7040638 CUPS (Common Unix Printing System) should move to Userland.
Jiri Sasek <Jiri.Sasek@Sun.COM>
parents:
diff
changeset
|
43 |
[[ -f "$LP_BIN" ]] |
3ff562b51ff5
7040638 CUPS (Common Unix Printing System) should move to Userland.
Jiri Sasek <Jiri.Sasek@Sun.COM>
parents:
diff
changeset
|
44 |
} |
3ff562b51ff5
7040638 CUPS (Common Unix Printing System) should move to Userland.
Jiri Sasek <Jiri.Sasek@Sun.COM>
parents:
diff
changeset
|
45 |
|
3ff562b51ff5
7040638 CUPS (Common Unix Printing System) should move to Userland.
Jiri Sasek <Jiri.Sasek@Sun.COM>
parents:
diff
changeset
|
46 |
is_cups_installed() |
3ff562b51ff5
7040638 CUPS (Common Unix Printing System) should move to Userland.
Jiri Sasek <Jiri.Sasek@Sun.COM>
parents:
diff
changeset
|
47 |
{ |
3ff562b51ff5
7040638 CUPS (Common Unix Printing System) should move to Userland.
Jiri Sasek <Jiri.Sasek@Sun.COM>
parents:
diff
changeset
|
48 |
[[ -f "$CUPS_BIN" ]] |
3ff562b51ff5
7040638 CUPS (Common Unix Printing System) should move to Userland.
Jiri Sasek <Jiri.Sasek@Sun.COM>
parents:
diff
changeset
|
49 |
} |
3ff562b51ff5
7040638 CUPS (Common Unix Printing System) should move to Userland.
Jiri Sasek <Jiri.Sasek@Sun.COM>
parents:
diff
changeset
|
50 |
|
3ff562b51ff5
7040638 CUPS (Common Unix Printing System) should move to Userland.
Jiri Sasek <Jiri.Sasek@Sun.COM>
parents:
diff
changeset
|
51 |
set_cups_active() |
3ff562b51ff5
7040638 CUPS (Common Unix Printing System) should move to Userland.
Jiri Sasek <Jiri.Sasek@Sun.COM>
parents:
diff
changeset
|
52 |
{ |
3ff562b51ff5
7040638 CUPS (Common Unix Printing System) should move to Userland.
Jiri Sasek <Jiri.Sasek@Sun.COM>
parents:
diff
changeset
|
53 |
if ! /usr/sbin/print-service -s cups |
3ff562b51ff5
7040638 CUPS (Common Unix Printing System) should move to Userland.
Jiri Sasek <Jiri.Sasek@Sun.COM>
parents:
diff
changeset
|
54 |
then |
3ff562b51ff5
7040638 CUPS (Common Unix Printing System) should move to Userland.
Jiri Sasek <Jiri.Sasek@Sun.COM>
parents:
diff
changeset
|
55 |
echo "ERROR: Unable to set CUPS as the default print service" >&2 |
3ff562b51ff5
7040638 CUPS (Common Unix Printing System) should move to Userland.
Jiri Sasek <Jiri.Sasek@Sun.COM>
parents:
diff
changeset
|
56 |
exit $SMF_EXIT_ERR_FATAL |
3ff562b51ff5
7040638 CUPS (Common Unix Printing System) should move to Userland.
Jiri Sasek <Jiri.Sasek@Sun.COM>
parents:
diff
changeset
|
57 |
fi |
3ff562b51ff5
7040638 CUPS (Common Unix Printing System) should move to Userland.
Jiri Sasek <Jiri.Sasek@Sun.COM>
parents:
diff
changeset
|
58 |
} |
3ff562b51ff5
7040638 CUPS (Common Unix Printing System) should move to Userland.
Jiri Sasek <Jiri.Sasek@Sun.COM>
parents:
diff
changeset
|
59 |
|
3ff562b51ff5
7040638 CUPS (Common Unix Printing System) should move to Userland.
Jiri Sasek <Jiri.Sasek@Sun.COM>
parents:
diff
changeset
|
60 |
if is_lp_installed |
3ff562b51ff5
7040638 CUPS (Common Unix Printing System) should move to Userland.
Jiri Sasek <Jiri.Sasek@Sun.COM>
parents:
diff
changeset
|
61 |
then |
3ff562b51ff5
7040638 CUPS (Common Unix Printing System) should move to Userland.
Jiri Sasek <Jiri.Sasek@Sun.COM>
parents:
diff
changeset
|
62 |
# Do nothing. They either upgraded, installed LP only, or both. |
3ff562b51ff5
7040638 CUPS (Common Unix Printing System) should move to Userland.
Jiri Sasek <Jiri.Sasek@Sun.COM>
parents:
diff
changeset
|
63 |
# In any of these cases, we either want the default or the previously |
3ff562b51ff5
7040638 CUPS (Common Unix Printing System) should move to Userland.
Jiri Sasek <Jiri.Sasek@Sun.COM>
parents:
diff
changeset
|
64 |
# selected behaviour. |
3ff562b51ff5
7040638 CUPS (Common Unix Printing System) should move to Userland.
Jiri Sasek <Jiri.Sasek@Sun.COM>
parents:
diff
changeset
|
65 |
true |
3ff562b51ff5
7040638 CUPS (Common Unix Printing System) should move to Userland.
Jiri Sasek <Jiri.Sasek@Sun.COM>
parents:
diff
changeset
|
66 |
elif is_cups_installed |
3ff562b51ff5
7040638 CUPS (Common Unix Printing System) should move to Userland.
Jiri Sasek <Jiri.Sasek@Sun.COM>
parents:
diff
changeset
|
67 |
then |
3ff562b51ff5
7040638 CUPS (Common Unix Printing System) should move to Userland.
Jiri Sasek <Jiri.Sasek@Sun.COM>
parents:
diff
changeset
|
68 |
# LP is not installed -- make CUPS the default if it is not already |
3ff562b51ff5
7040638 CUPS (Common Unix Printing System) should move to Userland.
Jiri Sasek <Jiri.Sasek@Sun.COM>
parents:
diff
changeset
|
69 |
is_cups_active || set_cups_active |
3ff562b51ff5
7040638 CUPS (Common Unix Printing System) should move to Userland.
Jiri Sasek <Jiri.Sasek@Sun.COM>
parents:
diff
changeset
|
70 |
else |
3ff562b51ff5
7040638 CUPS (Common Unix Printing System) should move to Userland.
Jiri Sasek <Jiri.Sasek@Sun.COM>
parents:
diff
changeset
|
71 |
echo "ERROR: Neither CUPS nor LP packages installed" >&2 |
3ff562b51ff5
7040638 CUPS (Common Unix Printing System) should move to Userland.
Jiri Sasek <Jiri.Sasek@Sun.COM>
parents:
diff
changeset
|
72 |
exit $SMF_EXIT_ERR_FATAL |
3ff562b51ff5
7040638 CUPS (Common Unix Printing System) should move to Userland.
Jiri Sasek <Jiri.Sasek@Sun.COM>
parents:
diff
changeset
|
73 |
fi |
3ff562b51ff5
7040638 CUPS (Common Unix Printing System) should move to Userland.
Jiri Sasek <Jiri.Sasek@Sun.COM>
parents:
diff
changeset
|
74 |
|
3ff562b51ff5
7040638 CUPS (Common Unix Printing System) should move to Userland.
Jiri Sasek <Jiri.Sasek@Sun.COM>
parents:
diff
changeset
|
75 |
exit $SMF_EXIT_OK |