feat: install multiple mods at once
This commit is contained in:
@@ -1,150 +1,151 @@
|
|||||||
# 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.
|
||||||
|
|
||||||
- [Helldivers 2 Mod Manager CLI](#helldivers-2-mod-manager-cli)
|
- [Helldivers 2 Mod Manager CLI](#helldivers-2-mod-manager-cli)
|
||||||
- [Installation](#installation)
|
- [Installation](#installation)
|
||||||
- [Usage](#usage)
|
- [Usage](#usage)
|
||||||
- [Available commands](#available-commands)
|
- [Available commands](#available-commands)
|
||||||
- [Basic usage](#basic-usage)
|
- [Basic usage](#basic-usage)
|
||||||
- [Install a mod](#install-a-mod)
|
- [Install a mod](#install-a-mod)
|
||||||
- [Uninstall a mod](#uninstall-a-mod)
|
- [Uninstall a mod](#uninstall-a-mod)
|
||||||
- [Enable/disable mods](#enabledisable-mods)
|
- [Enable/disable mods](#enabledisable-mods)
|
||||||
- [List installed mods](#list-installed-mods)
|
- [List installed mods](#list-installed-mods)
|
||||||
- [Compatibility](#compatibility)
|
- [Compatibility](#compatibility)
|
||||||
- [Advanced usage](#advanced-usage)
|
- [Advanced usage](#advanced-usage)
|
||||||
- [Shortcuts](#shortcuts)
|
- [Shortcuts](#shortcuts)
|
||||||
- [Exporting and importing](#exporting-and-importing)
|
- [Exporting and importing](#exporting-and-importing)
|
||||||
- [Resetting all installed mods](#resetting-all-installed-mods)
|
- [Resetting all installed mods](#resetting-all-installed-mods)
|
||||||
- [Database location and details](#database-location-and-details)
|
- [Database location and details](#database-location-and-details)
|
||||||
- [Contributing](#contributing)
|
- [Contributing](#contributing)
|
||||||
- [Planned features](#planned-features)
|
- [Planned features](#planned-features)
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
To install/update Helldivers 2 Mod Manager CLI run the following command in your terminal:
|
To install/update 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)"
|
||||||
```
|
```
|
||||||
|
|
||||||
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.
|
||||||
|
|
||||||
## 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 with files
|
- `install` - Install a mod with files
|
||||||
- `uninstall` - Uninstall a mod by name
|
- `uninstall` - Uninstall a mod by name
|
||||||
- `list` - List all installed mods
|
- `list` - List all installed mods
|
||||||
- `enable` - Enable a mod by name
|
- `enable` - Enable a mod by name
|
||||||
- `disable` - Disable a mod by name
|
- `disable` - Disable a mod by name
|
||||||
- `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
|
||||||
- `reset` - Reset all installed mods
|
- `reset` - Reset all installed mods
|
||||||
- `help` - Display the help message
|
- `help` - Display the help message
|
||||||
|
|
||||||
### Basic usage
|
### Basic usage
|
||||||
|
|
||||||
#### Install a mod
|
#### Install a mod
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
h2mm install /path/to/mod.zip
|
h2mm install /path/to/mod.zip
|
||||||
h2mm install /path/to/mod/files
|
h2mm install /path/to/mod/files
|
||||||
h2mm install -n "Example mod" mod.patch_0 mod.patch_0.stream # -n is mandatory when using files
|
h2mm install -n "Example mod" mod.patch_0 mod.patch_0.stream # -n is mandatory when using files
|
||||||
h2mm install -n "Example mod" mod* # using a wildcard to include all files
|
h2mm install -n "Example mod" mod* # using a wildcard to include all files
|
||||||
```
|
```
|
||||||
|
|
||||||
> Currently, if the mod has more than 1 variant, you need to install the one you want by unarchiving it separately.
|
> Currently, if the mod has more than 1 variant, you need to install the one you want by unarchiving it separately.
|
||||||
|
|
||||||
#### Uninstall a mod
|
#### Uninstall a mod
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
h2mm uninstall "Example mod"
|
h2mm uninstall "Example mod"
|
||||||
h2mm uninstall -i 1 # uninstall mod with index 1
|
h2mm uninstall -i 1 # uninstall mod with index 1
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Enable/disable mods
|
#### Enable/disable mods
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
h2mm enable "Example mod"
|
h2mm enable "Example mod"
|
||||||
h2mm enable -i 1 # enable mod with index 1
|
h2mm enable -i 1 # enable mod with index 1
|
||||||
h2mm disable "Example mod"
|
h2mm disable "Example mod"
|
||||||
h2mm disable -i 1 # disable mod with index 1
|
h2mm disable -i 1 # disable mod with index 1
|
||||||
```
|
```
|
||||||
|
|
||||||
#### List installed mods
|
#### List installed mods
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
h2mm list
|
h2mm list
|
||||||
```
|
```
|
||||||
|
|
||||||
## 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 other platforms:
|
Status of platforms:
|
||||||
|
|
||||||
- Linux :white_check_mark:
|
- Linux :white_check_mark:
|
||||||
- Steam Deck - untested (should work) :grey_question:
|
- Steam Deck - untested (should work) :grey_question:
|
||||||
- WSL :white_check_mark:
|
- 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`
|
||||||
- `r` for `reset`
|
- `r` for `reset`
|
||||||
|
|
||||||
### 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 zip file 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 zip file will be saved in the current directory.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
h2mm export modpack1.zip
|
h2mm export modpack1.zip
|
||||||
h2mm import modpack2.zip
|
h2mm import modpack2.zip
|
||||||
```
|
```
|
||||||
|
|
||||||
### 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
|
```bash
|
||||||
h2mm reset
|
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.
|
||||||
|
|
||||||
## Planned features
|
## Planned features
|
||||||
|
|
||||||
- [x] Check for mod updates
|
- [x] Check for mod updates
|
||||||
- [x] Enable/disable mods
|
- [x] Enable/disable mods
|
||||||
- [ ] Install mods in batches
|
- [x] Install mods in batches
|
||||||
- [ ] Easier way to change mod presets
|
- [ ] Easier way to change mod presets
|
||||||
- [ ] Find a way to make use of `manifest.json` and simplify installing variants
|
- [ ] Find a way to make use of `manifest.json` and simplify installing variants
|
||||||
- [x] [DEV] Change to `.tar.gz` for exporting and importing
|
- [x] [DEV] Change to `.tar.gz` for exporting and importing
|
||||||
- [x] [DEV] Provide fixes for breaking updates
|
- [x] [DEV] Provide fixes for breaking updates
|
||||||
- [ ] [DEV] Optimize code - throw errors in 1 line
|
- [x] [DEV] Optimize code - throw errors in 1 line
|
||||||
- [ ] [DEV] Rewrite some code to be more readable
|
- [ ] [DEV] Import/export treat breaking changes
|
||||||
|
- [ ] [DEV] Rewrite some code to be more readable
|
||||||
|
|||||||
@@ -368,8 +368,9 @@ function mod_reset() {
|
|||||||
|
|
||||||
function mod_install() {
|
function mod_install() {
|
||||||
local mod_name=""
|
local mod_name=""
|
||||||
local mod_dir=""
|
local mod_dir=()
|
||||||
local mod_files=()
|
local mod_files=()
|
||||||
|
local mod_zip=()
|
||||||
|
|
||||||
[[ $# -eq 0 ]] && { display_install_help; exit 0; }
|
[[ $# -eq 0 ]] && { display_install_help; exit 0; }
|
||||||
|
|
||||||
@@ -384,9 +385,9 @@ function mod_install() {
|
|||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
if [[ -f "$1" && "$1" == *.zip ]]; then
|
if [[ -f "$1" && "$1" == *.zip ]]; then
|
||||||
mod_zip="$1"
|
mod_zip+=("$1")
|
||||||
elif [[ -d "$1" ]]; then
|
elif [[ -d "$1" ]]; then
|
||||||
mod_dir="$1"
|
mod_dir+=("$1")
|
||||||
else
|
else
|
||||||
mod_files+=("$1")
|
mod_files+=("$1")
|
||||||
fi
|
fi
|
||||||
@@ -395,7 +396,26 @@ function mod_install() {
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
# zip file containing mod files
|
# edge case when there is a combination of mod zips and directories, call function for all zips and dirs
|
||||||
|
if [[ ${mod_zip} && ${mod_dir} ]]; then
|
||||||
|
mod_install "${mod_zip[@]}"
|
||||||
|
mod_install "${mod_dir[@]}"
|
||||||
|
|
||||||
|
# reset arrays
|
||||||
|
mod_zip=()
|
||||||
|
mod_dir=()
|
||||||
|
|
||||||
|
# if there are no more arguments, exit
|
||||||
|
[[ ${#mod_files[@]} -eq 0 ]] && exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# if there's more than 1 zip, call recursively
|
||||||
|
while [[ ${#mod_zip[@]} -gt 1 ]]; do
|
||||||
|
mod_install "${mod_zip[0]}"
|
||||||
|
mod_zip=("${mod_zip[@]:1}")
|
||||||
|
done
|
||||||
|
|
||||||
|
# extract the zip file and pass it to mod dirs
|
||||||
if [[ -n "$mod_zip" ]]; then
|
if [[ -n "$mod_zip" ]]; then
|
||||||
command -v unzip &> /dev/null || { echo -e "${RED}Error${NC}: unzip package is not installed." >&2; exit 1; }
|
command -v unzip &> /dev/null || { echo -e "${RED}Error${NC}: unzip package is not installed." >&2; exit 1; }
|
||||||
|
|
||||||
@@ -407,10 +427,16 @@ function mod_install() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# mod_dir as a temporary directory
|
# mod_dir as a temporary directory
|
||||||
mod_dir=$(mktemp -d)
|
mod_dir+=$(mktemp -d)
|
||||||
unzip -qq "$mod_zip" -d "$mod_dir"
|
unzip -qq "$mod_zip" -d "$mod_dir"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# if there's more than 1 directory, call recursively
|
||||||
|
while [[ ${#mod_dir[@]} -gt 1 ]]; do
|
||||||
|
mod_install "${mod_dir[0]}"
|
||||||
|
mod_dir=("${mod_dir[@]:1}")
|
||||||
|
done
|
||||||
|
|
||||||
# directory containing mod files
|
# directory containing mod files
|
||||||
if [[ -n "$mod_dir" ]]; then
|
if [[ -n "$mod_dir" ]]; then
|
||||||
# verify directory exists
|
# verify directory exists
|
||||||
@@ -427,15 +453,9 @@ function mod_install() {
|
|||||||
# verify minimum information required
|
# verify minimum information required
|
||||||
[[ -z "$mod_name" || ${#mod_files[@]} -eq 0 ]] && { echo -e "${RED}Error${NC}: Mod name and files are required." >&2; exit 1; }
|
[[ -z "$mod_name" || ${#mod_files[@]} -eq 0 ]] && { echo -e "${RED}Error${NC}: Mod name and files are required." >&2; exit 1; }
|
||||||
|
|
||||||
# verify mod files exist and is not directory
|
# verify mod files exist
|
||||||
for file in "${mod_files[@]}"; do
|
for file in "${mod_files[@]}"; do
|
||||||
if [[ ! -f "$file" ]]; then
|
[[ ! -f "$file" ]] && { echo -e "${RED}Error${NC}: Mod file $file does not exist." >&2; exit 1; }
|
||||||
# if it isn't a file, check if it's NOT a directory
|
|
||||||
[[ ! -d "$file" ]] && { echo -e "${RED}Error${NC}: File $file does not exist." >&2; exit 1; }
|
|
||||||
|
|
||||||
# delete the directory from the mod_files array
|
|
||||||
mod_files=(${mod_files[@]/$file})
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
|
|
||||||
# hash table - in case multiple named files are needed for 1 mod install, store the patch count
|
# hash table - in case multiple named files are needed for 1 mod install, store the patch count
|
||||||
|
|||||||
+5
-1
@@ -85,7 +85,11 @@ if [[ -x "$(command -v $SCRIPT_NAME)" ]]; then
|
|||||||
for ((i = installed_major + 1; i <= latest_major; i++)); do
|
for ((i = installed_major + 1; i <= latest_major; i++)); do
|
||||||
echo -e "Applying breaking changes patch for version $i."
|
echo -e "Applying breaking changes patch for version $i."
|
||||||
|
|
||||||
[[ -n "${breaking_changes_patches[$i]}" ]] && eval $(echo "${breaking_changes_patches[$i]}" | sed "s:\$1:$game_dir:")
|
if [[ -n "${breaking_changes_patches[$i]}" ]]; then
|
||||||
|
eval $(echo "${breaking_changes_patches[$i]}" | sed "s:\$1:$game_dir:")
|
||||||
|
else
|
||||||
|
echo "No breaking changes for version $i."
|
||||||
|
fi
|
||||||
if [[ $? -ne 0 ]]; then
|
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): "
|
echo -ne "${RED}Error:${NC} Failed to apply breaking changes patch for version $i. Do you want to continue? (Y/n): "
|
||||||
read -er response
|
read -er response
|
||||||
|
|||||||
Reference in New Issue
Block a user