vpnhide/zygisk/module/customize.sh
okhsunrog 12daca5c1a monorepo: combine vpnhide-zygisk, vpnhide (lsposed), and vpnhide-kmod
Unified repository for the complete Android VPN-hiding stack:
- zygisk/ — Rust Zygisk module (inline libc hooks via shadowhook)
- lsposed/ — Kotlin LSPosed module (Java API + system_server hooks)
- kmod/ — C kernel module (kretprobe hooks, invisible to anti-tamper)

CI workflows use path filters to build only the changed component.
2026-04-11 15:01:49 +03:00

53 lines
2.3 KiB
Bash

#!/system/bin/sh
# Installer hook run by KernelSU/Magisk. Called after the module files
# have been extracted to $MODPATH. Anything we write to $MODPATH persists
# into /data/adb/modules/<id>/ after the installer finishes.
SKIPUNZIP=0
ui_print "- VPN Hide (Zygisk native) v0.1.0"
ui_print "- Installing to $MODPATH"
# Make the native library readable/executable by zygote
set_perm "$MODPATH/zygisk/arm64-v8a.so" 0 0 0755
# ----------------------------------------------------------------------
# Persistent state directory
# ----------------------------------------------------------------------
# We deliberately store the user's targets list OUTSIDE the module
# directory. KSU/Magisk wipes the entire module dir on update, so anything
# under /data/adb/modules/vpnhide_zygisk/ would be lost every time the
# user installs a new build of the module. /data/adb/vpnhide_zygisk/ is
# never touched by the installer and persists across module updates and
# reboots.
PERSIST_DIR="/data/adb/vpnhide_zygisk"
PERSIST_TARGETS="$PERSIST_DIR/targets.txt"
LEGACY_TARGETS="/data/adb/modules/vpnhide_zygisk/targets.txt"
mkdir -p "$PERSIST_DIR"
set_perm "$PERSIST_DIR" 0 0 0755
# One-shot migration: when the new persistent file does not exist yet
# but the legacy in-module file does, copy the user's existing list over
# before the staged install dir replaces /data/adb/modules/vpnhide_zygisk/.
# This works because customize.sh runs while the OLD module directory is
# still on disk — KSU/Magisk only swaps the staged dir into place after
# this script returns successfully.
if [ ! -f "$PERSIST_TARGETS" ] && [ -f "$LEGACY_TARGETS" ]; then
cp "$LEGACY_TARGETS" "$PERSIST_TARGETS"
ui_print "- Migrated existing targets list from previous install"
fi
# Seed an empty file on a truly fresh install so the WebUI has something
# to read on first open.
if [ ! -f "$PERSIST_TARGETS" ]; then
cat > "$PERSIST_TARGETS" <<'EOF'
# vpnhide-zygisk target allowlist
# One package name per line. Lines starting with '#' are comments.
# Managed via the module's WebUI in the KernelSU-Next manager.
EOF
fi
set_perm "$PERSIST_TARGETS" 0 0 0644
ui_print "- Targets list: $PERSIST_TARGETS (preserved across updates)"
ui_print "- Pick target apps via the module's WebUI, then reboot or"
ui_print " force-stop them to take effect."