base-files: add support for staged sysupgrades from failsafe mode
[openwrt/openwrt.git] / package / base-files / files / lib / preinit / 40_run_failsafe_hook
1 #!/bin/sh
2 # Copyright (C) 2006-2010 OpenWrt.org
3 # Copyright (C) 2010 Vertical Communications
4
5 run_failsafe_hook() {
6 [ "$pi_preinit_no_failsafe" = "y" ] && return
7 if [ "$FAILSAFE" = "true" ]; then
8 lock /tmp/.failsafe
9 boot_run_hook failsafe
10 while [ ! -e /tmp/sysupgrade ]; do
11 lock -w /tmp/.failsafe
12 done
13 exit
14 fi
15 }
16
17 boot_hook_add preinit_main run_failsafe_hook