-
Notifications
You must be signed in to change notification settings - Fork 11
/
canonLBP_install.sh
executable file
·203 lines (189 loc) · 5.56 KB
/
canonLBP_install.sh
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
#!/bin/bash
################################################################################
# This script will help you install Canon CAPT Printer Driver 2.00 for #
# Debian-based Linux systems using the 32bit or 64bit OS architecture. #
# #
# @author Radu Cotescu #
# @version 2.4 #
# #
# For more details please visit: #
# http://radu.cotescu.com/?p=1194 #
################################################################################
param1="$1"
param2="$2"
param_no="$#"
args=$@
WORKSPACE="`dirname $0`/DEBS"
PRINTER_MODEL=""
PRINTER_SMODEL=""
ARCH=""
IP_REGEX="^([1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])){3}$"
IP=""
models="LBP-1120 LBP-1210 LBP2900 LBP3000 LBP3010 LBP3018 LBP3050 LBP3100
LBP3108 LBP3150 LBP3200 LBP3210 LBP3250 LBP3300 LBP3310 LBP3500 LBP5000 LBP5050
LBP5100 LBP5300 LBP6000 LBP6018 LBP6300dn LBP7200C LBP9100Cdn"
usage_message="This script will help you install Canon CAPT Printer Driver \
2.00 for Debian-based Linux systems using the 32-bit or 64-bit OS architecture.\n"
options="PRINTER_MODEL can be any of the following:\n$models\n\n\
If an IP is supplied the printer will be accessed from the network at that address.\
This setting is valid only for printers that support network printing."
display_usage() {
echo -e "Usage: ./`basename $0` PRINTER_MODEL [IP]\n"
echo -e $usage_message | fold -s
echo -e $options | fold -s
}
check_superuser() {
if [[ $USER != "root" ]]; then
echo "This script must be run with superuser privileges!"
display_usage
exit 1
fi
}
check_args() {
if [[ $param_no -eq 1 ]]; then
case $param1 in
"-h" | "--help")
display_usage
exit 0
;;
*)
for model in $models; do
if [[ $param1 == $model ]]; then
PRINTER_MODEL=$param1
break;
fi
done
check_printer_model
esac
elif [[ $param_no -eq 2 ]]; then
for model in $models; do
if [[ $param1 == $model ]]; then
PRINTER_MODEL=$param1
break;
fi
done
check_printer_model
IP=`echo $param2 | egrep -e "$IP_REGEX"`
if [[ -z $IP ]]; then
echo "Invalid IP!"
exit 1
fi
else
echo "Wrong parameter number!"
display_usage
exit 1
fi
}
check_printer_model() {
if [[ -z $PRINTER_MODEL ]]; then
echo -e "Error: Unkown printer model!\n"
display_usage
exit 1
fi
case $PRINTER_MODEL in
"LBP6000" | "LBP6018")
PRINTER_SMODEL="LBP6018"
;;
"LBP3100" | "LBP3108" | "LBP3150")
PRINTER_SMODEL="LBP3150"
;;
"LBP3010" | "LBP3018" | "LBP3050")
PRINTER_SMODEL="LBP3050"
;;
"LBP-1210")
PRINTER_SMODEL="LBP1210"
;;
"LBP-1120")
PRINTER_SMODEL="LBP1120"
;;
"LBP6300dn")
PRINTER_SMODEL="LBP6300"
;;
"LBP9100Cdn")
PRINTER_SMODEL="LBP9100C"
;;
*)
PRINTER_SMODEL=$PRINTER_MODEL
esac
}
packageError() {
if [[ $1 -ne 0 ]]; then
echo "I am unable to install the before mentioned package..."
echo "Please install the required package and rerun the script..."
exit 1
fi
}
check_requirements_for_release() {
release="`lsb_release -r | awk '{ print $2 }'`"
lib=6
if [[ "$release" == "9.10" ]]; then
lib=5
fi
check_lib=`dpkg-query -W -f='${Status} ${Version}\n' libstdc++${lib} 2> /dev/null | egrep "^install"`
if [[ -z $check_lib ]]; then
echo "Installing libstdc++${lib} package..."
apt-get -y install libstdc++${lib}
packageError $?
else echo "You do have the libstdc++${lib} package..."
fi
}
install_driver() {
machine=`uname -m`
if [[ $machine == "x86_64" ]]; then
ARCH="amd64"
else
ARCH="i386"
fi
cndrv_common="cndrvcups-common_2.20-1_${ARCH}.deb"
cndrv_capt="cndrvcups-capt_2.20-1_${ARCH}.deb"
echo "Installing driver for model: $PRINTER_MODEL"
echo "using file: CNCUPS${PRINTER_SMODEL}CAPTK.ppd"
echo "Installing packages..."
check_requirements_for_release
if [[ -e $WORKSPACE/$ARCH/$cndrv_common ]]; then
dpkg -i $WORKSPACE/$ARCH/$cndrv_common
else
echo "$cndrv_common is missing from $WORKSPACE/$ARCH folder!"
exit 1
fi
if [[ -e $WORKSPACE/$ARCH/$cndrv_capt ]]; then
dpkg -i $WORKSPACE/$ARCH/$cndrv_capt
else
echo "$cndrv_capt is missing from $WORKSPACE/$ARCH folder!"
exit 1
fi
echo "Modifying the default /etc/init.d/ccpd file..."
cp -f $WORKSPACE/ccpd /etc/init.d/
chmod a+x /etc/init.d/ccpd
echo "Restarting CUPS..."
/etc/init.d/cups restart
echo "Setting the printer for CUPS..."
/usr/sbin/lpadmin -p $PRINTER_MODEL -P /usr/share/cups/model/CNCUPS${PRINTER_SMODEL}CAPTK.ppd -v ccp://localhost:59687 -E
echo "Setting the printer for CAPT..."
if [[ -z $IP ]]; then
/usr/sbin/ccpdadmin -p $PRINTER_MODEL -o /dev/usb/lp0
else
/usr/sbin/ccpdadmin -p $PRINTER_MODEL -o "net:$IP"
fi
echo "Setting CAPT to boot with the system..."
update-rc.d ccpd defaults 50
echo "Starting ccpd..."
/etc/init.d/ccpd start
sleep 2
echo "Checking status:"
/etc/init.d/ccpd status
echo -e "\nPower on your printer! :)"
echo "Go to System - Administration - Printing and do the following:"
echo " 1. disable $PRINTER_MODEL-2 but do not delete it since Ubuntu will recreate it automatically;"
echo " 2. set $PRINTER_MODEL as your default printer;"
echo " 3. reboot your machine and print a test page."
}
exit_message() {
echo -e "Script author: \n\tRadu Cotescu"
echo -e "\thttp://radu.cotescu.com"
}
check_args
check_superuser
install_driver
exit_message
exit 0