feat: better install script, eval paths
This commit is contained in:
@@ -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)"
|
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
|
## 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.
|
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.
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ function find_game_directory() {
|
|||||||
if [[ -z "$game_dir" ]]; then
|
if [[ -z "$game_dir" ]]; then
|
||||||
echo "Could not find the Helldivers 2 data directory automatically." >&2
|
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
|
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
|
if [[ ! -d "$game_dir" ]]; then
|
||||||
echo -e "${RED}Error${NC}: Provided path is not a valid directory." >&2
|
echo -e "${RED}Error${NC}: Provided path is not a valid directory." >&2
|
||||||
exit 1
|
exit 1
|
||||||
|
|||||||
+24
-4
@@ -1,20 +1,40 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
RED='\033[0;31m'
|
||||||
|
NC='\033[0m'
|
||||||
|
|
||||||
|
DESTINATION_PATH="/usr/local/bin"
|
||||||
|
SCRIPT_NAME="h2mm"
|
||||||
|
|
||||||
if [ "$(id -u)" -eq 0 ]; then
|
if [ "$(id -u)" -eq 0 ]; then
|
||||||
echo "Run me as normal user, not as root."
|
echo "Run me as normal user, not as root."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
DESTINATION_PATH="/usr/local/bin"
|
echo -e "!!! ${RED}WARNING${NC} !!!"
|
||||||
SCRIPT_NAME="h2mm"
|
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 curl https://raw.githubusercontent.com/v4n00/h2mm-cli/refs/heads/master/h2mm --output "$DESTINATION_PATH/$SCRIPT_NAME"
|
||||||
sudo chmod +x "$DESTINATION_PATH/$SCRIPT_NAME"
|
sudo chmod +x "$DESTINATION_PATH/$SCRIPT_NAME"
|
||||||
|
|
||||||
if [[ ! -x "$(command -v $SCRIPT_NAME)" ]]; then
|
if [[ ! -x "$(command -v $SCRIPT_NAME)" ]]; then
|
||||||
echo "Installation failed."
|
echo -e "${RED}Error:${NC} Installation failed."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user