34 Commits

Author SHA1 Message Date
v4n cb71852068 fix: prompts for install script 2025-03-19 20:25:44 +02:00
v4n 26031c0381 version 0.4.0 release 2025-03-19 20:20:12 +02:00
Daedalusspacegames 9c73be1cb7 fix: modify date syntax to enhance compatibility with alternate coreutils implementations, such as [uutils](https://github.com/uutils/coreutils) (#29) 2025-03-19 12:10:17 +02:00
v4n a8e94c19fb feat: command to change load order of mods (#27)
* progress

* progress

* feat: progress

* progress

* done, needs more testing, pr -> change all functions to require -n before specifying name -> v0.4 (reindex db)

* testing done
2025-03-18 16:18:48 +02:00
v4n 6b968172ea fix: updating now works properly 2025-03-10 21:42:55 +02:00
v4n b3bc91522f do not update 2025-03-10 21:14:37 +02:00
v4n a7936c90bd fix: stop latest update 2025-03-10 21:07:03 +02:00
v4n 4d1af7e4a0 feat: modpack-create can select individual mods (#26) 2025-03-10 21:01:06 +02:00
v4n 0eff8afe6b fix: turned code into fn 2025-03-08 00:38:04 +02:00
v4n 3593e32a7b fix: upgrade mods was overwriting files 2025-03-07 23:24:30 +02:00
v4n 797739ea7a fix: uninstall correctly reindexes (fix #21) 2025-03-07 22:57:14 +02:00
v4n df006a7430 fix: infite loop while enabling (#25) 2025-03-07 18:20:34 +02:00
v4n 344e4348d4 fix: non important sed error 2025-03-06 04:09:45 +02:00
v4n 719217d00b bump: version 2025-03-06 01:29:45 +02:00
v4n b1930811f9 fix: segfault from infinite recursion 2025-03-06 01:29:14 +02:00
v4n d1ca18b563 bump: downgrade because of seg fault 2025-03-06 00:59:58 +02:00
v4n 5d91190dbf fix: code cleanup 2025-03-06 00:12:59 +02:00
v4n 28122ee332 feat: list is now compact, added verbose option 2025-03-05 19:09:57 +02:00
v4n 56bb73784e fix: directory checking in wrong place 2025-03-02 15:38:07 +02:00
v4n 0d8f22a2d0 fix: variants fix 2025-02-21 17:15:35 +02:00
v4n 3c6238f8d2 fix: show variants better 2025-02-21 16:16:42 +02:00
v4n a031230117 fix: bash black magic 2025-02-21 16:06:20 +02:00
v4n 77ae53ffa7 fix: weird update bug 2025-02-21 14:03:49 +02:00
v4n c23c57e16c fix: weird update bug 2025-02-21 14:01:36 +02:00
v4n 898400e526 fix: whitespace in help msg 2025-02-21 13:48:50 +02:00
v4n c45f5860d8 bump: version 2025-02-21 13:44:18 +02:00
v4n 838c834cc2 feat: easily install multiple variants (#20)
* feat: easily install multiple variants

* fix: filter only dirs that have patches
2025-02-21 13:16:29 +02:00
v4n 7b8b2fda8f fix: console output, formatting 2025-02-21 12:46:46 +02:00
Catherine Guelque 0485b56df5 There is no need to install in the global path nor to use SUDO if the given path was writtable (#18)
* There's no need for sudo + Added warning if not in PATH

* fix: removed duplicated command call

---------

Co-authored-by: v4n <105587619+v4n00@users.noreply.github.com>
2025-02-17 18:07:54 +02:00
v4n d18a9cdccf fix: formatting 2025-02-06 20:13:45 +02:00
v4n c74f4a8a00 fix: whitespace, version bump for earlier commit 2025-02-06 20:12:27 +02:00
Matt Cavanagh 9f592e7ce2 feat: added .editorconfig to ensure consistency across IDEs and to prevent line ending oopsies (#17) 2025-02-06 19:47:37 +02:00
v4n 21b1822006 fix: uninstall correctly downgrades 2025-02-06 19:43:30 +02:00
v4n dbcc7d1e96 fix: CRLF -> LF 2025-02-06 03:34:33 +02:00
6 changed files with 1839 additions and 1423 deletions
+6
View File
@@ -0,0 +1,6 @@
[*]
indent_style = tab
indent_size = 4
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
+6 -5
View File
@@ -1,5 +1,6 @@
* *
!h2mm !h2mm
!install.sh !install.sh
!README.md !README.md
!version !version
!.editorconfig
+165 -164
View File
@@ -1,164 +1,165 @@
# Helldivers 2 Mod Manager CLI # Helldivers 2 Mod Manager CLI
Helldivers 2 Mod Manager CLI is a command line interface for managing Helldivers 2 mods. Since there is no Linux mod manager available and I like being a nerd by using CLI tools instead of GUIs, this project was born. Helldivers 2 Mod Manager CLI is a command line interface for managing Helldivers 2 mods. Since there is no Linux mod manager available and I like being a nerd by using CLI tools instead of GUIs, this project was born.
This script is complete, the version will always [remain at 0.x.x](https://0ver.org/) This script is complete, the version will always [remain at 0.x.x](https://0ver.org/)
## Installation ## Installation
To install Helldivers 2 Mod Manager CLI run the following command in your terminal: To install Helldivers 2 Mod Manager CLI run the following command in your terminal:
```bash ```bash
bash -c "$(curl -fsSL https://raw.githubusercontent.com/v4n00/h2mm-cli/refs/heads/master/install.sh)" bash -c "$(curl -fsSL https://raw.githubusercontent.com/v4n00/h2mm-cli/refs/heads/master/install.sh)"
``` ```
> [!CAUTION] > [!CAUTION]
> 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. > 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.
If for some reason, the installation command doesn't work you can: If for some reason, the installation command doesn't work you can:
1. Go to <https://raw.githubusercontent.com/v4n00/h2mm-cli/refs/heads/master/install.sh> 1. Go to <https://raw.githubusercontent.com/v4n00/h2mm-cli/refs/heads/master/install.sh>
1. Right click -> Save page as... 1. Right click -> Save page as...
1. Go to your downloads folders `cd ~/Downloads` 1. Go to your downloads folders `cd ~/Downloads`
1. Give the script execution permissions `chmod +x install.sh` 1. Give the script execution permissions `chmod +x install.sh`
1. Run the script `./install.sh` 1. Run the script `./install.sh`
## 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.
```bash ```bash
h2mm h2mm
``` ```
### Available commands ### Available commands
- `install` - Install a mod by the file provided (directory, zip, patch). - `install` - Install a mod by the file provided (directory, zip, patch).
- `uninstall` - Uninstall a mod by name (or index). - `uninstall` - Uninstall a mod.
- `list` - List all installed mods. - `list` - List all installed mods.
- `enable` - Enable a mod by name (or index). - `enable` - Enable a mod.
- `disable` - Disable a mod by name (or index). - `disable` - Disable a mod.
- `export` - Export installed mods to a zip file. - `export` - Export installed mods to a zip file.
- `import` - Import mods from a zip file. - `import` - Import mods from a zip file.
- `modpack-create` - Create a modpack from the currently installed mods. - `order` - Change load order for a mod.
- `modpack-switch` - Switch to a modpack by name (or index). - `modpack-create` - Create a modpack from the currently installed mods.
- `modpack-list` - List all installed modpacks. - `modpack-switch` - Switch to a modpack.
- `modpack-delete` - Delete a modpack by name (or index). - `modpack-list` - List all installed modpacks.
- `modpack-overwrite` - Overwrite a modpack by name (or index). - `modpack-delete` - Delete a modpack.
- `modpack-reset` - Reset all installed modpacks. - `modpack-overwrite` - Overwrite a modpack.
- `reset` - Reset all installed mods. - `modpack-reset` - Reset all installed modpacks.
- `update` - Update h2mm to latest version. - `update` - Update h2mm to latest version.
- `help` - Display this help message. - `reset` - Reset all installed mods.
- `help` - Display this help message.
### Basic usage
### Basic usage
#### Install mod(s)
To find out how to use a command, you can run `h2mm <COMMAND> --help`.
```bash
h2mm install /path/to/mod.zip #### Install mod(s)
h2mm install /path/to/mod/files
h2mm install /path/to/mod.zip /path/to/mod2.zip /path/to/mod/files ```bash
h2mm install -n "Example mod" mod.patch_0 mod.patch_0.stream # -n is mandatory when using files h2mm install /path/to/mod.zip
h2mm install -n "Example mod" mod* # using a wildcard to include all files h2mm install /path/to/mod/files
``` h2mm install /path/to/mod.zip /path/to/mod2.zip /path/to/mod/files
h2mm install -n "Example mod" mod.patch_0 mod.patch_0.stream # -n is mandatory when using files
> [!NOTE] h2mm install -n "Example mod" mod* # using a wildcard to include all files
> If the mod has more than 1 variant, you need to install the one you want by unarchiving it separately and providing the directory. ```
#### Uninstall a mod #### Uninstall a mod
```bash ```bash
h2mm uninstall "Example mod" h2mm uninstall -n "Example mod"
h2mm uninstall -i 1 # uninstall mod with index 1 h2mm uninstall -i 3
``` ```
#### Enable/disable mods #### Enable/disable mods
```bash ```bash
h2mm enable "Example mod" h2mm enable -n "Example mod"
h2mm enable -i 1 # enable mod with index 1 h2mm enable -i 3
h2mm disable "Example mod" h2mm disable -n "Example mod"
h2mm disable -i 1 # disable mod with index 1 h2mm disable -i 3
``` ```
#### List installed mods #### List installed mods
```bash ```bash
h2mm list h2mm list
``` ```
#### Updating the script #### Updating the script
```bash ```bash
h2mm update h2mm update
``` ```
## Compatibility ## Compatibility
The script is developed and tested on Arch Linux, but it should work on other Linux distributions as well. If you encounter any issues, please open an issue on the repository. The script is developed and tested on Arch Linux, but it should work on other Linux distributions as well. If you encounter any issues, please open an issue on the repository.
Status of platforms: Status of platforms:
- Linux :white_check_mark: - Linux :white_check_mark:
- Steam Deck :white_check_mark: - Steam Deck :white_check_mark:
- Windows - WSL :white_check_mark: - Windows - WSL :white_check_mark:
> The script works on WSL, but you need to specify the path to the Helldivers 2 mods directory manually, to find your Windows partition head to `/mnt/` and from there go to your Helldivers 2 data directory, on a typical install it should be on `/mnt/c/Program\ Files\ \(x86\)/Steam/steamapps/common/Helldivers\ 2/data`. You also need to have `unzip` installed, which can be done by running `sudo apt install unzip`. > The script works on WSL, but you need to specify the path to the Helldivers 2 mods directory manually, to find your Windows partition head to `/mnt/` and from there go to your Helldivers 2 data directory, on a typical install it should be on `/mnt/c/Program\ Files\ \(x86\)/Steam/steamapps/common/Helldivers\ 2/data`. You also need to have `unzip` installed, which can be done by running `sudo apt install unzip`.
## Advanced usage ## Advanced usage
### Shortcuts ### Shortcuts
You can use the short form of commands to save some time. The shortcuts are: You can use the short form of commands to save some time. The shortcuts are:
- `i` for `install` - `i` for `install`
- `u` for `uninstall` - `u` for `uninstall`
- `e` for `enable` - `e` for `enable`
- `d` for `disable` - `d` for `disable`
- `l` for `list` - `l` for `list`
- `ex` for `export` - `ex` for `export`
- `im` for `import` - `im` for `import`
- `mc` for `modpack-create` - `o` for `order`
- `ms` for `modpack-switch` - `mc` for `modpack-create`
- `ml` for `modpack-list` - `ms` for `modpack-switch`
- `md` for `modpack-delete` - `ml` for `modpack-list`
- `mo` for `modpack-overwrite` - `md` for `modpack-delete`
- `mr` for `modpack-reset` - `mo` for `modpack-overwrite`
- `r` for `reset` - `mr` for `modpack-reset`
- `up` for `update` - `up` for `update`
- `r` for `reset`
### Modpacks support
### Modpacks support
You can set up modpacks by using the `modpack-*` commands. This allows you to quickly change between a set of mods. For more information, check the help message.
You can set up modpacks by using the `modpack-*` commands. This allows you to quickly change between a set of mods. For more information, check the help message.
```bash
h2mm modpack-create "Modpack 1" ```bash
# install, enable, disable other mods... h2mm modpack-create -n "Modpack 1"
h2mm modpack-create "Modpack 2" # install, enable, disable other mods...
h2mm modpack-switch "Modpack 1" h2mm modpack-create -n "Modpack 2"
``` h2mm modpack-switch -n "Modpack 1"
```
### Exporting and importing
### Exporting and importing
You can export all installed mods to a zip file and import mods from the same file. This can be useful for sharing mods with others or for backing up your mods. The archive file (`.tar.gz`) will be saved in the current directory.
You can export all installed mods to a zip file and import mods from the same file. This can be useful for sharing mods with others or for backing up your mods. The archive file (`.tar.gz`) will be saved in the current directory.
```bash
h2mm export modpack1.zip ```bash
h2mm import modpack2.zip h2mm export
``` h2mm import /path/to/mods.tar.gz
```
### Resetting all installed mods
### Resetting all installed mods
You can reset all installed mods by running the following command. This will remove all installed mods and the database, in case things go wild.
You can reset all installed mods by running the following command. This will remove all installed mods and the database, in case things go wild.
```bash
h2mm reset ```bash
``` h2mm reset
```
### Database location and details
### Database location and details
The database is stored in the `Helldivers 2` install directory, under the `data` folder with the name `mods.csv`, where the mods are also installed. The database is a simple CSV file which you can use to manually manage mods if needed, you can mostly use it to rename or reorder mods.
The database is stored in the `Helldivers 2` install directory, under the `data` folder with the name `mods.csv`, where the mods are also installed. The database is a simple CSV file which you can use to manually manage mods if needed, you can mostly use it to rename or reorder mods.
## Contributing
## Contributing
Feel free to contribute to this project by creating a pull request or opening an issue.
Feel free to contribute to this project by creating a pull request or opening an issue.
+1485 -1107
View File
File diff suppressed because it is too large Load Diff
+176 -146
View File
@@ -1,146 +1,176 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -e set -e
RED='\033[0;31m' RED='\033[0;31m'
GREEN='\033[0;32m' GREEN='\033[0;32m'
ORANGE='\033[0;33m' ORANGE='\033[0;33m'
NC='\033[0m' NC='\033[0m'
DESTINATION_PATH="/usr/local/bin" DESTINATION_PATH="/usr/local/bin"
SCRIPT_NAME="h2mm" SCRIPT_NAME="h2mm"
REPO_URL="https://raw.githubusercontent.com/v4n00/h2mm-cli/refs/heads/master" REPO_URL="https://raw.githubusercontent.com/v4n00/h2mm-cli/refs/heads/master"
if [ "$(id -u)" -eq 0 ]; then function log() {
echo "Run me as normal user, not as root." local type="$1"
exit 1 shift
fi case "$type" in
INFO)
# --- Main --- echo -e "$*" >&2
;;
# Warning ERROR)
echo -e "${RED}[ERROR]${NC} $*" >&2
echo -e "!!! ${RED}WARNING${NC} !!!" ;;
echo -e "This script will install Helldivers 2 Mod Manager CLI for Linux to $DESTINATION_PATH/$SCRIPT_NAME." PROMPT)
echo -e "Running this script will require sudo permissions. ${RED}DO NOT TRUST${NC} random scripts from the internet." echo -ne "$*" >&2
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" esac
echo -e "!!! ${RED}WARNING${NC} !!!" }
echo
# --- Main ---
# Check if update
# warning
# Breaking changes hash table
cat << EOF
breaking_changes_patches=( !!! WARNING !!!
["2"]='sed -i "s/^\([0-9]\+\),/\1,ENABLED,/" "$1/mods.csv"' This script will install Helldivers 2 Mod Manager CLI for Linux to $DESTINATION_PATH/$SCRIPT_NAME.
["3"]='sed -i "1 i\\3" "$1/mods.csv"' 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:
https://github.com/v4n00/h2mm-cli
# Handle breaking changes !!! WARNING !!!
if [[ -x "$(command -v $SCRIPT_NAME)" ]]; then EOF
installed_version=$($SCRIPT_NAME --version)
# version 1 show the help message, if the first character is not a 0, store installed version as 0.1.6 # breaking changes hash table
[[ ${installed_version:0:1} != "0" ]] && { installed_version="0.1.6"; } breaking_changes_patches=(
["2"]='sed -i "s/^\([0-9]\+\),/\1,ENABLED,/" "$1/mods.csv"'
latest_version=$(curl -sS "$REPO_URL"/version) ["3"]='sed -i "1 i\\3" "$1/mods.csv"'
if [[ "$latest_version" == "$installed_version" ]]; then ["4"]='awk '\''BEGIN {FS=OFS=","} NR==1 {print 4; next} {print NR-1, $2, $3, $4, $5}'\'' "$1/mods.csv" | tee "$1/mods.csv" > /dev/null'
echo -e "You are reinstalling version $installed_version." )
else
echo -e "You are upgrading from ${ORANGE}$installed_version${NC} -> ${GREEN}$latest_version${NC}." # notify if update is happening
fi installed_version=""
latest_version=""
# split version numbers if [[ -x "$(command -v $SCRIPT_NAME)" ]]; then
installed_major="" installed_version=$($SCRIPT_NAME --version)
latest_major=""
IFS='.' read -r _1 installed_major _2 <<< "$installed_version" # if installed version isn't x.x.x crash
IFS='.' read -r _1 latest_major _2 <<< "$latest_version" if [[ ! "$installed_version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
log ERROR "Installed version is not in the correct format."
if [[ $latest_major -gt $installed_major ]]; then log ERROR "h2mm is installed here -> $(which h2mm)"
echo -e "${ORANGE}Warning:${NC} Major version upgrade detected." log ERROR "Delete the script file and retry the install script, any mods installed will not be lost."
echo "${ORANGE}Info${NC}: Check out the changelogs here -> https://github.com/v4n00/h2mm-cli/releases" exit 1
echo "The script will proceed to upgrade ${SCRIPT_NAME} to avoid breaking changes." fi
# find hd2 path latest_version=$(curl -sS "$REPO_URL"/version)
search_dir="${HOME}" if [[ "$latest_version" == "$installed_version" ]]; then
target_dir="Steam/steamapps/common/Helldivers\ 2/data" log INFO "You are reinstalling version ${GREEN}$installed_version${NC}."
echo "Searching for the Helldivers 2 data directory... (20 seconds timeout)" >&2 else
log INFO "You are upgrading from ${ORANGE}$installed_version${NC} -> ${GREEN}$latest_version${NC}."
game_dir=$(timeout 20 find "$search_dir" -type d -path "*/$target_dir" 2>/dev/null | head -n 1) fi
if [[ -z "$game_dir" ]]; then fi
echo "Could not find the Helldivers 2 data directory automatically." >&2
IFS= read -ep "Please enter the path to the Helldivers 2 data directory: " game_dir # if steam deck, set destination path to ~/.local/bin
if [[ ! -d "$game_dir" ]]; then log PROMPT "Are you installing on a Steam Deck? (y/N): "
echo -e "${RED}Error${NC}: Provided path is not a valid directory." >&2 IFS= read -e response_sd
exit 1
fi if [[ "$response_sd" == "y" || "$response_sd" == "Y" ]]; then
fi # steam deck
DESTINATION_PATH="$HOME/.local/bin"
[[ ! -f "$game_dir/mods.csv" ]] && { echo -e "${RED}Error:${NC} mods.csv not found in $game_dir."; exit 1; } mkdir -p "$DESTINATION_PATH"
# make backup of mods in case something goes wrong # check if ~/.local/bin is in PATH
echo "${ORANGE}V${NC} It is advised to make a backup before proceeding." if [[ ":$PATH:" != *":$HOME/.local/bin:"* ]]; then
h2mm export # add ~/.local/bin to PATH
log INFO "Installing the script on a Steam Deck means adding $DESTINATION_PATH to your \$PATH."
# iterate from installed major number to latest major number log INFO "If you're using a different shell than bash, you may need to add it manually."
for ((i = installed_major + 1; i <= latest_major; i++)); do
if [[ -n "${breaking_changes_patches[$i]}" ]]; then log PROMPT "Do you want to add $DESTINATION_PATH to your \$PATH in ~/.bashrc? (Y/n): "
eval $(echo "${breaking_changes_patches[$i]}" | sed "s:\$1:$game_dir:") IFS= read -e response
else if [[ "$response" == "y" || "$response" = "Y" || -z "$response" ]]; then
echo "No breaking changes for version $i." echo "export PATH=\"\$HOME/.local/bin:\$PATH\"" >> "$HOME/.bashrc"
fi
if [[ $? -ne 0 ]]; then [[ $? -ne 0 ]] && { log ERROR "Failed to add $DESTINATION_PATH to \$PATH in ~/.bashrc." ; exit 1; }
echo -ne "${RED}Error:${NC} Failed to apply breaking changes patch for version $i. Do you want to continue? (Y/n): " log INFO "Added $DESTINATION_PATH to your \$PATH in ~/.bashrc."
read -er response fi
fi
[[ "$response" != "y" && "$response" != "Y" && -n "$response" ]] && { echo "Exiting. Uninstall the script first the retry the install script."; exit 1; } else
else # not steam deck
echo -e "Breaking changes patch for version ${ORANGE}$i${NC} applied ${GREEN}successfully${NC}." # set another path if needed
fi log PROMPT "Install the script to $DESTINATION_PATH or specify another path (must be included in \$PATH)? (Y/path): "
done IFS= read -e response
fi
echo if [[ "$response" != "y" && "$response" != "Y" && -n "$response" ]]; then
fi DESTINATION_PATH="$response"
[[ ! -d "$DESTINATION_PATH" ]] && { log ERROR "Path $DESTINATION_PATH does not exist." ; exit 1; }
# Install fi
fi
# if steam deck, set destination path to ~/.local/bin
IFS= read -ep "Are you installing on a Steam Deck? (y/N): " response_sd # handle breaking changes
if [[ "$response_sd" == "y" || "$response_sd" == "Y" ]]; then installed_major=$(echo "$installed_version" | awk -F. '{print $2}')
# steam deck latest_major=$(echo "$latest_version" | awk -F. '{print $2}')
DESTINATION_PATH="$HOME/.local/bin"
mkdir -p "$DESTINATION_PATH" if [[ $latest_major -gt $installed_major ]]; then
log INFO ""
# check if ~/.local/bin is in PATH log INFO "Major version upgrade detected."
if [[ ":$PATH:" != *":$HOME/.local/bin:"* ]]; then log INFO "Check out the changelogs here -> https://github.com/v4n00/h2mm-cli/releases"
# add ~/.local/bin to PATH log INFO "The script will proceed to upgrade the database file to avoid breaking changes."
echo -e "${ORANGE}Warning:${NC} Installing the script on a Steam Deck means adding $DESTINATION_PATH to your \$PATH."
echo -e "${ORANGE}Warning:${NC} If you're using a different shell, you may need to add it manually." # find hd2 path
search_dir="${HOME}"
IFS= read -ep "Do you want to add $DESTINATION_PATH to your \$PATH in ~/.bashrc? (Y/n): " response target_dir="Steam/steamapps/common/Helldivers\ 2/data"
if [[ "$response" == "y" || "$response" = "Y" || -z "$response" ]]; then
echo "export PATH=\"\$HOME/.local/bin:\$PATH\"" >> "$HOME/.bashrc" # check if game directory is in ~/.config/h2mm/h2path
echo -e "${GREEN}Success:${NC} Added $DESTINATION_PATH to your \$PATH in ~/.bashrc." if [[ -f "$HOME/.config/h2mm/h2path" ]]; then
fi game_dir=$(cat "$HOME/.config/h2mm/h2path")
fi [[ ! -d "$game_dir" ]] && { log ERROR "Helldivers 2 data directory in ~/.config/h2mm/h2path is not a valid directory." ; exit 1; }
else
# not steam deck log INFO "Helldivers 2 data directory found: $game_dir."
# set another path if needed else
IFS= read -ep "Install the script to $DESTINATION_PATH or specify another path (must be included in \$PATH)? (Y/path): " response log INFO "Searching for the Helldivers 2 data directory... (20 seconds timeout)"
game_dir=$(timeout 20 find "$search_dir" -type d -path "*/$target_dir" 2>/dev/null | head -n 1)
if [[ "$response" != "y" && "$response" != "Y" && -n "$response" ]]; then fi
DESTINATION_PATH="$response"
[[ ! -d "$DESTINATION_PATH" ]] && { echo -e "${RED}Error:${NC} Path $DESTINATION_PATH does not exist."; exit 1; } # if not found, prompt user
fi if [[ -z "$game_dir" ]]; then
fi log INFO "Could not find the Helldivers 2 data directory automatically."
log PROMPT "Please enter the path to the Helldivers 2 data directory: "
echo "Installing $SCRIPT_NAME to $DESTINATION_PATH." IFS= read -e game_dir
sudo curl "$REPO_URL"/h2mm --output "$DESTINATION_PATH/$SCRIPT_NAME" if [[ ! -d "$game_dir" ]]; then
sudo chmod +x "$DESTINATION_PATH/$SCRIPT_NAME" log ERROR "Provided path is not a valid directory."
exit 1
if [[ ! -x "$(command -v $SCRIPT_NAME)" ]]; then fi
echo -e "${RED}Error:${NC} Installation failed." fi
exit 1
fi [[ ! -f "$game_dir/mods.csv" ]] && { log ERROR "mods.csv not found in $game_dir." ; exit 1; }
echo "Helldivers 2 Mod Manager CLI installed successfully to $DESTINATION_PATH/$SCRIPT_NAME. Use it by running '$SCRIPT_NAME'." # iterate from installed major number to latest major number
for ((i = installed_major + 1; i <= latest_major; i++)); do
if [[ -n "${breaking_changes_patches[$i]}" ]]; then
# apply breaking changes patch
eval $(echo "${breaking_changes_patches[$i]}" | sed "s:\$1:$game_dir:g")
else
log INFO "No breaking changes for version $i."
continue
fi
if [[ $? -ne 0 ]]; then
log ERROR "Failed to apply breaking changes patch for version $i. Do you want to continue? (Y/n): "
read -er response
[[ "$response" != "y" && "$response" != "Y" && -n "$response" ]] && { log INFO "Exiting." ; exit 1; }
else
log INFO "Version upgrade fix ${GREEN}successfully${NC} applied for version $i."
fi
done
log INFO ""
fi
# install
log INFO "Installing $SCRIPT_NAME to $DESTINATION_PATH."
sudo curl "$REPO_URL"/h2mm --output "$DESTINATION_PATH/$SCRIPT_NAME"
sudo chmod +x "$DESTINATION_PATH/$SCRIPT_NAME"
log INFO ""
[[ ! -x "$(command -v $SCRIPT_NAME)" ]] && { log ERROR "Installation failed. Mod manager was not found in \$PATH." ; exit 1; }
log INFO "Helldivers 2 Mod Manager CLI ${GREEN}successfully${NC} installed: $DESTINATION_PATH/$SCRIPT_NAME."
log INFO "Use it by running '$SCRIPT_NAME'. Made with love <3 by v4n and contributors."
+1 -1
View File
@@ -1 +1 @@
0.3.5 0.4.0