-
Notifications
You must be signed in to change notification settings - Fork 11
/
canonLBP_uninstall.sh
executable file
·78 lines (71 loc) · 2.13 KB
/
canonLBP_uninstall.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
#!/bin/bash
################################################################################
# This script will help you uninstall Canon CAPT Printer Driver from a Debian #
# based Linux distribution. #
# #
# @author Radu Cotescu #
# @version 2.4 #
# #
# For more details please visit: #
# http://radu.cotescu.com/?p=1194 #
################################################################################
param="$1"
param_no="$#"
display_usage() {
echo "Usage: ./`basename $0` [-h, --help]"
}
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 -gt 1 ]]; then
display_usage
exit 1
fi
if [[ "$param" == "-h" || "$param" == "--help" ]]; then
display_usage
exit 0
fi
if [[ -n $param ]]; then
echo "Error: Unkown parameter!"
display_usage
exit 1
fi
}
uninstall() {
if [[ -e "/usr/sbin/ccpdadmin" ]]; then
installed_model=`ccpdadmin | grep LBP | awk '{print $3}'`
if [[ -n $installed_model ]]; then
echo "Found printer model $installed_model..."
echo "Stopping ccpd daemon..."
/etc/init.d/ccpd stop
echo "Removing printer from ccpdadmin..."
ccpdadmin -x $installed_model
echo "Removing printer from lpadmin..."
lpadmin -x $installed_model
echo "Removing driver..."
dpkg -P cndrvcups-capt
dpkg -P cndrvcups-common
echo "Removing runlevel scripts..."
update-rc.d ccpd remove
echo "Cleaning redundant packages..."
apt-get -y autoremove
echo "Done!"
fi
else
echo "Canon CAPT printer driver not found."
fi
}
exit_message() {
echo -e "Script author: \n\tRadu Cotescu"
echo -e "\thttp://radu.cotescu.com"
}
check_args
check_superuser
uninstall
exit_message
exit 0