blob: 0f8a6aa7b7c0709ac37114ca135745fcc1cf7d07 (
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
major=9
minor=1
pre_install() {
PHASE2_PPDS=/usr/share/cups/model/kyocera/
PHASE3_PPDS=/usr/share/ppd/kyocera/
if [ -d $PHASE2_PPDS ]; then
rm -rvf $PHASE2_PPDS
fi
if [ -d $PHASE3_PPDS ]; then
rm -rvf $PHASE3_PPDS
fi
}
post_install() {
xdg-icon-resource forceupdate --theme hicolor &> /dev/null
ALTERNATE_PPD_DIRECTORY=/usr/share/cups/model/kyocera
PRIMARY_PPD_DIRECTORY=/usr/share/ppd/kyocera/
INSTALLED_PPD_DIRECTORY=/usr/share/kyocera${major}/ppd${major}
if [ ! -d $INSTALLED_PPD_DIRECTORY ]; then
INSTALLED_PPD_DIRECTORY=/usr/share/kyocera${major}.${minor}/ppd${major}.${minor}
fi
mkdir -p $PRIMARY_PPD_DIRECTORY
cp -r $INSTALLED_PPD_DIRECTORY/* $PRIMARY_PPD_DIRECTORY
chmod 777 /usr/share/kyocera${major} || chmod 777 /usr/share/kyocera${major}.${minor}
chmod 755 /usr/bin/kyoPPDWrite_H
if [ ! -h $ALTERNATE_PPD_DIRECTORY ]; then
ln -s $PRIMARY_PPD_DIRECTORY $ALTERNATE_PPD_DIRECTORY
fi
mime_line="application/postscript application/vnd.cups-pdf 66 gstopdf"
cups_conf='/etc/cups/local.convs'
if [ -e $cups_conf ]; then
grep -q -F "$mime_line" $cups_conf || echo "$mime_line" >> $cups_conf
else
echo "$mime_line" > $cups_conf
fi
update-desktop-database -q
}
pre_upgrade() {
pre_install
}
post_upgrade() {
post_install
}
post_remove() {
xdg-icon-resource forceupdate --theme hicolor &> /dev/null
KYOCERA_CONFIG="/usr/share/kyocera${major}"
if [ ! -d $KYOCERA_CONFIG ]; then
KYOCERA_CONFIG="/usr/share/kyocera{major}.{minor}"
fi
uninstall_printers(){
files=`grep -l "kyofilter_H\|kyofilter_ras_H\|kyofilter_pdf_H\|kyofilter_kpsl_H" /etc/cups/ppd/* 2>/dev/null`
if [ ! -z "$files" ]; then
for file in ${files}; do
if matches $file .ppd; then
basefile=$(basename $file .ppd)
lpadmin -x $basefile
fi
done
fi
}
get_user_printer_list(){
# $1 is user
if [ -d $KYOCERA_CONFIG/$1 ]; then
echo `ls $KYOCERA_CONFIG/$1`
fi
}
uninstall_kyocera_config_files(){
# $1 is user
# $2 is printer list
rm -rf "$KYOCERA_CONFIG/$1/"
}
uninstall_lpoptions_config_files(){
# $1 is user
# $2 is printer list
lp_options="/home/$1/.cups/lpoptions"
#echo "Editing lpoptions config file"
if [ ! -z $2 ]; then
for printer in ${printers}; do
#echo "sed $base_printer $lp_options"
sed -i "s/\(Dest\|Default\) $base_printer.*//" $lp_options
done
fi
}
uninstall_config_files(){
#For each user, uninstall the config files in
#/usr/share/kyocera9/<username> and ~/.cups/lpoptions
if [ -d $KYOCERA_CONFIG ]; then
users=`ls $KYOCERA_CONFIG | grep -v 'ppd${major}\|ppd${major}.${minor}\|appicon\|Python'`
if [ ! -z "$users" ]; then
for user in ${users}; do
is_appicon=`matches $user appicon.png`
is_python=`matches $user Python`
if [ ! $is_appicon ] && [ ! $is_python ] ;then
printers=`get_user_printer_list $user`
uninstall_kyocera_config_files $user $printers
uninstall_lpoptions_config_files $user $printers
fi
done
fi
fi
}
{
rm -rf /usr/share/cups/model/kyocera
if [ -d /usr/share/ppd/kyocera ]; then
rm -rf "/usr/share/ppd/kyocera"
fi
}
matches(){
input="$1"
pattern="$2"
echo "$input" | grep -q "$pattern"
}
uninstall_printers
uninstall_config_files
#echo ""
update-desktop-database -q
}
|