init commit

This commit is contained in:
Luxferre
2026-10-19 09:23:54 +03:00
commit 6942acf5cf
307 changed files with 35003 additions and 0 deletions
Executable
+43
View File
@@ -0,0 +1,43 @@
#!/bin/sh
set -eu
BASE_DIR="$(cd "$(dirname "$0")" && pwd)"
PYTHON_BIN="${PYTHON_BIN:-python3}"
FLASHER_PY="$BASE_DIR/flash-edl.py"
for arg in "$@"; do
if [ "$arg" = "-h" ] || [ "$arg" = "--help" ]; then
exec "$PYTHON_BIN" "$FLASHER_PY" "$@"
fi
done
if [ "$(id -u)" -ne 0 ]; then
if command -v sudo >/dev/null 2>&1; then
echo "[*] Elevating privileges via sudo for raw USB EDL (05c6:9008) access..."
exec sudo "$0" "$@"
else
echo "[!] Warning: Not running as root and 'sudo' not found. Continuing..."
fi
fi
MM_WAS_ACTIVE=0
if command -v systemctl >/dev/null 2>&1; then
if systemctl is-active --quiet ModemManager 2>/dev/null; then
echo "[*] Temporarily stopping host ModemManager service during EDL flash..."
systemctl stop ModemManager 2>/dev/null || true
MM_WAS_ACTIVE=1
fi
fi
cleanup() {
if [ -n "${SUDO_UID:-}" ] && [ -n "${SUDO_GID:-}" ] && [ -d "$BASE_DIR/backup" ]; then
chown -R "$SUDO_UID:$SUDO_GID" "$BASE_DIR/backup" 2>/dev/null || true
fi
if [ "$MM_WAS_ACTIVE" -eq 1 ]; then
echo "[*] Restarting host ModemManager service..."
systemctl start ModemManager 2>/dev/null || true
fi
}
trap cleanup EXIT INT TERM
"$PYTHON_BIN" "$FLASHER_PY" "$@"