HEX
Server: nginx/1.18.0
System: Linux mail.dakarash.co.id 5.15.0-164-generic #174-Ubuntu SMP Fri Nov 14 20:25:16 UTC 2025 x86_64
User: www-data (33)
PHP: 8.1.2-1ubuntu2.23
Disabled: NONE
Upload Files
File: //usr/local/sbin/maildir_gunzip_in_tree.sh
#!/usr/bin/env bash
set -euo pipefail
ROOT="${1:-}"
if [[ -z "$ROOT" || ! -d "$ROOT" ]]; then
  echo "Usage: $0 /path/to/maildir_root"; exit 1
fi
echo "[*] Scan & decompress if gzip (magic 1f8b)..."
# note: nama file Maildir harus tetap — hanya kontennya yang diganti.
while IFS= read -r -d '' f; do
  # Baca 2 byte pertama
  magic=$(head -c2 "$f" | od -An -tx1 | tr -d ' \n')
  if [[ "$magic" == "1f8b" ]]; then
    tmp="$f.__tmp__"
    if gzip -cd -- "$f" > "$tmp" 2>/dev/null; then
      mv -f -- "$tmp" "$f"
      echo "unzipped: $f"
    else
      rm -f -- "$tmp" 2>/dev/null || true
      echo "WARN: gagal unzip (biarkan apa adanya): $f"
    fi
  fi
done < <(find "$ROOT" -type f -print0)
echo "[*] Done."