Compare commits
68 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 146b711a9b | |||
| 5aafd2f16b | |||
| c30d2a46a5 | |||
| b6e92e2918 | |||
| afbb6d3a0c | |||
| f87b2709b0 | |||
| 7666638328 | |||
| 5f7f2a261a | |||
| efe8720507 | |||
| cb71852068 | |||
| 26031c0381 | |||
| 9c73be1cb7 | |||
| a8e94c19fb | |||
| 6b968172ea | |||
| b3bc91522f | |||
| a7936c90bd | |||
| 4d1af7e4a0 | |||
| 0eff8afe6b | |||
| 3593e32a7b | |||
| 797739ea7a | |||
| df006a7430 | |||
| 344e4348d4 | |||
| 719217d00b | |||
| b1930811f9 | |||
| d1ca18b563 | |||
| 5d91190dbf | |||
| 28122ee332 | |||
| 56bb73784e | |||
| 0d8f22a2d0 | |||
| 3c6238f8d2 | |||
| a031230117 | |||
| 77ae53ffa7 | |||
| c23c57e16c | |||
| 898400e526 | |||
| c45f5860d8 | |||
| 838c834cc2 | |||
| 7b8b2fda8f | |||
| 0485b56df5 | |||
| d18a9cdccf | |||
| c74f4a8a00 | |||
| 9f592e7ce2 | |||
| 21b1822006 | |||
| dbcc7d1e96 | |||
| 09c40aa25f | |||
| 1a01034816 | |||
| 83e2161456 | |||
| a2b904caa2 | |||
| 9f622ca130 | |||
| 0ab273977e | |||
| 388afe69b7 | |||
| 3f0305c741 | |||
| 1a6a13a621 | |||
| 23cb0646bf | |||
| 6768cab391 | |||
| 35902f1f8f | |||
| 55f382a8e5 | |||
| c1785b5323 | |||
| 115e8acac3 | |||
| 8b06d76c31 | |||
| fc7ccc2f7c | |||
| f763d96797 | |||
| 83260e9961 | |||
| 36fc676ce0 | |||
| 911a9b86ff | |||
| f9c047078d | |||
| c80812476b | |||
| 740b0edd98 | |||
| cc91661663 |
@@ -0,0 +1,6 @@
|
|||||||
|
[*]
|
||||||
|
indent_style = tab
|
||||||
|
indent_size = 4
|
||||||
|
end_of_line = lf
|
||||||
|
insert_final_newline = true
|
||||||
|
trim_trailing_whitespace = true
|
||||||
+6
-5
@@ -1,5 +1,6 @@
|
|||||||
*
|
*
|
||||||
!h2mm
|
!h2mm
|
||||||
!install.sh
|
!install.sh
|
||||||
!README.md
|
!README.md
|
||||||
!version
|
!version
|
||||||
|
!.editorconfig
|
||||||
|
|||||||
@@ -1,135 +1,134 @@
|
|||||||
# Helldivers 2 Mod Manager CLI
|
# Helldivers 2 Mod Manager CLI
|
||||||
|
|
||||||
- [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.
|
||||||
- [Installation](#installation)
|
|
||||||
- [Usage](#usage)
|
This script is complete, the version will always [remain at 0.x.x](https://0ver.org/)
|
||||||
- [Available commands](#available-commands)
|
|
||||||
- [Basic usage](#basic-usage)
|
## Installation
|
||||||
- [Install a mod](#install-a-mod)
|
|
||||||
- [Uninstall a mod](#uninstall-a-mod)
|
Pre-requisites:
|
||||||
- [Enable/disable mods](#enabledisable-mods)
|
|
||||||
- [List installed mods](#list-installed-mods)
|
- You must have the `unzip` package installed for zip archives;
|
||||||
- [Advanced usage](#advanced-usage)
|
- You might want to have the `unarchiver` package installed for rar archives.
|
||||||
- [Shortcuts](#shortcuts)
|
|
||||||
- [Exporting and importing](#exporting-and-importing)
|
> The `unzip` package comes pre-installed on most Linux distributions. If you do not know how to install packages, search for your Linux distro and package manager.
|
||||||
- [Resetting all installed mods](#resetting-all-installed-mods)
|
|
||||||
- [Database location and details](#database-location-and-details)
|
To install Helldivers 2 Mod Manager CLI run the following command in your terminal:
|
||||||
- [Contributing](#contributing)
|
|
||||||
- [Planned features](#planned-features)
|
```bash
|
||||||
|
bash -c "$(curl -fsSL https://raw.githubusercontent.com/v4n00/h2mm-cli/refs/heads/master/install.sh)"
|
||||||
Helldivers 2 Mod Manager CLI is a command line interface for managing Helldivers 2 mods. Since there is no mod manager GUI for Helldivers 2 on Linux yet, this small script aims to provide a simple way to manage mods on Linux.
|
```
|
||||||
|
|
||||||
## Installation
|
> [!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.
|
||||||
To install/update Helldivers 2 Mod Manager CLI run the following command in your terminal:
|
|
||||||
|
If for some reason, the installation command doesn't work you can:
|
||||||
```bash
|
|
||||||
sh -c "$(curl -fsSL 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. Open your terminal
|
||||||
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.
|
1. Go to your downloads folders with `cd ~/Downloads`
|
||||||
|
1. Give the script execution permissions `chmod +x install.sh`
|
||||||
## Usage
|
1. Run the script `./install.sh`
|
||||||
|
|
||||||
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.
|
## Usage
|
||||||
|
|
||||||
```bash
|
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.
|
||||||
h2mm
|
|
||||||
```
|
```bash
|
||||||
|
h2mm
|
||||||
### Available commands
|
```
|
||||||
|
|
||||||
- `install` - Install a mod with files
|
### Available commands
|
||||||
- `uninstall` - Uninstall a mod by name
|
|
||||||
- `list` - List all installed mods
|
- `install` or `i` - Install a mod by the file provided (directory, zip, patch);
|
||||||
- `export <zip_name>` - Export installed mods to a zip file
|
- `uninstall` or `u` - Uninstall a mod;
|
||||||
- `import <zip_name>` - Import mods from a zip file
|
- `list` or `l` - List all installed mods;
|
||||||
- `reset` - Reset all installed mods
|
- `enable` or `e` - Enable a mod;
|
||||||
- `help` - Display the help message
|
- `disable` or `d` - Disable a mod;
|
||||||
|
- `order` or `o` - Change load order for a mod;
|
||||||
### Basic usage
|
- `export` or `ex` - Export installed mods to a zip file;
|
||||||
|
- `import` or `im` - Import mods from a zip file;
|
||||||
#### Install a mod
|
- `modpack-create` or `mc` - Create a modpack from the currently installed mods;
|
||||||
|
- `modpack-switch` or `ms` - Switch to a modpack;
|
||||||
```bash
|
- `modpack-list` or `ml` - List all installed modpacks;
|
||||||
h2mm install /path/to/mod.zip
|
- `modpack-delete` or `md` - Delete a modpack;
|
||||||
h2mm install /path/to/mod/files
|
- `modpack-overwrite` or `mo` - Overwrite a modpack;
|
||||||
h2mm install -n "Example mod" mod.patch_0 mod.patch_0.stream # -n is mandatory when using files
|
- `modpack-reset` or `mr` - Reset all installed modpacks;
|
||||||
h2mm install -n "Example mod" mod* # using a wildcard to include all files
|
- `nexus-setup` or `ns` - Setup Nexus Mods integration;
|
||||||
```
|
- `nexus-update` or `nu` - Start Nexus mods upgrade process;
|
||||||
|
- `update` or `up` - Update h2mm to latest version;
|
||||||
> Currently, if the mod has more than 1 variant, you need to install the one you want by unarchiving it separately.
|
- `reset` or `r` - Reset all installed mods;
|
||||||
|
- `help` or `h` - Display this help message.
|
||||||
#### Uninstall a mod
|
|
||||||
|
### Usage
|
||||||
```bash
|
|
||||||
h2mm uninstall "Example mod"
|
To find out how to use a command, you can run `h2mm <COMMAND> --help`.
|
||||||
h2mm uninstall -i 1 # uninstall mod with index 1
|
|
||||||
```
|
#### Install mod(s)
|
||||||
|
|
||||||
|
```bash
|
||||||
#### Enable/disable mods
|
h2mm install /path/to/mod.zip
|
||||||
|
h2mm install /path/to/mod/directory/
|
||||||
```bash
|
h2mm install /path/to/mod.zip /path/to/mod2.zip /path/to/mod/files
|
||||||
h2mm enable "Example mod"
|
h2mm install -n "Example mod" mod.patch_0 mod.patch_0.stream # -n is mandatory when using files
|
||||||
h2mm enable -i 1 # enable mod with index 1
|
```
|
||||||
h2mm disable "Example mod"
|
|
||||||
h2mm disable -i 1 # disable mod with index 1
|
> It's better to be in the directory where the mod files are located, so you don't have to specify the full path. For mod downloads, you can do `cd ~/Downloads` and then run the command.
|
||||||
```
|
>
|
||||||
|
> Also, use the Tab key to autocomplete the file names, as it will help you escape special characters likes spaces or quotes.
|
||||||
#### List installed mods
|
|
||||||
|
#### List installed mods
|
||||||
```bash
|
|
||||||
h2mm list
|
```bash
|
||||||
```
|
h2mm list
|
||||||
|
h2mm list -v # verbose mode
|
||||||
## Advanced usage
|
```
|
||||||
|
|
||||||
### Shortcuts
|
#### Uninstall a mod
|
||||||
|
|
||||||
You can use the short form of commands to save some time. The shortcuts are:
|
```bash
|
||||||
|
h2mm uninstall -n "Example mod"
|
||||||
- `i` for `install`
|
h2mm uninstall -i 3 # get the index from the list command
|
||||||
- `u` for `uninstall`
|
```
|
||||||
- `e` for `enable`
|
|
||||||
- `d` for `disable`
|
#### Enable/disable mods
|
||||||
- `l` for `list`
|
|
||||||
- `ex` for `export`
|
```bash
|
||||||
- `im` for `import`
|
h2mm enable -n "Example mod"
|
||||||
- `r` for `reset`
|
h2mm enable -i 3
|
||||||
|
h2mm disable -n "Example mod"
|
||||||
### Exporting and importing
|
h2mm disable -i 3
|
||||||
|
```
|
||||||
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 zip file will be saved in the current directory.
|
|
||||||
|
#### Updating the script
|
||||||
```bash
|
|
||||||
h2mm export modpack1.zip
|
```bash
|
||||||
h2mm import modpack2.zip
|
h2mm update
|
||||||
```
|
```
|
||||||
|
|
||||||
### Resetting all installed mods
|
## Nexus Mods integration
|
||||||
|
|
||||||
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.
|
Nexus Mods integration allows you to use the 1-click install feature of Nexus Mods (with the "Vortex" or "Mod manager download" buttons). You can set up Nexus Mods integration by running the following command:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
h2mm reset
|
h2mm nexus-setup
|
||||||
```
|
```
|
||||||
|
|
||||||
### Database location and details
|
You will be walked through the setup process, which will ask you for your Nexus Mods API key and your preferred terminal.
|
||||||
|
|
||||||
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.
|
## Compatibility
|
||||||
|
|
||||||
## Contributing
|
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.
|
||||||
|
|
||||||
Feel free to contribute to this project by creating a pull request or opening an issue.
|
Status of platforms:
|
||||||
|
|
||||||
## Planned features
|
- Linux :white_check_mark:
|
||||||
|
- Steam Deck :white_check_mark:
|
||||||
- [x] Check for mod updates
|
- Windows - WSL :white_check_mark:
|
||||||
- [x] Enable/disable mods
|
|
||||||
- [ ] Easier way to change mod presets
|
> 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`. Nexus Mods integration is not supported on WSL.
|
||||||
- [ ] Find a way to make use of `manifest.json` and simplify installing variants
|
|
||||||
- [x] [DEV] Change to `.tar.gz` for exporting and importing
|
## Contributing
|
||||||
- [x] [DEV] Provide fixes for breaking updates
|
|
||||||
- [ ] [DEV] Optimize code - throw errors in 1 line
|
Feel free to contribute to this project by creating a pull request or opening an issue.
|
||||||
- [ ] [DEV] Rewrite some code to be more readable
|
|
||||||
|
|||||||
+149
-75
@@ -1,4 +1,4 @@
|
|||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
RED='\033[0;31m'
|
RED='\033[0;31m'
|
||||||
@@ -8,110 +8,184 @@ 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"
|
||||||
|
|
||||||
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)
|
||||||
|
echo -e "$*" >&2
|
||||||
|
;;
|
||||||
|
ERROR)
|
||||||
|
echo -e "${RED}[ERROR]${NC} $*" >&2
|
||||||
|
;;
|
||||||
|
PROMPT)
|
||||||
|
echo -ne "$*" >&2
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
# --- Main ---
|
# --- Main ---
|
||||||
|
|
||||||
# Warning
|
# warning
|
||||||
|
|
||||||
echo -e "!!! ${RED}WARNING${NC} !!!"
|
cat << EOF
|
||||||
echo -e "This script will install Helldivers 2 Mod Manager CLI for Linux to $DESTINATION_PATH/$SCRIPT_NAME."
|
!!! WARNING !!!
|
||||||
echo -e "Running this script will require sudo permissions. ${RED}DO NOT TRUST${NC} random scripts from the internet."
|
This script will install Helldivers 2 Mod Manager CLI for Linux to $DESTINATION_PATH/$SCRIPT_NAME.
|
||||||
echo -e "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.
|
||||||
echo -e "https://github.com/v4n00/h2mm-cli"
|
If you want to review the script before running it, check out the mod repository for yourself:
|
||||||
echo -e "!!! ${RED}WARNING${NC} !!!"
|
https://github.com/v4n00/h2mm-cli
|
||||||
echo
|
!!! WARNING !!!
|
||||||
|
|
||||||
# Check if update
|
EOF
|
||||||
|
|
||||||
# Breaking changes hash table
|
|
||||||
|
|
||||||
|
# breaking changes hash table
|
||||||
breaking_changes_patches=(
|
breaking_changes_patches=(
|
||||||
["2"]='sed -i "s/^\([0-9]\+\),/\1,ENABLED,/" "$1/mods.csv"'
|
["2"]='sed -i "s/^\([0-9]\+\),/\1,ENABLED,/" "$1/mods.csv"'
|
||||||
|
["3"]='sed -i "1 i\\3" "$1/mods.csv"'
|
||||||
|
["4"]='tmp_file=$(mktemp) && awk '\''BEGIN {FS=OFS=","} NR==1 {print 4; next} {print NR-1, $2, $3, $4, $5}'\'' "$1/mods.csv" > "$tmp_file" && tee "$1/mods.csv" < "$tmp_file" > /dev/null && rm "$tmp_file"'
|
||||||
|
["5"]='sed -i "s/^\([0-9]\+\),\(.*\),\(.*\),\(.*\)/\1,\2,\3,,,,\4/" "$1/mods.csv"; sed -i "1 s/4/5/" "$1/mods.csv"'
|
||||||
)
|
)
|
||||||
|
|
||||||
# Script
|
# notify if update is happening
|
||||||
|
installed_version=""
|
||||||
|
latest_version=""
|
||||||
if [[ -x "$(command -v $SCRIPT_NAME)" ]]; then
|
if [[ -x "$(command -v $SCRIPT_NAME)" ]]; then
|
||||||
installed_version=$($SCRIPT_NAME --version)
|
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
|
|
||||||
[[ ${installed_version:0:1} != "0" ]] && { installed_version="0.1.6"; }
|
|
||||||
|
|
||||||
latest_version=$(curl -sS https://raw.githubusercontent.com/v4n00/h2mm-cli/refs/heads/master/version)
|
# if installed version isn't x.x.x crash
|
||||||
|
if [[ ! "$installed_version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
||||||
|
log ERROR "Installed version is not in the correct format."
|
||||||
|
log ERROR "h2mm is installed here -> $(which h2mm)"
|
||||||
|
log ERROR "Delete the script file and retry the install script, any mods installed will not be lost."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
latest_version=$(curl -sS "$REPO_URL"/version)
|
||||||
if [[ "$latest_version" == "$installed_version" ]]; then
|
if [[ "$latest_version" == "$installed_version" ]]; then
|
||||||
echo -e "You are reinstalling version $installed_version."
|
log INFO "You are reinstalling version ${GREEN}$installed_version${NC}."
|
||||||
else
|
else
|
||||||
echo -e "You are upgrading from ${ORANGE}$installed_version${NC} -> ${GREEN}$latest_version${NC}."
|
log INFO "You are upgrading from ${ORANGE}$installed_version${NC} -> ${GREEN}$latest_version${NC}."
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# split version numbers
|
# if steam deck, set destination path to ~/.local/bin
|
||||||
installed_major=""
|
log PROMPT "Are you installing on a Steam Deck? (y/N): "
|
||||||
latest_major=""
|
IFS= read -e response_sd
|
||||||
IFS='.' read -r _1 installed_major _2 <<< "$installed_version"
|
|
||||||
IFS='.' read -r _1 latest_major _2 <<< "$latest_version"
|
|
||||||
|
|
||||||
if [[ $latest_major -gt $installed_major ]]; then
|
if [[ "$response_sd" == "y" || "$response_sd" == "Y" ]]; then
|
||||||
echo -e "${ORANGE}Warning:${NC} Major version upgrade detected."
|
# steam deck
|
||||||
echo "The script will proceed to upgrade ${SCRIPT_NAME} to avoid breaking changes."
|
DESTINATION_PATH="$HOME/.local/bin"
|
||||||
|
mkdir -p "$DESTINATION_PATH"
|
||||||
|
|
||||||
# find hd2 path
|
# check if ~/.local/bin is in PATH
|
||||||
search_dir="${HOME}"
|
if [[ ":$PATH:" != *":$HOME/.local/bin:"* ]]; then
|
||||||
target_dir="Steam/steamapps/common/Helldivers\ 2/data"
|
# add ~/.local/bin to PATH
|
||||||
echo "Searching for the Helldivers 2 data directory..." >&2
|
log INFO "Installing the script on a Steam Deck means adding $DESTINATION_PATH to your \$PATH."
|
||||||
game_dir=$(find "$search_dir" -type d -path "*/$target_dir" 2>/dev/null | head -n 1)
|
log INFO "If you're using a different shell than bash (the default), you may need to add it manually."
|
||||||
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
|
log PROMPT "Do you want to add $DESTINATION_PATH to your \$PATH in ~/.bashrc? (Y/n): "
|
||||||
echo -e "${RED}Error${NC}: Provided path is not a valid directory." >&2
|
IFS= read -e response
|
||||||
exit 1
|
if [[ "$response" == "y" || "$response" = "Y" || -z "$response" ]]; then
|
||||||
fi
|
echo "export PATH=\"\$HOME/.local/bin:\$PATH\"" >> "$HOME/.bashrc"
|
||||||
|
[[ $? -ne 0 ]] && { log ERROR "Failed to add $DESTINATION_PATH to \$PATH in ~/.bashrc." ; exit 1; }
|
||||||
|
|
||||||
|
source "$HOME/.bashrc"
|
||||||
|
[[ $? -ne 0 ]] && { log ERROR "Failed to source ~/.bashrc." ; exit 1; }
|
||||||
|
|
||||||
|
log INFO "Added $DESTINATION_PATH to your \$PATH in ~/.bashrc."
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# not steam deck
|
||||||
|
# set another path if needed
|
||||||
|
log PROMPT "Install the script to $DESTINATION_PATH or specify another path (must be included in \$PATH)? (Y/path): "
|
||||||
|
IFS= read -e response
|
||||||
|
|
||||||
[[ ! -f "$game_dir/mods.csv" ]] && { echo -e "${RED}Error:${NC} mods.csv not found in $game_dir."; exit 1; }
|
if [[ "$response" != "y" && "$response" != "Y" && -n "$response" ]]; then
|
||||||
|
DESTINATION_PATH="$response"
|
||||||
# iterate from installed major number to latest major number
|
[[ ! -d "$DESTINATION_PATH" ]] && { log ERROR "Path $DESTINATION_PATH does not exist." ; exit 1; }
|
||||||
for ((i = installed_major + 1; i <= latest_major; i++)); do
|
|
||||||
echo -e "${RED}[ ]${NC} Applying breaking changes patch for version $i."
|
|
||||||
|
|
||||||
[[ -n "${breaking_changes_patches[$i]}" ]] && eval $(echo "${breaking_changes_patches[$i]}" | sed "s:\$1:$game_dir:")
|
|
||||||
if [[ $? -ne 0 ]]; then
|
|
||||||
echo -ne "${RED}Error:${NC} Failed to apply breaking changes patch for version $i. Do you want to continue? (Y/n): "
|
|
||||||
read -r response
|
|
||||||
|
|
||||||
[[ "$response" != "y" && "$response" != "Y" && -n "$response" ]] && { echo "Exiting. Uninstall the script first the retry the install script."; exit 1; }
|
|
||||||
else
|
|
||||||
echo -e "${GREEN}[X]${NC} Breaking changes patch for version $i applied successfully."
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Install
|
# handle breaking changes
|
||||||
|
installed_major=$(echo "$installed_version" | awk -F. '{print $2}')
|
||||||
|
latest_major=$(echo "$latest_version" | awk -F. '{print $2}')
|
||||||
|
|
||||||
read -p "Install the script to $DESTINATION_PATH or specify another path (must be included in \$PATH)? (Y/path): " response
|
if [[ $latest_major -gt $installed_major ]]; then
|
||||||
|
log INFO ""
|
||||||
|
log INFO "Major version upgrade detected."
|
||||||
|
log INFO "Check out the changelogs here -> https://github.com/v4n00/h2mm-cli/releases"
|
||||||
|
log INFO "The script will proceed to upgrade the database file to avoid breaking changes."
|
||||||
|
|
||||||
if [[ "$response" != "y" && "$response" != "Y" && -n "$response" ]]; then
|
# find hd2 path
|
||||||
DESTINATION_PATH=$(eval echo "$response")
|
search_dir="${HOME}"
|
||||||
if [[ ! -d "$DESTINATION_PATH" ]]; then
|
target_dir="Steam/steamapps/common/Helldivers\ 2/data"
|
||||||
echo -e "${RED}Error:${NC} Path $DESTINATION_PATH does not exist. Exiting..."
|
|
||||||
exit 1
|
# make backup
|
||||||
fi
|
log INFO "Creating a backup in case anything goes wrong."
|
||||||
|
h2mm export
|
||||||
|
|
||||||
|
# check if game directory is in ~/.config/h2mm/h2path
|
||||||
|
if [[ -f "$HOME/.config/h2mm/h2path" ]]; then
|
||||||
|
game_dir=$(cat "$HOME/.config/h2mm/h2path")
|
||||||
|
[[ ! -d "$game_dir" ]] && { log ERROR "Helldivers 2 data directory in ~/.config/h2mm/h2path is not a valid directory." ; exit 1; }
|
||||||
|
|
||||||
|
log INFO "Helldivers 2 data directory found: $game_dir."
|
||||||
|
else
|
||||||
|
log INFO "Searching for the Helldivers 2 data directory... (10 seconds timeout)"
|
||||||
|
game_dir=$(timeout 10 find "$search_dir" -type d -path "*/$target_dir" 2>/dev/null | head -n 1)
|
||||||
|
fi
|
||||||
|
|
||||||
|
# if not found, prompt user
|
||||||
|
if [[ -z "$game_dir" ]]; then
|
||||||
|
log INFO "Could not find the Helldivers 2 data directory automatically."
|
||||||
|
log PROMPT "Please enter the path to the Helldivers 2 data directory: "
|
||||||
|
IFS= read -e game_dir
|
||||||
|
if [[ ! -d "$game_dir" ]]; then
|
||||||
|
log ERROR "Provided path is not a valid directory."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
[[ ! -f "$game_dir/mods.csv" ]] && { log ERROR "mods.csv not found in $game_dir." ; exit 1; }
|
||||||
|
|
||||||
|
# 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
|
fi
|
||||||
|
|
||||||
echo "Installing $SCRIPT_NAME to $DESTINATION_PATH."
|
# install
|
||||||
sudo curl https://raw.githubusercontent.com/v4n00/h2mm-cli/refs/heads/master/h2mm --output "$DESTINATION_PATH/$SCRIPT_NAME"
|
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"
|
sudo chmod +x "$DESTINATION_PATH/$SCRIPT_NAME"
|
||||||
|
log INFO ""
|
||||||
|
|
||||||
if [[ ! -x "$(command -v $SCRIPT_NAME)" ]]; then
|
[[ ! -x "$(command -v $SCRIPT_NAME)" ]] && { log ERROR "Installation failed. Mod manager was not found in \$PATH." ; exit 1; }
|
||||||
echo -e "${RED}Error:${NC} Installation failed."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Helldivers 2 Mod Manager CLI installed successfully to $DESTINATION_PATH/$SCRIPT_NAME. Use it by running '$SCRIPT_NAME'."
|
log INFO "Helldivers 2 Mod Manager CLI ${GREEN}successfully${NC} installed."
|
||||||
|
log INFO "${GREEN}IMPORTANT${NC}: To install mods, you need to have installed:"
|
||||||
|
log INFO " -> \"unzip\" package for .zip archives"
|
||||||
|
log INFO " -> \"unarchiver\" package for .rar archives"
|
||||||
|
log INFO "If you do not know how to install these packages, please search for your linux distro on how to install packages."
|
||||||
|
log INFO ""
|
||||||
|
log INFO "Use the mod manager by running '$SCRIPT_NAME' in your terminal."
|
||||||
|
log INFO "Made with love <3 by v4n and contributors."
|
||||||
|
|||||||
Reference in New Issue
Block a user