source: trunk/debathena/config/cluster-cups-config/debian/configure-athena-printers @ 25329

Revision 25329, 2.1 KB checked in by jdreed, 13 years ago (diff)
In cluster-cups-config: * /etc/init.d/cups status always returns 0, so require_cups() in configure-athena-printers won't actually require cups. Fix by just calling start, since it's a noop if the service is already running.
  • Property svn:executable set to *
Line 
1#!/bin/sh
2
3PHAROS_PRINTERS="mitprint bias nysa python savion wired"
4ATHENA_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 \
12                 waffle westgate wg-tang wh-print"
13
14add_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
28        # Clobber the queue if it exists
29        if add-athena-printer -f $a; then
30            echo "Added Athena printer $a"
31        else
32            echo "FAILED to add Athena printer $a"
33        fi
34    done
35}
36
37del_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
46require_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
54    if ! $invoke start; then
55        echo "FATAL: Couldn't start CUPS!"
56        exit 1
57    fi
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
62}
63
64case "$1" in
65    add)
66        require_cups 
67        add_printers
68        ;;
69    remove)
70        require_cups
71        del_printers
72        ;;
73    *)
74        echo "Usage: $0 [ add | remove ]"
75        exit 1
76        ;;
77esac
78exit 0
Note: See TracBrowser for help on using the repository browser.