$ show jojo2357/kiwix-zim-updater
The kiwix-zim-updater.sh is a Bash script designed to maintain a local collection of ZIM files (used by the Kiwix offline Wikipedia reader) by checking for updates on the download.kiwix.org server. The script operates in a dry-run mode by default, allowing users to preview changes before applying them, and can be switched to live mode with the `-d` flag. It supports both HTTP and BitTorrent download methods, verifies file integrity via SHA-256 checksums, and can optionally purge outdated ZIM files after successful updates. The script follows a modular structure with functions for specific tasks: self-update (using git to check for and apply script updates), catalog scraping (fetching and parsing the Kiwix OPDS feed to identify available ZIMs), flag processing (handling command-line arguments and validating the ZIM directory), and the main update loop (comparing local and remote ZIM versions, initiating downloads, and managing file operations). Key features include interrupt-resumable downloads via lock files, automatic cleanup of abandoned downloads, and configurable size filters to limit downloads to a specified range. Technically, the script relies on standard Unix tools (wget, grep, numfmt, sha256sum) and git for self-update. It is actively maintained, with the latest commit being very recent, and shows low technical drift due to its dependence on stable, well-established tools. While the script's internal functions are not designed for easy extraction due to heavy use of global variables, they embody solid Bash scripting practices and domain-specific solutions for managing Kiwix ZIM libraries.
The LLM identified 2 files worth highlighting for reuse:
The self_update function checks for script updates via git, stashes local changes, pulls the latest version, and restarts the script. This demonstrates a safe and automated self-update mechanism for Bash scripts.
The master_scrape function fetches and parses the Kiwix OPDS catalog to obtain the list of available ZIM files, their sizes, paths, and categories. It implements caching to reduce network requests and uses robust grep-based parsing of XML data.