#!/bin/sh PHAROS_PRINTERS="mitprint bias nysa python savion wired" ATHENA_PRINTERS="acantha ajax albany amittai ashdown avery barbar barker bob \ boomboom bricks celine clearcut corfu e55prt echo edgerton \ eie electra fiber getitfaster hayden helios homer jarthur \ jonathan katharine laser lerman lotis macg maia \ mark-the-great massave mccormick metis mortar nhdesk pacific \ peecs picus pietro pindar pulp pulp-fiction quick-print \ sanda sidney simmons stumpgrinder sum thesis \ tree-eater ussy varan virus w20thesis w61cluster w84prt \ waffle westgate wg-tang wh-print" add_printers() { for p in $PHAROS_PRINTERS; do lpadmin -p $p -E -v lpd://mitprint.mit.edu/bw \ -D "Pharos (Monochrome)" \ -L "Release jobs from any Pharos printer" \ -o printer-is-share=false \ -m drv:///hpijs.drv/hp-laserjet_9050-hpijs-pcl3.ppd if [ $? != 0 ]; then echo "FAILED to add Pharos printer $p" else echo "Added Pharos printer $p" fi done for a in $ATHENA_PRINTERS; do # Clobber the queue if it exists if add-athena-printer -f $a; then echo "Added Athena printer $a" else echo "FAILED to add Athena printer $a" fi done } del_printers() { for p in $PHAROS_PRINTERS $ATHENA_PRINTERS; do lpadmin -x $p; if [ $? != 0 ]; then echo "Failed to remove printer $p!" fi done } require_cups() { # Ensure CUPS is running [ -e /etc/init.d/cups ] && rcname=cups || rcname=cupsys if hash invoke-rc.d; then invoke="invoke-rc.d $rcname" else invoke="/etc/init.d/$rcname" fi if ! $invoke start; then echo "FATAL: Couldn't start CUPS!" exit 1 fi if [ "$(lpstat -r)" != "scheduler is running" ]; then echo "FATAL: cups claimed to have started, but lpstat -r says it's not running!" exit 1 fi } case "$1" in add) require_cups add_printers ;; remove) require_cups del_printers ;; *) echo "Usage: $0 [ add | remove ]" exit 1 ;; esac exit 0