feat: install rar mods (#34)
This commit is contained in:
@@ -6,6 +6,13 @@ This script is complete, the version will always [remain at 0.x.x](https://0ver.
|
|||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
|
Pre-requisites:
|
||||||
|
|
||||||
|
- You must have the `unzip` package installed for zip archives;
|
||||||
|
- You might want to have the `unarchiver` package installed for rar archives.
|
||||||
|
|
||||||
|
> 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.
|
||||||
|
|
||||||
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
|
||||||
@@ -19,7 +26,8 @@ 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. Open your terminal
|
||||||
|
1. Go to your downloads folders with `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`
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
VERSION="0.4.1"
|
VERSION="0.4.2"
|
||||||
|
|
||||||
# --- Globals ---
|
# --- Globals ---
|
||||||
|
|
||||||
@@ -672,6 +672,7 @@ function mod_install() {
|
|||||||
local mod_dir=()
|
local mod_dir=()
|
||||||
local mod_files=()
|
local mod_files=()
|
||||||
local mod_zip=()
|
local mod_zip=()
|
||||||
|
local is_rar=false
|
||||||
|
|
||||||
# parse arguments
|
# parse arguments
|
||||||
while [[ $# -gt 0 ]]; do
|
while [[ $# -gt 0 ]]; do
|
||||||
@@ -681,8 +682,9 @@ function mod_install() {
|
|||||||
mod_name="$2"; shift 2
|
mod_name="$2"; shift 2
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
if [[ -f "$1" && "$1" == *.zip ]]; then
|
if [[ -f "$1" && ( "$1" == *.zip || "$1" == *.rar ) ]]; then
|
||||||
mod_zip+=("$1")
|
mod_zip+=("$1")
|
||||||
|
[[ "$1" == *.rar ]] && is_rar=true
|
||||||
elif [[ -d "$1" ]]; then
|
elif [[ -d "$1" ]]; then
|
||||||
mod_dir+=("$1")
|
mod_dir+=("$1")
|
||||||
else
|
else
|
||||||
@@ -714,7 +716,11 @@ function mod_install() {
|
|||||||
|
|
||||||
# if zip, extract the zip file and pass it to mod dirs
|
# if zip, 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 || { log ERROR "unzip package is not installed."; exit 1; }
|
if [[ $is_rar == true ]]; then
|
||||||
|
command -v unar &> /dev/null || { log ERROR "Rar archive could not be extracted because package \"unarchiver\" is not installed."; exit 1; }
|
||||||
|
else
|
||||||
|
command -v unzip &> /dev/null || { log ERROR "Zip archive could not be extracted because package \"unzip\" is not installed."; exit 1; }
|
||||||
|
fi
|
||||||
|
|
||||||
[[ ! -f "$mod_zip" ]] && { log ERROR "Zip file $mod_zip does not exist."; exit 1; }
|
[[ ! -f "$mod_zip" ]] && { log ERROR "Zip file $mod_zip does not exist."; exit 1; }
|
||||||
|
|
||||||
@@ -725,8 +731,12 @@ function mod_install() {
|
|||||||
|
|
||||||
# mod_dir as a temporary directory
|
# mod_dir as a temporary directory
|
||||||
mod_dir+=$(mktemp -d)
|
mod_dir+=$(mktemp -d)
|
||||||
|
if [[ $is_rar == true ]]; then
|
||||||
|
unar -q "$mod_zip" -o "$mod_dir"
|
||||||
|
else
|
||||||
unzip -qq "$mod_zip" -d "$mod_dir"
|
unzip -qq "$mod_zip" -d "$mod_dir"
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# if there's more than 1 directory, call recursively
|
# if there's more than 1 directory, call recursively
|
||||||
while [[ ${#mod_dir[@]} -gt 1 ]]; do
|
while [[ ${#mod_dir[@]} -gt 1 ]]; do
|
||||||
|
|||||||
+9
-2
@@ -179,5 +179,12 @@ sudo chmod +x "$DESTINATION_PATH/$SCRIPT_NAME"
|
|||||||
log INFO ""
|
log INFO ""
|
||||||
|
|
||||||
[[ ! -x "$(command -v $SCRIPT_NAME)" ]] && { log ERROR "Installation failed. Mod manager was not found in \$PATH." ; exit 1; }
|
[[ ! -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."
|
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