base-files: add support for staged sysupgrades from failsafe mode
[openwrt/openwrt.git] / package / base-files / files / lib / preinit / 40_run_failsafe_hook
index 7301f77349a1a1e42fcef9bcbc927ef55c83b991..533b0a9771e1aac603f00ecf7a4622ea9fee969d 100644 (file)
@@ -5,8 +5,12 @@
 run_failsafe_hook() {
     [ "$pi_preinit_no_failsafe" = "y" ] && return
     if [ "$FAILSAFE" = "true" ]; then
+       lock /tmp/.failsafe
        boot_run_hook failsafe
-       lock -w /tmp/.failsafe
+       while [ ! -e /tmp/sysupgrade ]; do
+           lock -w /tmp/.failsafe
+       done
+       exit
     fi
 }