summaryrefslogtreecommitdiff
path: root/debian/foomatic-filters.config
blob: 2e5bfd96224b6ed3693323935f44c0cfb820c0a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/bin/bash -e
#
# Debconf configuration script for the foomatic-filters package
#

. /usr/share/debconf/confmodule

db_version 2.0
db_capb backup
db_title Foomatic Printer Filter Configuration

declare -i state=1 backup=0

function parseconfig
{
	if [ -e /usr/share/foomatic/parseconfig.pl ]; then
        db_clear
        eval $(/usr/bin/perl /usr/share/foomatic/parseconfig.pl)
        db_set foomatic-filters/config_parsed true
    else
        db_set foomatic-filters/config_parsed false
    fi
}

#################
### Main loop ###
#################

parseconfig

if [ -f /etc/foomatic/defaultspooler ]; then
    db_set foomatic-filters/spooler `cat /etc/foomatic/defaultspooler`;
else
    # Try to detect from installed packages; use the one found first in
    # the list
    spooler=`dpkg-query --showformat='${Package} ${Status}' -W cupsys lpr lprng rlpr lpr-ppd pdq ppr 2>/dev/null | grep ' installed$' | cut -d' ' -f1 | head -1`
    if [ "$spooler" = cupsys ]; then
        spooler=cups
    elif [ "$spooler" = lpr-ppd -o "$spooler" = lpr -o "$spooler" = rlpr ]; then
        spooler=lpd
    fi
    if [ "$spooler" ]; then
        db_set foomatic-filters/spooler $spooler
    else
        # This script may be run before dpkg gets around to installing
        # a spooler if it is done in the same apt run, so see if anything
        # is in the "install" state.
        spooler=`dpkg-query --showformat='${Package} ${Status}' -W cupsys lpr lprng rlpr lpr-ppd pdq ppr 2>/dev/null | grep ' install ' | cut -d' ' -f1 | head -1`
        if [ "$spooler" = "cupsys" ]; then
            spooler=cups
        elif [ "$spooler" = lpr-ppd -o "$spooler" = lpr -o "$spooler" = rlpr ]; then
            spooler=lpd
        fi
        if [ "$spooler" ]; then
            db_set foomatic-filters/spooler $spooler
        fi
    fi
fi

while ((state)); do
	case $state in
        1)
            db_input low foomatic-filters/spooler || true
        ;;
        2)
			db_input low foomatic-filters/filter_debug || true
		;;
		3)
            db_get foomatic-filters/spooler;
            if [ "$RET" = cups ]; then
                ((backup ? state-- : state++ )) || true
                continue
            else
                db_input low foomatic-filters/textfilter || true
            fi
		;;
		4)
			db_get foomatic-filters/textfilter;
			if [ "$RET" = Custom ]; then
				db_input low foomatic-filters/custom_textfilter || true
			else
				((backup ? state-- : state++)) || true
				continue
			fi
		;;
		5)
            db_get foomatic-filters/spooler;
            if [ "$RET" = cups ]; then
                db_input low foomatic-filters/ps_accounting || true
            else
				((backup ? state-- : state++)) || true
				continue
            fi
		;;
		*)
			break;
		;;
	esac
        backup=0
		db_go || backup=1
		((backup ? state-- : state++))
done

db_stop

### Local Variables:
### tab-width: 4
### End: