forked from hailo-ai/tappas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuninstall.sh
executable file
·83 lines (68 loc) · 1.77 KB
/
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
78
79
80
81
82
83
#!/bin/bash
# Hailo Tappas uninstall script
# requires `sudo` privileges
set -e
#############################################
readonly GSTREAMER_DIR=core/hailo
readonly SHARK_DIR=sources/gst-shark/plugins
readonly PIP_REQUIREMENTS=core/requirements/requirements.txt
VENV_NAME=hailo_tappas_venv
#############################################
function not_installed_msg(){
echo "Hailo Tappas does not appear to be installed..."
}
function check_tappas_installed(){
rm -rf ~/.cache/gstreamer-1.0/registry.x86_64.bin && gst-inspect-1.0 hailotools &> /dev/null
}
function uninstall_gst(){
pushd $GSTREAMER_DIR
sudo env "PATH=$PATH" ninja uninstall -C build.release
popd
}
function uninstall_shark(){
if [[ -d $SHARK_DIR ]]; then
pushd $SHARK_DIR
sudo env "PATH=$PATH" ninja uninstall -C build
popd
fi
}
function create_venv(){
if [[ ! -d $VENV_NAME ]]; then
VENV_NAME=tmp_venv
python3 -m virtualenv $VENV_NAME
fi
}
function activate_venv(){
source "$VENV_NAME/bin/activate"
}
function remove_venv(){
rm -rf $VENV_NAME
}
function install_env_requirements(){
pip install -r $PIP_REQUIREMENTS
}
function uninstall_so(){
create_venv
activate_venv
install_env_requirements
uninstall_gst
uninstall_shark
deactivate
remove_venv
}
function remove_bash_autocompletion(){
if [[ ! -z $HOME && -f $HOME/.bashrc ]]; then
local tappas_bash_comp_line=$(grep -n tappas $HOME/.bashrc | grep bash_completion | cut -d':' -f1)
sed -i "${tappas_bash_comp_line}d" $HOME/.bashrc
fi
}
function main(){
check_tappas_installed && return_code=$?
if [[ $return_code == 0 ]]; then
uninstall_so
remove_bash_autocompletion
else
not_installed_msg
fi
}
main