feat: changed from zip to tar.gz

This commit is contained in:
v4n
2025-01-16 09:40:49 +02:00
parent 8d6591a19d
commit 6bcad99bec
2 changed files with 12 additions and 24 deletions
+2 -2
View File
@@ -112,9 +112,9 @@ Feel free to contribute to this project by creating a pull request or opening an
## Planned features ## Planned features
- [x] Check for mod updates
- [x] Change to `.tar.gz` for exporting and importing
- [ ] ! Enable/disable mods - [ ] ! Enable/disable mods
- [ ] ! Provide fixes for breaking updates - [ ] ! Provide fixes for breaking updates
- [ ] ! Auto update mods
- [ ] !! Easier way to change mod presets - [ ] !! Easier way to change mod presets
- [ ] !! Change to `.tar.xz` for exporting and importing
- [ ] !!! 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
+10 -22
View File
@@ -13,7 +13,7 @@ H2PATH="${HOME}/.config/h2mm/h2path"
MODS_DIR="" MODS_DIR=""
DB_FILE="" DB_FILE=""
LAST_UPDATE_FILE="${HOME}/.config/h2mm/last_update" LAST_CHECKED_UPDATE_FILE="${HOME}/.config/h2mm/last_update"
VERSION_URL="https://raw.githubusercontent.com/v4n00/h2mm-cli/refs/heads/dev/version" VERSION_URL="https://raw.githubusercontent.com/v4n00/h2mm-cli/refs/heads/dev/version"
REPO_URL="https://github.com/v4n00/h2mm-cli" REPO_URL="https://github.com/v4n00/h2mm-cli"
@@ -164,13 +164,13 @@ function display_import_help() {
# Check for updates # Check for updates
function check_for_updates() { function check_for_updates() {
if [[ -f "$LAST_UPDATE_FILE" ]]; then if [[ -f "$LAST_CHECKED_UPDATE_FILE" ]]; then
last_update=$(cat "$LAST_UPDATE_FILE") last_update=$(cat "$LAST_CHECKED_UPDATE_FILE")
if [[ $(date +%Y-%m-%d) -gt $(date +%Y-%m-%d -d "$last_update + 7 days") ]]; then if [[ $(date +%Y-%m-%d) -gt $(date +%Y-%m-%d -d "$last_update + 7 days") ]]; then
return return
fi fi
else else
echo $(date +%Y-%m-%d) > "$LAST_UPDATE_FILE" echo $(date +%Y-%m-%d) > "$LAST_CHECKED_UPDATE_FILE"
exit 0 exit 0
fi fi
@@ -185,7 +185,7 @@ function check_for_updates() {
echo -e "${RED}!${NC} You can download it from: $REPO_URL" >&2 echo -e "${RED}!${NC} You can download it from: $REPO_URL" >&2
fi fi
echo $(date +%Y-%m-%d) > "$LAST_UPDATE_FILE" echo $(date +%Y-%m-%d) > "$LAST_CHECKED_UPDATE_FILE"
} }
# Mod management # Mod management
@@ -450,12 +450,7 @@ function mod_export() {
exit 0 exit 0
fi fi
if ! command -v zip &> /dev/null; then echo -ne "Archive file will be saved in the current directory ($(pwd)). Continue? (Y/n): "
echo -e "${RED}Error${NC}: zip is not installed, please install the package and try again." >&2
exit 1
fi
echo -ne "Zip file will be saved in the current directory ($(pwd)). Continue? (Y/n): "
read -r confirm read -r confirm
if [[ "$confirm" == "y" || "$confirm" == "Y" || "$confirm" = "" ]]; then if [[ "$confirm" == "y" || "$confirm" == "Y" || "$confirm" = "" ]]; then
OUT_DIR=$(mktemp -d) OUT_DIR=$(mktemp -d)
@@ -473,13 +468,11 @@ function mod_export() {
fi fi
current_path=$(pwd) current_path=$(pwd)
zip_name="Helldivers_2_Mods_$(date +%Y-%m-%d_%H-%M-%S).zip" archive_name="Helldivers_2_Mods_$(date +%Y-%m-%d_%H-%M-%S).tar.gz"
cd "$OUT_DIR" tar -czf "$current_path/$archive_name" -C "$OUT_DIR" "Helldivers 2 Mods"
zip -r "$zip_name" "Helldivers 2 Mods"
mv "$zip_name" "$current_path"
if [[ $? -eq 0 ]]; then if [[ $? -eq 0 ]]; then
echo -e "Mods exported to ${GREEN}$current_path/$zip_name${NC}." >&2 echo -e "Mods exported to ${GREEN}$current_path/$archive_name${NC}." >&2
else else
echo -e "${RED}Error${NC}: Failed to export mods." >&2 echo -e "${RED}Error${NC}: Failed to export mods." >&2
fi fi
@@ -497,11 +490,6 @@ function mod_import() {
exit 1 exit 1
fi fi
if ! command -v unzip &> /dev/null; then
echo -e "${RED}Error${NC}: unzip is not installed, please install the package and try again." >&2
exit 1
fi
echo -e "Importing mods will ${RED}reset${NC} your mods." >&2 echo -e "Importing mods will ${RED}reset${NC} your mods." >&2
mod_reset mod_reset
if [[ $? -eq 1 ]]; then if [[ $? -eq 1 ]]; then
@@ -509,7 +497,7 @@ function mod_import() {
fi fi
OUT_DIR=$(mktemp -d) OUT_DIR=$(mktemp -d)
unzip -qq "$1" -d "$OUT_DIR" tar -xzf "$1" -C "$OUT_DIR"
if [[ $? -ne 0 ]]; then if [[ $? -ne 0 ]]; then
echo -e "${RED}Error${NC}: Could not import mods. Possibly because the zip file is invalid." >&2 echo -e "${RED}Error${NC}: Could not import mods. Possibly because the zip file is invalid." >&2