From f1c436e881722cd599442f062c193a6cb3f300a7 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 13 Sep 2025 22:09:30 +0000 Subject: [PATCH] Add reboot wrapper script to fix overlay sync issue for Ingenic T40N Co-authored-by: flyrouter <68112357+flyrouter@users.noreply.github.com> --- general/overlay/usr/bin/reboot | 79 ++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100755 general/overlay/usr/bin/reboot diff --git a/general/overlay/usr/bin/reboot b/general/overlay/usr/bin/reboot new file mode 100755 index 00000000..b8fb3a33 --- /dev/null +++ b/general/overlay/usr/bin/reboot @@ -0,0 +1,79 @@ +#!/bin/sh +# +# OpenIPC reboot wrapper script +# Ensures proper overlay sync before reboot +# + +# Check for help/info flags first - pass through immediately +for arg in "$@"; do + case "$arg" in + -h|--help|--version) + # Find the real busybox reboot command + if [ -x /bin/busybox ]; then + exec /bin/busybox reboot "$@" + elif [ -x /usr/bin/busybox ]; then + exec /usr/bin/busybox reboot "$@" + else + # Fallback to system reboot + exec /sbin/reboot "$@" + fi + ;; + esac +done + +# Parse arguments to check for force flag and no-sync flag +force_reboot=0 +no_sync=0 +delay=0 +for arg in "$@"; do + case "$arg" in + -f|--force) + force_reboot=1 + ;; + -n) + no_sync=1 + ;; + -d) + # Get next argument as delay value + shift + delay="$1" + ;; + -d*) + # Extract delay value from -d format + delay="${arg#-d}" + ;; + esac +done + +# If not a forced reboot and sync is not disabled, ensure proper sync +if [ "$force_reboot" -eq 0 ] && [ "$no_sync" -eq 0 ]; then + echo "Syncing overlay filesystem..." + sync + + # Give a brief moment for sync to complete + sleep 1 + + # Attempt graceful shutdown by stopping services + if [ -f /etc/init.d/rcK ]; then + echo "Stopping services gracefully..." + /etc/init.d/rcK >/dev/null 2>&1 + fi + + # Final sync + sync +fi + +# Handle delay if specified +if [ "$delay" -gt 0 ]; then + sleep "$delay" +fi + +# Call the actual reboot command - find busybox location +if [ -x /bin/busybox ]; then + exec /bin/busybox reboot "$@" +elif [ -x /usr/bin/busybox ]; then + exec /usr/bin/busybox reboot "$@" +else + # Fallback to system reboot + exec /sbin/reboot "$@" +fi \ No newline at end of file