From 5b488f5db5179a7901e7a13b7532b06cb8f5ad25 Mon Sep 17 00:00:00 2001 From: Henry Wenger-Stickel Date: Fri, 23 Jun 2023 08:55:25 -0500 Subject: [PATCH] Add uninstall --- uninstall.sh | 73 ++++++++++++++++++++++++++++------------------------ 1 file changed, 40 insertions(+), 33 deletions(-) diff --git a/uninstall.sh b/uninstall.sh index 73519ad..6676c42 100644 --- a/uninstall.sh +++ b/uninstall.sh @@ -4,41 +4,48 @@ PATH_FLAG='' while getopts 'P:' flag; do - case "${flag}" in - P) - PATH_FLAG="${OPTARG}" - INSTALL_PATH="${PATH_FLAG}" ;; - *) - echo "Error: Flag not supported." - exit ;; - esac + case "${flag}" in + P) + PATH_FLAG="${OPTARG}" + INSTALL_PATH="${PATH_FLAG}" + ;; + *) + echo "Error: Flag not supported." + exit + ;; + esac done # Locate install directory if [ -z ${INSTALL_PATH+x} ]; then - INSTALL_PATH=$(readlink -e `type -p spotify` 2>/dev/null | rev | cut -d/ -f2- | rev) - if [[ -d "${INSTALL_PATH}" && "${INSTALL_PATH}" != "/usr/bin" ]]; then - echo "Spotify directory found in PATH: ${INSTALL_PATH}" - elif [[ ! -d "${INSTALL_PATH}" ]]; then - echo -e "\nSpotify not found in PATH. Searching for Spotify directory..." - INSTALL_PATH=$(timeout 10 find / -type f -path "*/spotify*Apps/*" -name "xpui.spa" -size -7M -size +3M -print -quit 2>/dev/null | rev | cut -d/ -f3- | rev) - if [[ -d "${INSTALL_PATH}" ]]; then - echo "Spotify directory found: ${INSTALL_PATH}" - elif [[ ! -d "${INSTALL_PATH}" ]]; then - echo -e "Spotify directory not found. Set directory path with -P flag.\nExiting...\n" - exit; fi - elif [[ "${INSTALL_PATH}" == "/usr/bin" ]]; then - echo -e "\nSpotify PATH is set to /usr/bin, searching for Spotify directory..." - INSTALL_PATH=$(timeout 10 find / -type f -path "*/spotify*Apps/*" -name "xpui.spa" -size -7M -size +3M -print -quit 2>/dev/null | rev | cut -d/ -f3- | rev) - if [[ -d "${INSTALL_PATH}" && "${INSTALL_PATH}" != "/usr/bin" ]]; then - echo "Spotify directory found: ${INSTALL_PATH}" - elif [[ "${INSTALL_PATH}" == "/usr/bin" ]] || [[ ! -d "${INSTALL_PATH}" ]]; then - echo -e "Spotify directory not found. Set directory path with -P flag.\nExiting...\n" - exit; fi; fi + INSTALL_PATH=$(readlink -e $(type -p spotify) 2> /dev/null | rev | cut -d/ -f2- | rev) + if [[ -d ${INSTALL_PATH} && ${INSTALL_PATH} != "/usr/bin" ]]; then + echo "Spotify directory found in PATH: ${INSTALL_PATH}" + elif [[ ! -d ${INSTALL_PATH} ]]; then + echo -e "\nSpotify not found in PATH. Searching for Spotify directory..." + INSTALL_PATH=$(timeout 10 find / -type f -path "*/spotify*Apps/*" -name "xpui.spa" -size -7M -size +3M -print -quit 2> /dev/null | rev | cut -d/ -f3- | rev) + if [[ -d ${INSTALL_PATH} ]]; then + echo "Spotify directory found: ${INSTALL_PATH}" + elif [[ ! -d ${INSTALL_PATH} ]]; then + echo -e "Spotify directory not found. Set directory path with -P flag.\nExiting...\n" + exit + fi + elif [[ ${INSTALL_PATH} == "/usr/bin" ]]; then + echo -e "\nSpotify PATH is set to /usr/bin, searching for Spotify directory..." + INSTALL_PATH=$(timeout 10 find / -type f -path "*/spotify*Apps/*" -name "xpui.spa" -size -7M -size +3M -print -quit 2> /dev/null | rev | cut -d/ -f3- | rev) + if [[ -d ${INSTALL_PATH} && ${INSTALL_PATH} != "/usr/bin" ]]; then + echo "Spotify directory found: ${INSTALL_PATH}" + elif [[ ${INSTALL_PATH} == "/usr/bin" ]] || [[ ! -d ${INSTALL_PATH} ]]; then + echo -e "Spotify directory not found. Set directory path with -P flag.\nExiting...\n" + exit + fi + fi else - if [[ ! -d "${INSTALL_PATH}" ]]; then - echo -e "Directory path set by -P was not found.\nExiting...\n" - exit; fi; fi + if [[ ! -d ${INSTALL_PATH} ]]; then + echo -e "Directory path set by -P was not found.\nExiting...\n" + exit + fi +fi # XPUI paths XPUI_PATH="${INSTALL_PATH}/Apps" @@ -46,9 +53,9 @@ XPUI_SPA="${XPUI_PATH}/xpui.spa" XPUI_BAK="${XPUI_PATH}/xpui.bak" # Check for backup file -if [[ ! -f "${XPUI_BAK}" ]]; then - echo -e "Backup file not found.\nExiting...\n" - exit +if [[ ! -f ${XPUI_BAK} ]]; then + echo -e "Backup file not found.\nExiting...\n" + exit fi # Uninstall patch