-
Notifications
You must be signed in to change notification settings - Fork 17
/
uninstall_ocv.sh
87 lines (79 loc) · 2.69 KB
/
uninstall_ocv.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
#!/bin/bash
#########################################################################################################
## OpenCV Uninstallation Script
##
## Code by : Dimas Toha Pramawitra (Lonehack)
## <dms.pram@gmail.com>
## Created : 20 Mar 2016
## Modified : 16 Apr 2016
##
## This code is released to the public domain.
## You can use, modify, or distribute this code as you need without any restriction.
#########################################################################################################
#################################################################################
## Distribution check
#################################################################################
if [ -f /etc/debian_version ];then
DIST="debian"
PKG=$(which dpkg)
PKGMGR=$(which apt-get)
PKGLIST=" --get-selections"
elif [ -f /etc/redhat-release ];then
DIST="redhat"
PKG=$(which rpm)
PKGMGR=$(which dnf)
if [ -z "$PKGMGR" ];then
PKGMGR=$(which yum)
fi
PKGLIST="--all"
else
echo "Your Linux Distribution not yet supported by this script"
echo "Uninstall manualy or edit this script for your need"
exit 0
fi
#################################################################################
## Initialization
#################################################################################
LIST=$($PKG $PKGLIST | grep opencv | awk '{print $1}')
VERSION=$(pkg-config --modversion opencv)
PYT=$(pkg-config --modversion python)
PFX="/usr/local/"
trap ctrl_c INT
function ctrl_c() {
echo "Terminated by User!"
exit 0
}
#################################################################################
## Uninstallation
#################################################################################
if [ -z "$VERSION" ];then
echo "OpenCV not found in pkg-config"
echo "If OpenCV was installed,"
echo "please uninstall remaining OpenCV manually"
else
echo "Uninstall OpenCV : "$VERSION
fi
read -rsp $'Are you sure? <y/N>\n' -n 1 key
if [[ "$key" =~ ^[Yy]$ ]]; then
# y pressed
echo "Uninstalling..."
if [ ! -z "$LIST" ];then
sudo $PKMGR remove $LIST
else
echo "OpenCV not found in dpkg"
echo "If OpenCV was installed,"
echo "please uninstall remaining OpenCV manually"
fi
#sudo find / -name "*opencv*" -exec rm {} \;
sudo rm -rf "$PFX"{include/opencv2,include/opencv,share/OpenCV}
sudo find "$PFX"lib -maxdepth 1 -name "libopencv*" -exec rm -f {} \;
sudo find "$PFX"bin/ -maxdepth 1 -name "opencv*" -exec rm -f {} \;
sudo find "$PFX"lib/pkgconfig -maxdepth 1 -name "opencv*" -exec rm -f {} \;
if [ ! -z "$PYT" ];then
sudo find "$PFX"lib/python$PYT/dist-packages/ -maxdepth 1 -name "cv*" -exec rm -f {} \;
fi
echo "Uninstall OpenCV done!"
else
echo "Uninstall OpenCV aborted.."
exit 0
fi