#!/bin/sh # Name: Install Kho Sách # Author: mnd.vn # # Adds the MND repo to KPM and installs (or updates) Kho Sách from it. # Copy this file into the Kindle's documents/ folder, eject, and tap it on # the home screen with Wi-Fi on. Tap it again later to update. Needs a # jailbreak recent enough to ship KPM (hdnext / jb.sh + Universal Hotfix). REPO=https://kpm.mnd.vn/r # KPM lives in different places depending on the jailbreak, so find it. KPM="" for c in /var/local/kmc/bin/kpm /mnt/us/kmc/bin/kpm $(command -v kpm 2>/dev/null); do [ -x "$c" ] && { KPM=$c; break; } done [ -n "$KPM" ] || { echo "KPM not found on this Kindle."; exit 1; } # Adding a repo KPM already holds fails on the repository id's primary key # ("SQLite error: 19", reported as "Could not add repository ... (3)"), # which reads like the network fault it never was -- measured on device. # So only add it when it is actually missing. # # 2>&1, not 2>/dev/null: KPM logs EVERYTHING to stderr (cli/io.c is all # vfprintf(stderr, ...)), including this listing. Discarding stderr threw # away the very output being searched, so the check always said "missing" # and every run tried to add a repo that was already there. "$KPM" list-repo 2>&1 | grep -q mndvn || "$KPM" -y add-repo "$REPO" # Deliberately not gated on add-repo succeeding: if the check above ever # misfires again, the add fails as a duplicate and the install below is # still perfectly able to proceed. A genuine network failure fails here # too, with its own message. "$KPM" -y install khosach