| #!/bin/bash |
| # |
| # Uninstalls device manager from the local machine. |
| # |
| # Usage: |
| # |
| # ./dmuninstall <install parent dir> |
| |
| set -e |
| |
| usage() { |
| echo "usage:" |
| echo "./dmuninstall [--single_user] <install parent dir>" |
| } |
| |
| main() { |
| if [[ "$1" == "--single_user" ]]; then |
| local -r SINGLE_USER=true |
| shift |
| else |
| local -r SINGLE_USER=false |
| fi |
| local -r INSTALL_PARENT_DIR="$1" |
| if [[ -z "${INSTALL_PARENT_DIR}" ]]; then |
| echo 'No local install directory specified!' |
| usage |
| exit 1 |
| fi |
| shift |
| local -r INSTALL_DIR="${INSTALL_PARENT_DIR}/device_manager" |
| if [[ ! -d "${INSTALL_DIR}" ]]; then |
| echo "${INSTALL_DIR} does not exist or is not a directory!" |
| exit 1 |
| fi |
| |
| # Tell the device manager to uninstall itself. |
| local -r DM_ROOT="${INSTALL_DIR}/dmroot" |
| echo "Uninstalling device manager from ${DM_ROOT} ..." |
| |
| local -r BIN_INSTALL="${INSTALL_DIR}/bin" |
| |
| VEYRON_DM_CURRENT="${INSTALL_DIR}/deviced.curr" VEYRON_DM_ROOT="${DM_ROOT}" \ |
| VEYRON_DM_HELPER="unused" "${BIN_INSTALL}/deviced" uninstall |
| echo "Device manager uninstalled." |
| |
| if [[ ${SINGLE_USER} == false ]]; then |
| sudo rm -rf "${INSTALL_DIR}" |
| else |
| rm -rf "${INSTALL_DIR}" |
| fi |
| echo "Removed ${INSTALL_DIR}" |
| } |
| |
| main "$@" |