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
+2
View File
@@ -25,6 +25,8 @@ To install/update Helldivers 2 Mod Manager CLI run the following command in your
sh -c "$(curl -fsSL https://raw.githubusercontent.com/v4n00/h2mm-cli/refs/heads/master/install.sh)"
```
Running this script will require sudo permissions. **DO NOT TRUST** random scripts from the internet. If you want to review the script before running it, check out the mod repository for yourself.
## Usage
The script gets added to `/usr/local/bin/h2mm` and can be used by running `h2mm` in your shell, which will show the help message explaining how to use the script.
+1
View File
@@ -46,6 +46,7 @@ function find_game_directory() {
if [[ -z "$game_dir" ]]; then
echo "Could not find the Helldivers 2 data directory automatically." >&2
read -p "Please enter the path to the Helldivers 2 data directory: " game_dir
game_dir=$(eval echo "$game_dir")
if [[ ! -d "$game_dir" ]]; then
echo -e "${RED}Error${NC}: Provided path is not a valid directory." >&2
exit 1
+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