-
-
Save peelman/8220ab0c217271553808 to your computer and use it in GitHub Desktop.
Script I wrote as a postflight to a setup package for new / rebuilt machines.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
# AgComm Setup Script | |
# Built to run postflight in an installer package to set default printers and settings when setting up a new system for AgComm Use. | |
# | |
# | |
# | |
# Future: Use sysctl to fetch kernel values such as machine model for more automation. | |
# | |
# | |
# | |
# Written By: Nick Peelman | |
# Purdue University Agriculture Communcations Department | |
# www.purdue.edu | |
# September 2007 | |
# Set Up Logging | |
$logfile="/Library/Logs/AgCommStandardInstaller.log"; | |
$starttime=`date`; | |
open(LOGFILE,">>$logfile") or die "Can't Open Logfile: $!"; | |
print LOGFILE "#--- Started $starttime" ; | |
################################################################# | |
####################### PRINTERS ######################### | |
################################################################# | |
# Set Up Department Printers | |
# But First flush the old ones | |
# cancel current tasks | |
print LOGFILE "canceling all printer tasks..."; | |
$result=`cancel -a`; | |
if ($result == 0){ | |
print LOGFILE "Done\n"; | |
} else { | |
print LOGFILE "\n*******Error********\n...$result\n\n"; | |
} | |
# remove exiting printers | |
@curPrinterList=split(/\n/,`lpstat -p | grep printer | awk '{ print \$2 }'`); | |
foreach $p (@curPrinterList) { | |
print LOGFILE "Removing $p..."; | |
$result=`lpadmin -x $p`; | |
if ($result == 0){ | |
print LOGFILE "Done\n"; | |
} else { | |
print LOGFILE "\n*******Error********\n$result\n\n"; | |
} | |
} | |
if (-e "/Library/Printers/PPDs/Contents/Resources/en.lproj/ADPDF8.PPD") | |
{ | |
`/bin/mkdir /var/spool/PDFMaker` if (!(-e "/var/spool/PDFMaker")); | |
`/usr/sbin/chown nobody /var/spool/PDFMaker`; | |
`/usr/bin/chgrp nobody /var/spool/PDFMaker`; | |
`/bin/chmod 777 /var/spool/PDFMaker`; | |
`/usr/sbin/lpadmin -p AdobePDF8 -L "Local Machine" -D "Adobe CS3/Acrobat 8 PDF Printer" -E -v "pdf800://distiller/" -P "/Library/Printers/PPDs/Contents/Resources/en.lproj/ADPDF8.PPD" && echo "Adobe PDF Printer Successfully Added" >> $logfile`; | |
} | |
else | |
{ | |
print LOGFILE "Adobe PDF Driver Not Present, Adobe PDF Printer Not Installed\n"; | |
} | |
`/usr/sbin/lpadmin -p AgAD016-HP2420 -L "AgAD 016" -D "HP 2420 in AGAD 016" -E -v "socket://10.0.0.93/?bidi" -P "/Library/Printers/PPDs/Contents/Resources/en.lproj/HP LaserJet 2420.gz" && echo "AgAD 016 HP2420 Added Successfully" >> $logfile || echo "Error Adding AgAD 016" >> $logfile`; | |
`/usr/sbin/lpadmin -p AgAD206-HP2420 -L "AgAD 206" -D "HP 2420 in AGAD 206 Next to Student Station" -E -v "lpd://10.0.0.143/" -P "/Library/Printers/PPDs/Contents/Resources/en.lproj/HP LaserJet 2420.gz" -o HPOption_Duplexer=True -o Resolution=1200x1200dpi -o InstalledMemory=Mem64_79 && echo "AgAD 206 HP2420 Added Successfully" >> $logfile || echo "Error Adding AgAD 206" >> $logfile`; | |
`/usr/sbin/lpadmin -p AgAD207-HP4050 -L "AgAD 207" -D "HP 4050 in AGAD 207 In News Students Cubicle" -E -v "lpd://10.0.0.28/" -P "/Library/Printers/PPDs/Contents/Resources/en.lproj/HP LaserJet 4050 Series.gz" && echo "AgAD 207 HP4050 Added Successfully" >> $logfile || echo "Error Adding AgAD 207" >> $logfile`; | |
`/usr/sbin/lpadmin -p AgAD207-HP8150 -L "AgAD 207" -D "HP 8150 in AGAD 207 Near DTN" -E -v "lpd://10.0.0.97/" -P "/Library/Printers/PPDs/Contents/Resources/en.lproj/HP LaserJet 8150 Series.gz" && echo "AgAD 207 HP8150 Added Successfully" >> $logfile || echo "Error Adding AgAD 207" >> $logfile`; | |
`/usr/sbin/lpadmin -p AgAD204-HP2420 -L "AgAD 204" -D "HP 2420 in AGAD 204 Near Door" -E -v "lpd://10.0.0.150/" -P "/Library/Printers/PPDs/Contents/Resources/en.lproj/HP LaserJet 2420.gz" -o HPOption_Duplexer=True -o Resolution=1200x1200dpi -o InstalledMemory=Mem64_79 && echo "AgAD 204 HP2420 Added Successfully" >> $logfile || echo "Error Adding AgAD 204" >> $logfile`; | |
`/usr/sbin/lpadmin -p AgAD211-HP2420 -L "AgAD 211" -D "HP 2420 in AGAD 211 Near Door" -E -v "lpd://10.0.0.98/" -P "/Library/Printers/PPDs/Contents/Resources/en.lproj/HP LaserJet 2420.gz" && echo "AgAD 211 HP2420 Added Successfully" >> $logfile || echo "Error Adding AgAD 211" >> $logfile`; | |
`/usr/sbin/lpadmin -p AgAD202-HP5550 -L "AgAD 202" -D "HP 5550 in AgAD 202" -E -v "lpd://10.0.0.151/" -P "/Library/Printers/PPDs/Contents/Resources/en.lproj/HP Color LaserJet 5550.gz" -o HPOption_Duplexer=True -o InstalledMemory=416_544 -o HPOption_500_Sheet_Feeder_Tray3=True -o HPOption_500_Sheet_Feeder_Tray4=True -o HPOption_500_Sheet_Feeder_Tray5=True -o HPOption_Disk=HardDisk && echo "AgAD 202 HP5550 Added Successfully" >> $logfile || echo "Error Adding AgAD 202" >> $logfile`; | |
`/usr/sbin/lpadmin -p AgAD202-HP2420 -L "AgAD 202" -D "HP 2420 in AGAD 202 Near the PC" -E -v "lpd://10.0.0.89/" -P "/Library/Printers/PPDs/Contents/Resources/en.lproj/HP LaserJet 2420.gz" -o HPOption_Duplexer=True -o Resolution=1200x1200dpi -o InstalledMemory=Mem64_79 && echo "AgAD 202 HP2420 Added Successfully" >> $logfile || echo "Error Adding AgAD202" >> $logfile`; | |
`/usr/sbin/lpadmin -p AgAD203-HP2300 -L "AgAD 203" -D "HP 2300 in AGAD 203 Near Door" -E -v "lpd://10.0.0.163/" -P "/Library/Printers/PPDs/Contents/Resources/en.lproj/hp LaserJet 2300.gz" -o Resolution=1200x1200dpi -o InstalledMemory=48MB && echo "AgAD 203 HP2300 Added Successfully" >> $logfile || echo "Error Adding AgAD203" >> $logfile`; | |
`/usr/sbin/lpadmin -p AgAD010-HP4000 -L "AgAD 010" -D "HP 4000 in AGAD 010 (mailroom) Near Bonnie" -E -v "lpd://10.0.0.24/" -P "/Library/Printers/PPDs/Contents/Resources/en.lproj/HP LaserJet 4000 Series.gz" && echo "AgAD 010 HP4000 Added Successfully" >> $logfile || echo "Error Adding AgAD010" >> $logfile`; | |
`/usr/sbin/lpadmin -p AgAD003-HP2420 -L "AgAD 003" -D "HP 2420 in AGAD 003 Next to Dell 3110cn" -E -v "lpd://10.0.0.91/" -P "/Library/Printers/PPDs/Contents/Resources/en.lproj/HP LaserJet 2420.gz" -o HPOption_Duplexer=True -o Resolution=1200x1200dpi -o InstalledMemory=Mem64_79 && echo "AgAD 003 HP2420 Added Successfully" >> $logfile || echo "Error Adding AgAD003 HP2420" >> $logfile`; | |
################################################################# | |
# The Three Dell Color Lasers | |
`/usr/sbin/lpadmin -p AgAD003-Dell3110cn -L "AgAD 003" -D "Dell 3110cn in AGAD 003 near Copy Machine" -E -v "socket://10.0.0.27/?bidi" -P "/Library/Printers/PPDs/Contents/Resources/en.lproj/Dell Color Laser 3110cn.gz" && echo "AgAD 003 Dell Added Successfully" >> $logfile || echo "Error Adding AgAD003 Dell" >> $logfile`; | |
`/usr/sbin/lpadmin -p AgAD206-Dell3110cn -L "AgAD 206" -D "Dell 3110cn in AGAD 206 Behind Patty" -E -v "socket://10.0.0.47/?bidi" -P "/Library/Printers/PPDs/Contents/Resources/en.lproj/Dell Color Laser 3110cn.gz" && echo "AgAD 206 Dell Added Successfully" >> $logfile || echo "Error Adding AgAD206 Dell" >> $logfile`; | |
`/usr/sbin/lpadmin -p AgAD205-Dell3110cn -L "AgAD 205" -D "Dell 3110cn in AGAD 205 near Christine" -E -v "socket://10.0.0.48/?bidi" -P "/Library/Printers/PPDs/Contents/Resources/en.lproj/Dell Color Laser 3110cn.gz" && echo "AgAD 205 Dell Added Successfully" >> $logfile || echo "Error Adding AgAD 205 Dell" >> $logfile`; | |
################################################################# | |
################################################################# | |
# Close Logging and clean up | |
$endtime = `date`; | |
print LOGFILE "#--- Completed $endtime"; | |
close LOGFILE; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment