diff --git a/README.md b/README.md index dea4d7c..8d2507a 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ sudo ./scripts/setup-ssd.sh /dev/nvme0n1 sudo ./install.sh ``` -**5. Download content.** Edit `config/content.conf` to choose what to download, then run the script below. The defaults need about 150 GB, and downloads can take many hours. If a download is interrupted, re-run the script and it resumes. +**5. Download content.** Edit `config/content.conf` to choose what to download, then run the script below. The defaults need about 160 GB, and downloads can take many hours. If a download is interrupted, re-run the script and it resumes. The script looks up the newest version of each ZIM in the Kiwix catalog, checks free disk space before each download and verifies every file against its SHA-256 checksum. ```bash sudo ./scripts/download-content.sh ``` @@ -162,7 +162,7 @@ sudo ./scripts/setup-ssd.sh /dev/nvme0n1 sudo ./install.sh ``` -**5. İçerikleri indir.** Ne indirileceğini `config/content.conf` dosyasından seç, sonra aşağıdaki betiği çalıştır. Varsayılan liste yaklaşık 150 GB tutar ve indirme saatler sürebilir. İndirme yarıda kalırsa betiği tekrar çalıştırman yeterli, kaldığı yerden devam eder. +**5. İçerikleri indir.** Ne indirileceğini `config/content.conf` dosyasından seç, sonra aşağıdaki betiği çalıştır. Varsayılan liste yaklaşık 160 GB tutar ve indirme saatler sürebilir. İndirme yarıda kalırsa betiği tekrar çalıştırman yeterli, kaldığı yerden devam eder. Betik her ZIM'in en yeni sürümünü Kiwix kataloğundan bulur, her indirmeden önce boş alanı kontrol eder ve inen dosyayı SHA-256 özetiyle doğrular. ```bash sudo ./scripts/download-content.sh ``` diff --git a/config/content.conf b/config/content.conf index ae005ab..55c8b14 100644 --- a/config/content.conf +++ b/config/content.conf @@ -11,7 +11,16 @@ wikipedia wikipedia_tr_all_maxi # ~9 GB wikipedia wikipedia_en_all_maxi # ~120 GB # wikipedia wikipedia_en_all_nopic # ~55 GB, resimsiz / no images (küçük diskler için / for small disks) +# --- Türkçe kitaplık / Turkish library --- +wiktionary wiktionary_tr_all_nopic # ~810 MB Vikisözlük (katalogda yalnız resimsiz var / only nopic exists) +wikibooks wikibooks_tr_all_maxi # ~27 MB Vikikitap: açık ders ve el kitapları / open textbooks +wikisource wikisource_tr_all_maxi # ~68 MB Vikikaynak: telifsiz metinler, kanunlar / public-domain texts +wikiquote wikiquote_tr_all_maxi # ~59 MB Vikisöz / quotations +ifixit ifixit_tr_all # ~3.6 GB iFixit Türkçe tamir rehberleri / repair guides in Turkish +phet phet_tr_all # ~107 MB PhET fizik-kimya simülasyonları / science simulations (TR) + # --- Hayatta kalma kitapları / Survival books --- +other appropedia_en_all_maxi # ~580 MB uygun teknoloji wiki: su, enerji, tarım / appropriate technology wiki other zimgit-post-disaster_en # ~615 MB afet sonrası kitaplığı / post-disaster library other zimgit-water_en # ~20 MB su arıtma / water treatment other zimgit-food-preparation_en # ~93 MB gıda hazırlama ve saklama / food for preppers @@ -21,10 +30,12 @@ zimit solar.lowtechmagazine.com_mul_all # ~670 MB düşük tekno # --- Sağlık / Health --- wikipedia wikipedia_en_medicine_maxi # ~2 GB WikiMed -other wikem_en_all_maxi # ~260 MB acil tıp / emergency medicine +# wikem_en_all_maxi Kiwix kataloğundan kaldırıldı (2026-10); yerine MDWiki + MedlinePlus. +# wikem_en_all_maxi was removed from the Kiwix catalog (2026-10); MDWiki + MedlinePlus cover it. other mdwiki_en_all_maxi # ~2.1 GB tıp ansiklopedisi / medical encyclopedia +zimit medlineplus.gov_en_all # ~1.9 GB MedlinePlus hasta bilgilendirme / patient information (US NLM) other zimgit-medicine_en # ~67 MB tıp kitapları / medical books -zimit fas-military-medicine_en # ~78 MB askeri sahra tıbbı / military field medicine +zimit irp.fas.org_en_military-medicine # ~65 MB askeri sahra tıbbı / military field medicine (eski ad / old name: fas-military-medicine_en) zimit nhs.uk_en_medicines # ~15 MB ilaç bilgileri / medicines A-Z # --- Tamir ve beceriler / Repair & skills --- diff --git a/scripts/download-content.sh b/scripts/download-content.sh index 1d59ae1..0df02c9 100755 --- a/scripts/download-content.sh +++ b/scripts/download-content.sh @@ -3,38 +3,93 @@ # Downloads the newest version of each ZIM in config/content.conf and adds it to Kiwix. # Yarıda kalırsa tekrar çalıştır, kaldığı yerden devam eder. / Re-run to resume. # +# Sürüm çözme: Kiwix OPDS kataloğu (library.kiwix.org) tek istekte tüm ZIM'lerin adını, boyutunu ve +# adresini verir; klasör listesi yalnızca katalog erişilemezse kullanılır. +# Version lookup: the Kiwix OPDS catalog returns every ZIM's name, size and URL in one request; +# the directory listing is only a fallback when the catalog is unreachable. +# Her dosya indirildikten sonra Kiwix'in yayımladığı .sha256 ile doğrulanır, bozuksa silinir. +# Each download is verified against the .sha256 Kiwix publishes next to it; a corrupt file is deleted. +# # Kullanım / usage: sudo ./scripts/download-content.sh [config-dosyası] +# Ortam / environment: DEST=/library/zims/content RESERVE_GB=5 (boş bırakılacak pay / headroom to keep free) set -uo pipefail [ "$EUID" -eq 0 ] || { echo "sudo ile çalıştır / run with sudo" >&2; exit 1; } CONF="${1:-$(cd "$(dirname "$0")/.." && pwd)/config/content.conf}" -DEST=/library/zims/content +DEST="${DEST:-/library/zims/content}" +RESERVE_GB="${RESERVE_GB:-5}" BASE=https://download.kiwix.org/zim +CATALOG_URL="${CATALOG_URL:-https://library.kiwix.org/catalog/v2/entries?count=-1}" +CAT=$(mktemp) +trap 'rm -f "$CAT"' EXIT mkdir -p "$DEST" mountpoint -q /library || echo "Uyarı / warning: /library ayrı bir disk değil / is not a separate disk (SD kart dolabilir / SD card may fill up)" +echo ">> Kiwix kataloğu alınıyor / fetching Kiwix catalog" +if ! curl -fsSL -m 300 "$CATALOG_URL" -o "$CAT"; then + echo "!! Katalog alınamadı, klasör listesine düşülüyor / catalog unreachable, falling back to directory listings" + CAT="" +fi + failed=0 while read -r folder prefix _; do case "$folder" in ''|\#*) continue;; esac - latest=$(curl -fsSL "$BASE/$folder/" | grep -oE "${prefix}_[0-9]{4}-[0-9]{2}[a-z]?\.zim" | sort -u | tail -1) - if [ -z "$latest" ]; then echo "!! $prefix bulunamadı / not found in $BASE/$folder/"; failed=1; continue; fi + url=""; size="" + if [ -n "$CAT" ]; then + # Katalog satırı / catalog line: href="https://.../zim//_YYYY-MM.zim.meta4" ... length="" + entry=$(grep -oE "href=\"https://[^\"]*/${prefix}_[0-9]{4}-[0-9]{2}[a-z]?\.zim\.meta4\"[^>]*length=\"[0-9]+\"" "$CAT" | sort -u | tail -1) + if [ -n "$entry" ]; then + url=$(sed -E 's/^href="([^"]*)\.meta4".*/\1/' <<<"$entry") + size=$(sed -E 's/.*length="([0-9]+)".*/\1/' <<<"$entry") + case "$url" in */zim/"$folder"/*) ;; *) echo " not / note: $prefix katalogda '$folder' klasöründe değil / is not under '$folder' in the catalog ($url)";; esac + fi + else + latest=$(curl -fsSL "$BASE/$folder/" | grep -oE "${prefix}_[0-9]{4}-[0-9]{2}[a-z]?\.zim" | sort -u | tail -1) + [ -n "$latest" ] && url="$BASE/$folder/$latest" + fi + if [ -z "$url" ]; then echo "!! $prefix bulunamadı / not found in the Kiwix catalog (ad değişmiş veya kaldırılmış olabilir / name may have changed or been retired)"; failed=1; continue; fi + latest=$(basename "$url") if [ -f "$DEST/$latest" ]; then echo "== $latest zaten var / already present"; continue; fi - echo ">> $latest indiriliyor / downloading" - df -h /library | tail -1 - if wget -c --progress=dot:giga -O "$DEST/$latest.part" "$BASE/$folder/$latest" < /dev/null; then - mv "$DEST/$latest.part" "$DEST/$latest" - echo "OK $latest tamamlandı / done" - # Eski sürümleri sil / remove older versions of the same ZIM - for old in "$DEST/${prefix}"_*.zim; do - [ "$old" != "$DEST/$latest" ] && [ -f "$old" ] && { echo "-- eski sürüm siliniyor / removing $old"; rm -f "$old"; } - done + # Yer kontrolü / free-space check: kalan boyut + pay / remaining bytes + headroom + [ -z "$size" ] && size=$(curl -sIL -m 30 "$url" | grep -i '^content-length:' | tail -1 | tr -dc '0-9') + have=0; [ -f "$DEST/$latest.part" ] && have=$(stat -c %s "$DEST/$latest.part") + avail=$(df -B1 --output=avail "$DEST" | tail -1 | tr -dc '0-9') + if [ -n "$size" ] && [ "$avail" -lt $((size - have + RESERVE_GB * 1024 * 1024 * 1024)) ]; then + echo "!! $latest için yer yok / not enough space: gerekli / needed $(((size - have) / 1024 / 1024)) MB + ${RESERVE_GB} GB pay / headroom, boş / free $((avail / 1024 / 1024)) MB" + failed=1; continue + fi + + sizetxt="boyut bilinmiyor / size unknown"; [ -n "$size" ] && sizetxt="$((size / 1024 / 1024)) MB" + echo ">> $latest indiriliyor / downloading ($sizetxt)" + df -h "$DEST" | tail -1 + if ! wget -c --progress=dot:giga -O "$DEST/$latest.part" "$url" < /dev/null; then + echo "!! $latest indirilemedi / download failed (tekrar çalıştır / re-run to resume)"; failed=1; continue + fi + + # SHA-256 doğrulama / verification + expected=$(curl -fsSL -m 60 "$url.sha256" 2>/dev/null | awk '{print $1}') + if [[ ! "$expected" =~ ^[0-9a-f]{64}$ ]]; then + echo " Uyarı / warning: $latest için .sha256 yayımlanmamış, doğrulanmadan kabul edildi / no .sha256 published, accepted unverified" else - echo "!! $latest indirilemedi / download failed (tekrar çalıştır / re-run to resume)"; failed=1 + echo " sha256 hesaplanıyor / verifying checksum" + actual=$(sha256sum "$DEST/$latest.part" | awk '{print $1}') + if [ "$actual" != "$expected" ]; then + echo "!! $latest sha256 uyuşmuyor, bozuk dosya silindi / checksum mismatch, corrupt file deleted (beklenen / expected $expected, bulunan / got $actual)" + rm -f "$DEST/$latest.part"; failed=1; continue + fi + echo " sha256 doğru / checksum OK" fi + + mv "$DEST/$latest.part" "$DEST/$latest" + echo "OK $latest tamamlandı / done" + # Eski sürümleri sil / remove older versions of the same ZIM + for old in "$DEST/${prefix}"_[0-9][0-9][0-9][0-9]-[0-9][0-9]*.zim; do + [ "$old" != "$DEST/$latest" ] && [ -f "$old" ] && { echo "-- eski sürüm siliniyor / removing $old"; rm -f "$old"; } + done done < "$CONF" echo ">> Kiwix kütüphanesi güncelleniyor / rebuilding Kiwix library" diff --git a/www/home/index.html b/www/home/index.html index 74a2501..8cc5214 100644 --- a/www/home/index.html +++ b/www/home/index.html @@ -131,6 +131,14 @@ { name:"Vikipedi (Türkçe)", desc:"Türkçe Vikipedi'nin resimli tam kopyası.", lang:"TR", size:"~9 GB", zim:"wikipedia_tr_all_maxi", search:true }, { name:"Wikipedia (English)", desc:"Tüm İngilizce Wikipedia, resimleriyle birlikte.", lang:"EN", size:"~120 GB", zim:"wikipedia_en_all_maxi", search:true }, ]}, + { title:"Türkçe Kitaplık", items:[ + { name:"Vikisözlük", desc:"Türkçe sözlük, köken bilgisi ve çeviriler.", lang:"TR", size:"~810 MB", zim:"wiktionary_tr_all", search:true }, + { name:"Vikikitap", desc:"Açık ders kitapları ve el kitapları.", lang:"TR", size:"~27 MB", zim:"wikibooks_tr_all" }, + { name:"Vikikaynak", desc:"Telifsiz metinler, kanunlar, klasikler.", lang:"TR", size:"~68 MB", zim:"wikisource_tr_all" }, + { name:"Vikisöz", desc:"Özlü sözler ve alıntılar.", lang:"TR", size:"~59 MB", zim:"wikiquote_tr_all" }, + { name:"iFixit (Türkçe)", desc:"Cihaz ve araç tamiri için Türkçe adım adım rehberler.", lang:"TR", size:"~3,6 GB", zim:"ifixit_tr_all", search:true }, + { name:"PhET Simülasyonları", desc:"Fizik, kimya ve matematik etkileşimli deneyleri.", lang:"TR", size:"~107 MB", zim:"phet_tr_all" }, + ]}, { title:"Haritalar ve Navigasyon", items:[ { name:"Dünya Haritası", desc:"Avrupa ve Orta Doğu sokak seviyesinde, dünyanın geri kalanı şehir seviyesinde.", lang:"—", size:"~40 GB", url:"/maps" }, ]}, @@ -141,13 +149,14 @@ { name:"Düğümler Kitaplığı", desc:"Düğüm çeşitleri ve kullanım alanları.", lang:"EN", size:"~27 MB", zim:"zimgit-knots_en" }, { name:"Ready.gov", desc:"ABD resmi afet hazırlık rehberleri: deprem, sel, yangın.", lang:"EN", size:"~1,9 GB", zim:"ready.gov_en_all", search:true }, { name:"Low-tech Magazine", desc:"Elektriksiz ve düşük teknolojili pratik çözümler.", lang:"EN", size:"~670 MB", zim:"solar.lowtechmagazine.com_mul_all" }, + { name:"Appropedia", desc:"Uygun teknoloji wiki'si: su, güneş enerjisi, tarım, barınak.", lang:"EN", size:"~580 MB", zim:"appropedia_en_all", search:true }, ]}, { title:"Sağlık ve İlk Yardım", items:[ { name:"WikiMed", desc:"Wikipedia'nın tıp maddeleri: hastalıklar, ilaçlar, anatomi.", lang:"EN", size:"~2 GB", zim:"wikipedia_en_medicine_maxi", search:true }, - { name:"WikEM", desc:"Acil tıp başvuru kaynağı.", lang:"EN", size:"~260 MB", zim:"wikem_en_all_maxi", search:true }, { name:"MDWiki", desc:"Doktorlar tarafından düzenlenen tıp ansiklopedisi.", lang:"EN", size:"~2 GB", zim:"mdwiki_en_all_maxi", search:true }, + { name:"MedlinePlus", desc:"ABD Ulusal Tıp Kütüphanesi hasta bilgilendirme sayfaları.", lang:"EN", size:"~1,9 GB", zim:"medlineplus.gov_en_all", search:true }, { name:"Tıp Kitaplığı", desc:"Temel tıp ve sağlık kitapları.", lang:"EN", size:"~67 MB", zim:"zimgit-medicine_en" }, - { name:"Askeri Sahra Tıbbı", desc:"Sahada travma ve yaralı bakımı.", lang:"EN", size:"~78 MB", zim:"fas-military-medicine_en" }, + { name:"Askeri Sahra Tıbbı", desc:"Sahada travma ve yaralı bakımı (FAS).", lang:"EN", size:"~65 MB", zim:"irp.fas.org_en_military-medicine" }, { name:"NHS İlaç Rehberi", desc:"İlaçların kullanımı, dozları ve yan etkileri.", lang:"EN", size:"~15 MB", zim:"nhs.uk_en_medicines" }, ]}, { title:"Tamir ve Beceriler", items:[