api install needed sudo (#34)
[platform/adaptation/npu/intel-libmvnc.git] / uninstall.sh
1 #!/bin/bash
2 #
3 # Movidius Neural Compute Toolkit uninstall script.
4 #
5 # Function main at the bottom calls all of the other functions required to uninstall.
6
7 # Please provide feedback in our support forum if you encountered difficulties.
8 ################################################################################
9 # read in functions shared by installer and uninstaller
10 source $(dirname "$0")/install-utilities.sh
11
12 # remove_NCSDK_from_PYTHONPATH - removes PYTHONPATH from $HOME/.bashrc
13 function remove_NCSDK_from_PYTHONPATH()
14 {
15     [ "${VERBOSE}" = "yes" ] && printf "Remove NCSDK references from PYTHONPATH..."
16     #sed -i "\#export PYTHONPATH=\"\${PYTHONPATH}:"${PREV_NCSDK_PATH}"/mvnc/python\"#d" $HOME/.bashrc
17     sed -i "\#export PYTHONPATH=\"\${PYTHONPATH}:"${PREV_NCSDK_PATH}"/caffe/python\"#d" $HOME/.bashrc
18     # Remove some of the older versions of this as well
19     sed -i "\#export PYTHONPATH=\$env:\""${PREV_NCSDK_PATH}"/mvnc/python\":\$PYTHONPATH#d" $HOME/.bashrc
20     sed -i "\#export PYTHONPATH=\$env:\""${PREV_NCSDK_PATH}"/caffe/python\":\$PYTHONPATH#d" $HOME/.bashrc
21     [ "${VERBOSE}" = "yes" ] && printf "done\n"    
22 }
23
24
25 # remove_caffe - remove version of caffe built during the install
26 function remove_caffe()
27 {
28     [ "${VERBOSE}" = "yes" ] && printf "Removing ${INSTALL_DIR}/${CAFFE_FLAVOR}-caffe..."
29     # remove caffe directory
30     check_and_remove_files ${INSTALL_DIR}/${CAFFE_FLAVOR}-caffe
31     # remove caffe soft link
32     check_and_remove_file ${INSTALL_DIR}/caffe
33     [ "${VERBOSE}" = "yes" ] && printf "done\n"         
34 }
35
36
37 # remove_install_dir - remove ${INSTALL_DIR} if ${NCSDK1_ARCHIVE_DIR} doesn't exist, the dir NCSDK 1.x files were moved to
38 function remove_install_dir()
39 {
40     if [ -d ${NCSDK1_ARCHIVE_DIR} ] ; then
41         echo ""
42         echo -e "${YELLOW}Warning: Detected an NCSDK 1.x backup directory at ${NCSDK1_ARCHIVE_DIR}"        
43         read -p "Delete this directory (y/n) ? " CONTINUE
44         echo -e "${NC}"        
45         if [[ "$CONTINUE" = "y" || "$CONTINUE" = "Y" ]]; then
46             echo "Based on user input, will remove ${NCSDK1_ARCHIVE_DIR}"
47             ${SUDO_PREFIX} rm -rf ${NCSDK1_ARCHIVE_DIR}
48         else
49             # if user wants to keep ${NCSDK1_ARCHIVE_DIR}, don't rm ${INSTALL_DIR}
50             echo "Not removing ${INSTALL_DIR} because ${NCSDK1_ARCHIVE_DIR} exists, the directory where NCSDK 1.x files were moved to"
51             return
52         fi
53     fi
54     [ "${VERBOSE}" = "yes" ] && printf "Removing ${INSTALL_DIR}/..."
55     check_and_remove_files ${INSTALL_DIR}
56     [ "${VERBOSE}" = "yes" ] && printf "done\n"
57 }
58
59
60 # main - this is the main function that runs the uninstall
61 function main()
62 {
63     echo "Movidius Neural Compute Toolkit uninstall"
64
65     ### get constants, function is in install-utilities.sh
66     initialize_constants
67
68     ### ask for sudo priviledges, function is in install-utilities.sh
69     ask_sudo_permissions
70
71     ### function is in install-utilities.sh
72     read_ncsdk_config
73
74     # override value in ncsdk.config for uninstall
75     VERBOSE=yes
76     
77     ### function is in install-utilities.sh
78     find_previous_install
79     
80     ### remove prev installation. Function is in install-utilities.sh
81     remove_previous_install
82
83     ### edit $HOME/.bashrc
84     remove_NCSDK_from_PYTHONPATH
85
86     ### remove version of caffe that installer installed
87     remove_caffe
88
89     remove_install_dir
90     echo "Movidius Neural Compute Toolkit uninstall finished"
91 }
92 main