#!/bin/bash # mac-cups-migraatio - Update new IP addresses of CUPS printers in OS X 10.6 # 2012-10-24, IT + DoM verkkomigraatiotiimi, LTu # Stop CUPS launchctl unload /System/Library/LaunchDaemons/org.cups.cupsd.plist # Leave unlisted queues as is, e.g. local USB or Bonjour printers # Back up the original config with time stamp perl -i.`date +%F_%T` -pe ' BEGIN { %printer = ( "10.91.1.230" => "128.91.1.230", "10.91.1.232" => "128.91.1.232", "10.91.1.242" => "", "10.91.2.241" => "", "10.52.2.242" => "", "10.52.2.244" => "", ); } if ( m,^DeviceURI.*//(.*)/$, ) { $ip = $1; s/$ip/$printer{$ip}/ if defined $printer{$ip} } ' /etc/cups/printers.conf # Start CUPS launchctl load /System/Library/LaunchDaemons/org.cups.cupsd.plist