diff --git a/README.md b/README.md index 02a2706..6efa4fc 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,14 @@ sudo ./scripts/download-content.sh **7. Use it.** Join the Wi-Fi network you created and open **http://box.lan/home**. +### Take it with you: phone downloads + +The Wi-Fi reaches only a few dozen metres. **http://box.lan/home/telefon.html** ("Telefona İndir" on the homepage) lets people install the Kiwix Android app from the box and download the ZIM files on it, so they can keep reading after they leave. The ZIM files are served straight from `/library/zims/content` (no copies, no extra space), Turkish content first, each download limited to 2 MB/s so one phone can't choke the hotspot. Fetch the app once while the Pi has internet: +```bash +sudo ./scripts/download-app.sh +``` +It fetches two builds from Kiwix's GitHub releases, about 70 MB for current phones and 64 MB for older ones, each checked against the SHA-256 GitHub publishes; re-run it later to get a newer version. iPhones can't install the app from the box, since Apple only allows the App Store; the page links to Kiwix on the App Store for phones with mobile data, and the downloaded files open in Kiwix once it is installed. + ### Optional: internet over a USB Wi-Fi adapter The Pi's built-in Wi-Fi is dedicated to the hotspot. If the Pi needs internet temporarily (updates, new content) and there is no Ethernet cable, add a cheap USB Wi-Fi adapter as a second card. Adapters with the MediaTek MT7601U chip work out of the box. @@ -94,12 +102,16 @@ install.sh main installer scripts/setup-ssd.sh mounts the SSD at /library scripts/download-content.sh downloads/updates ZIM files from Kiwix scripts/install-homepage.sh installs the custom homepage +scripts/install-telefon.sh sets up phone downloads +scripts/download-app.sh downloads the Kiwix Android app for phones scripts/status.sh health check: disk, services, hotspot, content, power scripts/disk-health.sh disk and power health check (saglik/: its systemd timer) config/iiab-overrides.yml Internet-in-a-Box settings config/content.conf list of content to download www/home/index.html homepage www/home/acil.html emergency page (Turkish, sourced from AFAD and EPA) +www/home/telefon.html phone downloads page +telefon/ nginx config for phone downloads ``` ### Troubleshooting @@ -199,6 +211,14 @@ sudo ./scripts/download-content.sh **7. Kullan.** Oluşturduğun Wi-Fi ağına bağlan ve **http://box.lan/home** adresini aç. +### Bilgiyi yanında götür: telefona indirme + +Wi-Fi yalnızca birkaç on metre çeker. **http://box.lan/home/telefon.html** (ana sayfada "Telefona İndir") sayfasından insanlar Kiwix'in Android uygulamasını kutudan kurar ve kutudaki ZIM dosyalarını indirir; kutudan uzaklaşınca da okumaya devam eder. ZIM dosyaları doğrudan `/library/zims/content` klasöründen sunulur (kopya yok, ek yer tutmaz), Türkçe içerikler en üstte, her indirme 2 MB/sn ile sınırlı ki tek bir telefon hotspot'u tıkamasın. Uygulamayı Pi internete bağlıyken bir kez indir: +```bash +sudo ./scripts/download-app.sh +``` +Kiwix'in GitHub sürümlerinden iki paket indirir, güncel telefonlar için yaklaşık 70 MB, eskiler için 64 MB; her biri GitHub'ın yayımladığı SHA-256 ile doğrulanır. Yeni sürüm için betiği tekrar çalıştır. Apple yalnızca App Store'dan kuruluma izin verdiği için iPhone'a uygulama kutudan kurulamaz; sayfa, mobil verisi olan telefonlar için App Store'daki Kiwix'e bağlantı verir, indirilen dosyalar Kiwix kurulunca açılır. + ### İsteğe bağlı: USB Wi-Fi adaptörüyle internet Pi'nin dahili Wi-Fi kartı sadece hotspot için kullanılıyor. Pi'nin geçici olarak internete çıkması gerekirse (güncelleme, yeni içerik) ve Ethernet kablosu yoksa ikinci kart olarak ucuz bir USB Wi-Fi adaptörü tak. MediaTek MT7601U yongalı adaptörler kurulumsuz çalışıyor. @@ -232,12 +252,16 @@ install.sh ana kurulum betiği scripts/setup-ssd.sh SSD'yi /library klasörüne bağlar scripts/download-content.sh Kiwix'ten ZIM dosyalarını indirir/günceller scripts/install-homepage.sh özel ana sayfayı kurar +scripts/install-telefon.sh telefona indirmeyi kurar +scripts/download-app.sh telefonlar için Kiwix Android uygulamasını indirir scripts/status.sh sağlık kontrolü: disk, servisler, hotspot, içerik, güç scripts/disk-health.sh disk ve güç sağlığı denetimi (saglik/: systemd zamanlayıcısı) config/iiab-overrides.yml Internet-in-a-Box ayarları config/content.conf indirilecek içerik listesi www/home/index.html ana sayfa www/home/acil.html acil durum sayfası (AFAD ve EPA kaynaklı) +www/home/telefon.html telefona indirme sayfası +telefon/ telefona indirme için nginx ayarı ``` ### Sorun giderme diff --git a/install.sh b/install.sh index 6d6947a..6d4bcf5 100755 --- a/install.sh +++ b/install.sh @@ -79,6 +79,7 @@ fi say "3/3 Ana sayfa / homepage" "$REPO/scripts/install-homepage.sh" "$REPO/scripts/install-disk-health.sh" +"$REPO/scripts/install-telefon.sh" IP=$(hostname -I | awk '{print $1}') say "Bitti / done" @@ -86,6 +87,7 @@ cat <&2; exit 1; } +[ "$EUID" -eq 0 ] || die "sudo ile çalıştır / run with sudo" +[ -d /library/www/html ] || die "/library/www/html yok. Önce / install first: sudo ./install.sh" + +# GitHub her dosyanın SHA-256 özetini verir; Kiwix sunucusundaki .md5 dosyaları güncel değil. +# GitHub publishes a SHA-256 for every file; the .md5 files on Kiwix's own server are stale. +RELEASE=$(curl -fsSL "$API") || die "GitHub'a ulaşılamadı / cannot reach GitHub" +LIST=$(printf '%s' "$RELEASE" | python3 -c ' +import json, sys +r = json.load(sys.stdin) +for abi in sys.argv[1].split(): + for a in r["assets"]: + if a["name"].endswith(f"-{abi}-standalone.apk") and (a.get("digest") or "").startswith("sha256:"): + print(abi, a["name"], a["digest"][7:], a["browser_download_url"]) +' "$ABIS") +[ -n "$LIST" ] || die "sürümde uygulama dosyası yok / no app files in the release" + +install -d -m 755 "$DIR" +keep=() +while read -r _ name sha url; do + keep+=("$name") + if [ -f "$DIR/$name" ]; then + echo "Güncel / up to date: $name" + continue + fi + echo "İndiriliyor / downloading $name" + curl -fL --retry 3 -C - -o "$DIR/$name.part" "$url" || true + if ! echo "$sha $DIR/$name.part" | sha256sum -c --status 2>/dev/null; then + rm -f "$DIR/$name.part" + die "SHA-256 tutmadı, dosya silindi / checksum mismatch, file removed: $name" + fi + mv "$DIR/$name.part" "$DIR/$name" + chmod 644 "$DIR/$name" +done <<< "$LIST" + +for f in "$DIR"/*.apk; do + [ -e "$f" ] || continue + printf '%s\n' "${keep[@]}" | grep -qxF "$(basename "$f")" || rm -f "$f" +done + +python3 -c ' +import json, os, sys +print(json.dumps([{"abi": abi, "file": name, "size": os.path.getsize(os.path.join(sys.argv[1], name))} + for abi, name, *_ in (line.split() for line in sys.stdin if line.strip())])) +' "$DIR" <<< "$LIST" > "$DIR/app.json.tmp" +chmod 644 "$DIR/app.json.tmp" +mv "$DIR/app.json.tmp" "$DIR/app.json" +echo "Telefonlar buradan kurar / phones install it from: http://box.lan/home/telefon.html" diff --git a/scripts/install-homepage.sh b/scripts/install-homepage.sh index 3fbb2e9..c93c5b3 100755 --- a/scripts/install-homepage.sh +++ b/scripts/install-homepage.sh @@ -12,6 +12,6 @@ DST=/library/www/html/home if [ -f "$DST/index.html" ] && [ ! -f "$DST/index.html.iiab-original" ]; then cp "$DST/index.html" "$DST/index.html.iiab-original" fi -cp "$SRC/index.html" "$SRC/acil.html" "$DST/" +cp "$SRC"/*.html "$DST/" echo "Ana sayfa kuruldu / homepage installed: http://box.lan/home" echo "Geri almak için / to restore: sudo cp $DST/index.html.iiab-original $DST/index.html" diff --git a/scripts/install-telefon.sh b/scripts/install-telefon.sh new file mode 100755 index 0000000..1ede5b9 --- /dev/null +++ b/scripts/install-telefon.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash +# "Telefona indir" sayfasını kurar: telefonlar Kiwix uygulamasını ve içerikleri kutudan indirir. +# Tekrar çalıştırmak güvenlidir. +# Installs the "Telefona indir" page: phones download the Kiwix app and content from the box. Safe to re-run. +# +# Kullanım / usage: sudo ./scripts/install-telefon.sh +set -euo pipefail + +REPO="$(cd "$(dirname "$0")/.." && pwd)" +NGINX_CONF=/etc/nginx/conf.d/has-telefon-nginx.conf + +die(){ echo "HATA / ERROR: $*" >&2; exit 1; } +[ "$EUID" -eq 0 ] || die "sudo ile çalıştır / run with sudo: sudo ./scripts/install-telefon.sh" +[ -d /etc/nginx/conf.d ] || die "nginx bulunamadı. Önce / install first: sudo ./install.sh" + +install -d -m 755 /library/www/html/telefon +install -m 644 "$REPO/telefon/telefon-nginx.conf" "$NGINX_CONF" +if nginx -t 2>/dev/null; then + systemctl reload nginx +else + rm -f "$NGINX_CONF" + nginx -t || true + die "nginx ayarı hatalı, geri alındı / nginx config failed and was removed" +fi + +cat <Çevrimdışı bilgi arşivi — internet olmasa da açık diff --git a/www/home/telefon.html b/www/home/telefon.html new file mode 100644 index 0000000..f728132 --- /dev/null +++ b/www/home/telefon.html @@ -0,0 +1,156 @@ + + + + + +HAS_PrepperDisk :: Telefona İndir + + + +
+ +
Ana Sayfa » Telefona İndir
+ +
+
+

Kutunun Wi-Fi'ı yalnızca birkaç on metre çeker. Uygulamayı ve içerikleri telefonuna indirirsen kutudan uzaklaştığında da internetsiz okuyabilirsin.

+

Wi-Fi'a bağlanınca kendiliğinden açılan pencerede indirme çalışmayabilir. Bu sayfayı Chrome ya da Safari'de aç: http://box.lan/home/telefon.html

+
+
+ +
+

1. Kiwix uygulaması (Android)

+
+
Yükleniyor...
+
    +
  1. İndirme bitince dosyaya dokun.
  2. +
  3. Telefon izin isterse "Bu kaynaktan yüklemeye izin ver"i aç.
  4. +
  5. "Yükle"ye dokun.
  6. +
+
iPhone: Apple, uygulamaların App Store dışından kurulmasına izin vermiyor. Telefonunda internet varsa (mobil veri de olur) Kiwix'i buradan kur: App Store'da Kiwix
İnternet yoksa, aşağıdaki dosyaları şimdi indir, Kiwix'i ilk fırsatta kurup açarsın.
+
+
+ +
+

2. İçerikler

+
+

Dosyayı indir, sonra Kiwix'i aç. Dosya kütüphanede görünmezse Kiwix içinden İndirilenler klasöründeki dosyayı aç. Büyük dosyalar için telefonunda yer olduğundan emin ol.

+
+
+
+ + +
+ + + +