Files
honoka-chan/android/scripts/prepare_runtime_zip.sh
T
YumeMichi 91bbc7f607 Add Android control app and embedded server
Inspired by HNKServer/honoka-chan-apk-server, but implemented as a JNI-based embedded runtime instead of the original approach.

- Add an Android Compose controller app that starts and stops honoka-chan through JNI, shows runtime and health status, manages data directory mounting, and supports backup import/export for data.db
- Add an embeddable Go server entrypoint plus JNI-exported status, health, and reload hooks so desktop and Android builds share the same startup and shutdown path
- Add Android build scripts, runtime packaging, and project documentation, including generated default config.json content for honoka_runtime.zip
- Add runtime bundle hash tracking so updated honoka_runtime.zip assets are automatically redeployed while preserving config.json and user data files
- Add in-app service settings for unlock_all_special_rotation with immediate config persistence and automatic reload when the service is running
- Split SQLite driver selection by platform, using go-sqlite3 on Android and modernc.org/sqlite elsewhere to avoid Android x86_64 seccomp crashes
- Update startup, database initialization, and system health/reload handlers to support the embedded runtime and Android control flow

Signed-off-by: Sean Du <do4suki@gmail.com>
2026-06-12 19:17:21 +08:00

59 lines
1.1 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/common.sh"
require_cmd zip
ZIP_PATH="$ANDROID_DIR/app/src/main/assets/honoka_runtime.zip"
cd "$PROJECT_ROOT"
ensure_file "$PROJECT_ROOT/assets/main.db"
TMP_DIR="$(mktemp -d)"
trap 'rm -rf "$TMP_DIR"' EXIT
mkdir -p "$TMP_DIR/assets" "$TMP_DIR/static"
log "collecting runtime files"
cat > "$TMP_DIR/config.json" <<'EOF'
{
"app_name": "honoka-chan",
"settings": {
"listen_port": "8080",
"cdn_server": "http://127.0.0.1:8080/static",
"reload_token": "",
"unlock_all_special_rotation": false
}
}
EOF
cp -r "$PROJECT_ROOT/assets/main.db" "$TMP_DIR/assets/main.db"
for path in \
"assets/serverdata" \
"assets/certs" \
"static/templates" \
"static/css" \
"static/js" \
"static/images" \
"static/font"
do
if [[ -e "$PROJECT_ROOT/$path" ]]; then
mkdir -p "$TMP_DIR/$(dirname "$path")"
cp -r "$PROJECT_ROOT/$path" "$TMP_DIR/$path"
fi
done
rm -f "$ZIP_PATH"
log "packing $ZIP_PATH"
(
cd "$TMP_DIR"
zip -qr "$ZIP_PATH" assets static config.json
)
log "runtime zip ready: $ZIP_PATH"