summaryrefslogtreecommitdiff
path: root/usr/src/cmd/print
diff options
context:
space:
mode:
authorGhee Teo <Ghee.Teo@Sun.COM>2009-07-17 23:02:00 +0000
committerGhee Teo <Ghee.Teo@Sun.COM>2009-07-17 23:02:00 +0000
commit6124874e2cec65f2e7a974b3833b05dbf2a7d905 (patch)
tree87bd5d8d62a373120ce222792eaf36d935402e24 /usr/src/cmd/print
parent62b885670cb2373723bdad8e9fc26c05f8dabfb6 (diff)
downloadillumos-joyent-6124874e2cec65f2e7a974b3833b05dbf2a7d905.tar.gz
6851083 modify print-service to switch running printer detection daemon correctly
Diffstat (limited to 'usr/src/cmd/print')
-rw-r--r--usr/src/cmd/print/selector/Makefile9
-rwxr-xr-xusr/src/cmd/print/selector/desktop-print-management-applet81
-rwxr-xr-xusr/src/cmd/print/selector/print-service5
3 files changed, 89 insertions, 6 deletions
diff --git a/usr/src/cmd/print/selector/Makefile b/usr/src/cmd/print/selector/Makefile
index 86bc04d6e8..faa0a1bb77 100644
--- a/usr/src/cmd/print/selector/Makefile
+++ b/usr/src/cmd/print/selector/Makefile
@@ -19,21 +19,22 @@
# CDDL HEADER END
#
#
-# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
include ../../Makefile.cmd
SBINPROG = print-service
+BINPROG = desktop-print-management-applet
LPBINLINKS = lp lpstat cancel enable disable
LPRBINLINKS = lpr lpq lprm lpc
-DESKTOPLINKS = desktop-print-management desktop-print-management-applet
-DESKTOPLINKS += desktop-print-management-prefs
+DESKTOPLINKS = desktop-print-management desktop-print-management-prefs
BINLINKS = $(LPBINLINKS) $(LPRBINLINKS) $(DESKTOPLINKS)
SBINLINKS = accept reject lpmove lpadmin
ROOTUSRSBINPROG = $(SBINPROG:%=$(ROOTUSRSBIN)/%)
+ROOTUSRBINPROG = $(BINPROG:%=$(ROOTBIN)/%)
ROOTUSRBINLINKS = $(BINLINKS:%=$(ROOTBIN)/%)
ROOTUSRSBINLINKS = $(SBINLINKS:%=$(ROOTUSRSBIN)/%)
@@ -50,5 +51,5 @@ $(ROOTUSRSBINLINKS):
all check clean clobber lint:
-install: $(ROOTUSRSBINPROG) $(ROOTUSRBINLINKS) $(ROOTUSRSBINLINKS)
+install: $(ROOTUSRSBINPROG) $(ROOTUSRBINPROG) $(ROOTUSRBINLINKS) $(ROOTUSRSBINLINKS)
diff --git a/usr/src/cmd/print/selector/desktop-print-management-applet b/usr/src/cmd/print/selector/desktop-print-management-applet
new file mode 100755
index 0000000000..3f5713d52b
--- /dev/null
+++ b/usr/src/cmd/print/selector/desktop-print-management-applet
@@ -0,0 +1,81 @@
+#!/usr/perl5/bin/perl
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+#
+
+my $SVC_CUPS_SCHEDULER = 'cups/scheduler';
+my $SVCPROP = '/usr/bin/svcprop';
+
+sub svcprop {
+ local ($fmri, $property) = @_;
+ my $FH;
+
+ open($FH, "$SVCPROP -C -p $property $fmri 2>/dev/null |");
+ $result = <$FH>;
+ close($FH);
+
+ return ($result);
+}
+
+sub print_service {
+ my $service;
+
+ $service = svcprop("$SVC_CUPS_SCHEDULER:default", "general/active");
+ ($service =~ /true/) && ($service = 'cups') || ($service = 'lp');
+
+ return ($service);
+}
+
+sub kill_running_applets {
+ # cups applet daemon
+ system("pkill -f '/system-config-printer/applet.py'");
+ # lp applet daemon
+ system("pkill ospm-applet");
+}
+
+my $pid;
+
+sub handle_signal {
+ kill_running_applets ();
+}
+$SIG{USR1} = \&handle_signal;
+
+
+$SIG{CHLD} = 'IGNORE';
+my $service;
+$service = print_service();
+$pid = fork();
+if ($pid) {
+ waitpid($pid, 0);
+ exec('/usr/bin/desktop-print-management-applet');
+}
+else {
+ if ($service eq 'lp') {
+ exec('/usr/lib/lp/bin/desktop-print-management-applet');
+ }
+ else {
+ exec('/usr/lib/cups/bin/desktop-print-management-applet');
+ }
+}
+
diff --git a/usr/src/cmd/print/selector/print-service b/usr/src/cmd/print/selector/print-service
index 9fd672f565..7f90256aac 100755
--- a/usr/src/cmd/print/selector/print-service
+++ b/usr/src/cmd/print/selector/print-service
@@ -19,10 +19,9 @@
#
# CDDL HEADER END
#
-# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
-# ident "%Z%%M% %I% %E% SMI"
#
#
@@ -242,6 +241,7 @@ sub select_service {
svcadm("enable", $SVC_CUPS_SCHEDULER, $SVC_CUPS_LPD);
svccfg("cups/scheduler:default",
"setprop general/active = boolean: true");
+ system("pkill -USR1 -f '/desktop-print-management-applet'");
} else {
print("disabling CUPS services...\n");
svcadm("disable", $SVC_CUPS_SCHEDULER, $SVC_CUPS_LPD);
@@ -251,6 +251,7 @@ sub select_service {
(-f '/etc/lp/printers.conf') &&
rename('/etc/lp/printers.conf', '/etc/printers.conf');
svccfg("cups/scheduler:default", "delprop general/active");
+ system("pkill -USR1 -f '/desktop-print-management-applet'");
}
# import the new print queue configuration (if migrating)