Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Pushing out new printer information




On 19/01/2007, at 3:28 AM, Brian Garrett wrote:

I've recently added a new Canon mfp to our network and I'm trying to push out (using ARD) the printer and the printer configuration to the clients. I've found the PPD file located in /Library/ Printers/PPDs/Contents/Resources/en.lproj and have successfully pushed the respective file to all the clients. However when I look at the clients the Installable Options pane under the printer info doesn't reflect the settings on the server (I'm managing the queues on an Xserve). I've tried modifying the PPD to reflect the correct printer options, however that isn't working either.

I've just pushed out our new Canon printer drivers on our images.

There was a lot more there than just the PPD. From looking at my radmind transcript I have files in:

/usr/libexec/cups/filter
(These are just for our RIP, you may not have these installed)

/Library/Printers/Canon/Fax
(a heap of stuff here that is necessary for the fax printer drivers)

and a kext in:
/System/Library/Extensions/CNMFPPrinterClassDriver.kext

I've gotten over managing printers using MCX. It slows down login a lot, and we've found it to be annoying when it comes to users with directly attached printers at home, so I've got this script that runs at startup:

We keep the cups config file we want to push out on a web server at http://a.web.server/printers/printers.conf, and the ppds for each printer are kept at: http://a.web.server/printers/ppds/ (printername).ppd.

The script runs at startup, examines the local cups config file, pulls out any LPR printers that are on my network ( the '$cofa_printer_pattern' statement below), keeps any other printers that are defined, and merges them into the config file from the server, pulling down the matching ppds for each one. It's been working quite nicely actually.


#!/usr/bin/php <?php

$baseurl="http://a.web.server/printers";;
$tmpdir="/tmp/printers";

if ( file_exists("/etc/cups/printers.conf") ) {
  $current_printers_conf = file("/etc/cups/printers.conf");
} else {
  $current_printers_conf = array();
}

$start_printer_pattern = '/^<(Printer|DefaultPrinter)/';
$end_printer_pattern = '/^<\/Printer>$/';
$start_printer_def_lines = array();
$end_printer_def_lines = array();

exec("/bin/rm -Rf $tmpdir");
exec("/bin/mkdir -p $tmpdir");
exec("/bin/mkdir -p $tmpdir/ppd");

exec("/usr/bin/curl $baseurl/printers.conf -o $tmpdir/printers.conf 2&> /dev/null");

if ( file_exists("$tmpdir/printers.conf") ) {
  $new_printers_conf_array=file("$tmpdir/printers.conf");
} else {
  exec("logger: Unable to get printers.conf from server");
  exit(1);
}

foreach ($new_printers_conf_array as $line) {
if ( preg_match ($start_printer_pattern, $line)) {
$printername = str_replace('<Printer ','', $line);
$printername = str_replace(">\n",'', $printername);
exec("/usr/bin/curl $baseurl/ppds/$printername.ppd -o $tmpdir/ ppd/$printername.ppd 2&> /dev/null");
}
}


for ( $i = 0; $i < count($current_printers_conf); $i++) {
  $line = $current_printers_conf[$i];
  if ( preg_match( $start_printer_pattern, $line) ) {
    $start_printer_def_lines[] = $i;
  }
  elseif ( preg_match( $end_printer_pattern, $line) ) {
    $end_printer_def_lines[] = $i;
  }
}

if (count($start_printer_def_lines) != count($end_printer_def_lines)) {
  echo "alert!: mismatch in parsing printer definitions";
  exit(1);
}

$current_printers = array();

for ( $i = 0; $i < count($start_printer_def_lines); $i++ ) {
  $temp_array = array();
  $start = $start_printer_def_lines[$i];
  $end = $end_printer_def_lines[$i];
  $length = $end - $start + 1;
  $temp_array = array_slice($current_printers_conf, $start, $length);
  $current_printers[] = $temp_array;
}

$cofa_printer_pattern = '/^DeviceURI (lpd:\/\/149\.171\.(18|19|20| 21).*|lpd:\/\/.*cofa\.unsw\.edu\.au)/';

$printers_to_keep = array();

foreach ($current_printers as $printer) {
  $matching_lines = preg_grep ( $cofa_printer_pattern, $printer);
  if (count($matching_lines) == 0 ) {
    $printers_to_keep[] = $printer;
  }
}

foreach ($printers_to_keep as $printer) {
  foreach ($printer as $line) {
    $new_printers_conf_array[] = $line;
  }
}

$new_printers_conf_str = "";

foreach ($new_printers_conf_array as $line) {
  $new_printers_conf_str .= $line;
}

exec("/bin/cp $tmpdir/printers.conf /etc/cups/printers.conf");
exec("/bin/cp -Rf $tmpdir/ppd/* /etc/cups/ppd/");
exec("/usr/sbin/chown -R root:lp /etc/cups/");
exec("/bin/chmod 0600 /etc/cups/printers.conf");
exec("/bin/chmod 0644 /etc/cups/ppd/*");

exec("/usr/bin/killall -HUP cupsd 2& > /dev/null");

exit(0);

?>




-- Nigel Kersten http://explanatorygap.net



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Client-management mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/client-management/email@hidden

This email sent to email@hidden
References: 
 >Pushing out new printer information (From: Brian Garrett <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.