#!/bin/bash

# carry on with the script in case of error
set +e

# kill the startup process if it hasn't completed yet
killall rcS &>/dev/null || true

# write buffers to disk
/bin/sync

# allow the shutdown script 20 seconds to shut down,
# after which we stop feeding the watchdog
(sleep 20 && /usr/bin/killall -STOP watchdog) &

# actual poweroff command
/bin/busybox poweroff
