[25012] | 1 | #!/bin/sh |
---|
| 2 | |
---|
[25066] | 3 | PHAROS_PRINTERS="mitprint bias nysa python savion wired" |
---|
[25012] | 4 | ATHENA_PRINTERS="acantha ajax albany amittai ashdown avery barbar barker bob \ |
---|
| 5 | boomboom bricks celine clearcut corfu e55prt echo edgerton \ |
---|
| 6 | eie electra fiber getitfaster hayden helios homer jarthur \ |
---|
| 7 | jonathan katharine laser lerman lotis macg maia \ |
---|
| 8 | mark-the-great massave mccormick metis mortar nhdesk pacific \ |
---|
| 9 | peecs picus pietro pindar pulp pulp-fiction quick-print \ |
---|
| 10 | sanda sidney simmons stumpgrinder sum thesis \ |
---|
| 11 | tree-eater ussy varan virus w20thesis w61cluster w84prt \ |
---|
[25066] | 12 | waffle westgate wg-tang wh-print" |
---|
[25012] | 13 | |
---|
| 14 | add_printers() { |
---|
| 15 | for p in $PHAROS_PRINTERS; do |
---|
| 16 | lpadmin -p $p -E -v lpd://mitprint.mit.edu/bw \ |
---|
| 17 | -D "Pharos (Monochrome)" \ |
---|
| 18 | -L "Release jobs from any Pharos printer" \ |
---|
| 19 | -o printer-is-share=false \ |
---|
| 20 | -m drv:///hpijs.drv/hp-laserjet_9050-hpijs-pcl3.ppd |
---|
| 21 | if [ $? != 0 ]; then |
---|
| 22 | echo "FAILED to add Pharos printer $p" |
---|
| 23 | else |
---|
| 24 | echo "Added Pharos printer $p" |
---|
| 25 | fi |
---|
| 26 | done |
---|
| 27 | for a in $ATHENA_PRINTERS; do |
---|
[25066] | 28 | # Clobber the queue if it exists |
---|
| 29 | if add-athena-printer -f $a; then |
---|
[25012] | 30 | echo "Added Athena printer $a" |
---|
| 31 | else |
---|
| 32 | echo "FAILED to add Athena printer $a" |
---|
| 33 | fi |
---|
| 34 | done |
---|
| 35 | } |
---|
| 36 | |
---|
| 37 | del_printers() { |
---|
| 38 | for p in $PHAROS_PRINTERS $ATHENA_PRINTERS; do |
---|
| 39 | lpadmin -x $p; |
---|
| 40 | if [ $? != 0 ]; then |
---|
| 41 | echo "Failed to remove printer $p!" |
---|
| 42 | fi |
---|
| 43 | done |
---|
| 44 | } |
---|
| 45 | |
---|
| 46 | require_cups() { |
---|
| 47 | # Ensure CUPS is running |
---|
| 48 | [ -e /etc/init.d/cups ] && rcname=cups || rcname=cupsys |
---|
| 49 | if hash invoke-rc.d; then |
---|
| 50 | invoke="invoke-rc.d $rcname" |
---|
| 51 | else |
---|
| 52 | invoke="/etc/init.d/$rcname" |
---|
| 53 | fi |
---|
[25329] | 54 | if ! $invoke start; then |
---|
| 55 | echo "FATAL: Couldn't start CUPS!" |
---|
| 56 | exit 1 |
---|
[25012] | 57 | fi |
---|
[25268] | 58 | if [ "$(lpstat -r)" != "scheduler is running" ]; then |
---|
| 59 | echo "FATAL: cups claimed to have started, but lpstat -r says it's not running!" |
---|
| 60 | exit 1 |
---|
| 61 | fi |
---|
[25012] | 62 | } |
---|
| 63 | |
---|
| 64 | case "$1" in |
---|
| 65 | add) |
---|
| 66 | require_cups |
---|
| 67 | add_printers |
---|
| 68 | ;; |
---|
| 69 | remove) |
---|
| 70 | require_cups |
---|
| 71 | del_printers |
---|
| 72 | ;; |
---|
| 73 | *) |
---|
[25263] | 74 | echo "Usage: $0 [ add | remove ]" |
---|
[25012] | 75 | exit 1 |
---|
| 76 | ;; |
---|
| 77 | esac |
---|
| 78 | exit 0 |
---|