feat: better install script, eval paths

This commit is contained in:
v4n
2025-01-15 19:52:18 +02:00
parent 087dd4561c
commit 0806594289
3 changed files with 27 additions and 4 deletions
+24 -4
View File
@@ -1,20 +1,40 @@
#!/bin/bash
set -e
RED='\033[0;31m'
NC='\033[0m'
DESTINATION_PATH="/usr/local/bin"
SCRIPT_NAME="h2mm"
if [ "$(id -u)" -eq 0 ]; then
echo "Run me as normal user, not as root."
exit 1
fi
DESTINATION_PATH="/usr/local/bin"
SCRIPT_NAME="h2mm"
echo -e "!!! ${RED}WARNING${NC} !!!"
echo -e "This script will install Helldivers 2 Mod Manager CLI for Linux to $DESTINATION_PATH/$SCRIPT_NAME."
echo -e "Running this script will require sudo permissions. ${RED}DO NOT TRUST${NC} random scripts from the internet."
echo -e "If you want to review the script before running it, check out the mod repository for yourself:"
echo -e "https://github.com/v4n00/h2mm-cli"
echo
echo "Installing $SCRIPT_NAME..."
read -p "Install the script to $DESTINATION_PATH or specify another path (must be included in \$PATH)? (Y/path): " response
if [[ "$response" != "y" && "$response" != "Y" && -n "$response" ]]; then
DESTINATION_PATH=$(eval echo "$response")
if [[ ! -d "$DESTINATION_PATH" ]]; then
echo -e "${RED}Error:${NC} Path $DESTINATION_PATH does not exist. Exiting..."
exit 1
fi
fi
echo "Installing $SCRIPT_NAME to $DESTINATION_PATH."
sudo curl https://raw.githubusercontent.com/v4n00/h2mm-cli/refs/heads/master/h2mm --output "$DESTINATION_PATH/$SCRIPT_NAME"
sudo chmod +x "$DESTINATION_PATH/$SCRIPT_NAME"
if [[ ! -x "$(command -v $SCRIPT_NAME)" ]]; then
echo "Installation failed."
echo -e "${RED}Error:${NC} Installation failed."
exit 1
fi