Files
driver-manager/service.sh
sssnake b88141a9c5 Driver Manager v2.0.0 - LSPosed-style rewrite
Complete rewrite with:
- Per-app driver scoping via mount namespace isolation (LSPosed-style)
- System-wide driver mode selection
- .ko kernel module manager with autoload and dependency tracking
- Driver integrity protection (monitor/enforce modes)
- Driver registry with auto-discovery and SHA256 hashing
- LSPosed-style dark WebUI with 6 tabs: Dashboard, Drivers, Apps, Modules, Protection, Logs
- RESTful API handler for WebUI communication
- Zygote process monitor for auto-applying scopes to new app launches

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-03 06:01:07 -07:00

64 lines
2.0 KiB
Bash

#!/system/bin/sh
# Driver Manager v2 - Main Service
# Runs after boot_completed
MODDIR=${0%/*}
LOGFILE="$MODDIR/logs/service.log"
CONFIGDIR="$MODDIR/config"
. "$MODDIR/scripts/core.sh"
log_init "$LOGFILE"
log "Service starting"
# Wait for boot to complete
while [ "$(getprop sys.boot_completed)" != "1" ]; do
sleep 1
done
sleep 3
log "Boot completed, initializing"
# --- Run driver scan if registry doesn't exist ---
if [ ! -f "$CONFIGDIR/drivers.json" ] || [ ! -s "$CONFIGDIR/drivers.json" ]; then
log "No driver registry found, running initial scan"
sh "$MODDIR/scripts/driver_registry.sh" scan
fi
# --- Create protection baseline if missing ---
if [ ! -f "$CONFIGDIR/baseline.json" ] || [ ! -s "$CONFIGDIR/baseline.json" ]; then
log "No protection baseline found, creating"
sh "$MODDIR/scripts/protect.sh" baseline
fi
# --- Load kernel modules from autoload list ---
log "Loading kernel modules"
sh "$MODDIR/scripts/ko_manager.sh" autoload
# --- Apply driver scopes ---
log "Applying driver scopes"
sh "$MODDIR/scripts/scope_manager.sh" apply
# --- Start protection monitor ---
SETTINGS=$(cat "$CONFIGDIR/settings.json" 2>/dev/null)
PROT_MODE=$(echo "$SETTINGS" | grep -o '"protection_mode"[[:space:]]*:[[:space:]]*"[^"]*"' | grep -o '"[^"]*"$' | tr -d '"')
if [ "$PROT_MODE" = "monitor" ] || [ "$PROT_MODE" = "enforce" ]; then
log "Starting protection monitor (mode: $PROT_MODE)"
sh "$MODDIR/scripts/protect.sh" watch &
echo $! > "$MODDIR/run/protect.pid"
fi
# --- Monitor Zygote for new app launches (apply per-app scopes) ---
MONITOR_ZYGOTE=$(echo "$SETTINGS" | grep -o '"monitor_zygote"[[:space:]]*:[[:space:]]*[a-z]*' | grep -o '[a-z]*$')
if [ "$MONITOR_ZYGOTE" = "true" ]; then
log "Starting Zygote process monitor for per-app scoping"
sh "$MODDIR/scripts/scope_manager.sh" monitor &
echo $! > "$MODDIR/run/scope_monitor.pid"
fi
log "Service initialization complete"
# --- Keep service alive for API calls ---
while true; do
sleep 86400
done