blob: fd21994d95849878ef4a2f86d6298b974772e240 (
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
|
PREFIX=/usr/share
printer_model=""mfcj4335dw""
printer_name=`echo $printer_model | tr '[a-z]' '[A-Z]'`
device_name=`echo $printer_name | eval sed -e 's/MFC/MFC-/' -e 's/DCP/DCP-/' -e 's/HL/HL-/' -e 's/FAX/FAX-/'`
ppd_file_name=$PREFIX/cups/model/Brother/brother_${printer_model}_printer_en.ppd
post_install() {
post_upgrade;
echo "Register the new printer at \"http://localhost:631/\"."
print_lpadmin;
apply_selinux_policy;
}
post_upgrade() {
echo "Restart CUPS (cups.service) in order to load the new files."
}
apply_selinux_policy() {
if [ "$(which semanage 2> /dev/null)" != '' ];then
semanage fcontext -a -t cupsd_rw_etc_t '/opt/brother/Printers/'${printer_model}'/inf(/.*)?'
semanage fcontext -a -t bin_t '/opt/brother/Printers/'${printer_model}'/lpd(/.*)?'
semanage fcontext -a -t bin_t '/opt/brother/Printers/'${printer_model}'/cupswrapper(/.*)?'
if [ "$(which restorecon 2> /dev/null)" != '' ];then
restorecon -R /opt/brother/Printers/${printer_model}
fi
fi
}
print_lpadmin() {
uris=$(lpinfo -v)
for uri in $uris
do
URI=$(echo $uri | grep ${device_name} | grep usb)
if [ "$URI" != '' ];then
break;
fi
done
if [ "$URI" = '' ];then
for uri in $uris
do
URI=$(echo $uri | grep ${device_name} )
if [ "$URI" != '' ];then
break;
fi
done
fi
if [ "$URI" = '' ];then
for uri in $uris
do
URI=$(echo $uri | grep -i Brother | grep usb )
if [ "$URI" != '' ];then
break;
fi
done
fi
if [ "$URI" = '' ];then
for uri in $uris
do
URI=$(echo $uri | grep usb )
if [ "$URI" != '' ];then
break;
fi
done
fi
if [ "$URI" = '' ];then
URI="usb://dev/usb/lp0"
fi
echo "or execute 'lpadmin -p ${printer_name} -E -v $URI -P ${ppd_file_name}'"
}
|