From 9774c9bccbd1be62599af820908b36139565a822 Mon Sep 17 00:00:00 2001 From: mollusk Date: Thu, 7 Oct 2021 11:06:38 -0700 Subject: [PATCH] d2-setup.sh: error handling and help --- d2-setup.sh | 53 +++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 41 insertions(+), 12 deletions(-) diff --git a/d2-setup.sh b/d2-setup.sh index db6e673..536ac2b 100755 --- a/d2-setup.sh +++ b/d2-setup.sh @@ -1,23 +1,48 @@ #!/bin/bash -echo "NOTICE: Currently you must move & rename the installer directories to the following:" -echo "Base Game: ${HOME}/D2" -echo "Expansion: ${HOME}/LOD" -echo "Then run this script with the following option:" -echo "${0} -a" -echo "The script will then kick off the process of grabbing debs, setting the prefix and installing the game." -echo "User intervention is required to click through the installer setups" +# Colors +RED='\033[0;31m' +LRED="\033[1;31m" +BLUE="\033[0;34m" +LBLUE="\033[1;34m" +GREEN="\033[0;32m" +LGREEN="\033[1;32m" +YELLOW="\033[1;33m" +CYAN="\033[0;36m" +LCYAN="\033[1;36m" +PURPLE="\033[0;35m" +LPURPLE="\033[1;35m" +BWHITE="\e[1m" +NC='\033[0m' # No Color + + + + + # Wine Prefix Environment PREFIX="/home/$USER/diablo" ARCH="win32" +notice(){ + echo -e "${YELLOW}NOTICE: Currently you must move & rename the installer directories to the following: ${NC}\n" + echo -e "${LCYAN}Base Game: ${HOME}/D2${NC}" + echo -e "${LCYAN}Expansion: ${HOME}/LOD${NC}" + echo -e "${YELLOW}\nThen run this script with the following option:${NC}" + echo -e "${LCYAN}${0} -a${NC}" + echo -e "${YELLOW}\nThe script will then kick off the process of grabbing debs, setting the prefix and installing the game.${NC}" + echo -e "${YELLOW}User intervention is required to click through the installer setups${NC}" +} + installD2(){ + notice + read -n 1 -p "~~~~~~ Press enter to continue ~~~~~~" + D2_INSTALLER_PATH="/home/$USER/D2" - echo -e "\nInstalling Diablo II...\n" + echo -e "\n${LGREEN}Installing Diablo II...${NC}\n" if [ ! -d "${D2_INSTALLER_PATH}" ];then echo -e "${D2_INSTALLER_PATH} not found, edit script and set correct path\n" @@ -31,6 +56,10 @@ installD2(){ } installLOD(){ + + notice + read -n 1 -p "~~~~~~ Press enter to continue ~~~~~~" + LOD_INSTALLER_PATH="/home/$USER/LOD" echo -e "\nInstalling Diablo II: Lord of Destruction...\n" @@ -91,11 +120,11 @@ getGlide(){ } runGame(){ - cd "${PREFIX}/drive_c/"Program Files"/"Diablo II"/" || exit 1 + cd "${PREFIX}/drive_c/Program Files/Diablo II/" || exit 1 - echo -n -e "\nRun game now?(Y/n): " - read choice + echo -n -e "\n${LGREEN}Run game now?(Y/n): ${NC}" + read -r choice if [ "${choice}" = "n" ];then exit 0; @@ -109,7 +138,7 @@ runGame(){ run_glide(){ - cd "${PREFIX}/drive_c/"Program Files"/"Diablo II"/" || exit 1 + cd "${PREFIX}/drive_c/Program Files/Diablo II/" || exit 1 WINEPREFIX="${PREFIX}" WINEARCH="${ARCH}" wine "glide-init.exe"