#!/bin/sh
# we want to reboot if ever the nfs root is lost.
set -e
on_exit()
{
    echo "[bg] walt-nfs-watchdog exited! What happened?? Let's reboot!"
    reboot -f
}

trap on_exit EXIT
echo "[bg] walt-nfs-watchdog started."

while [ 1 ]
do
    /bin/walt-timeout 20 ls -l mnt/nfsroot/bin/walt-init >/dev/null || {
        echo "[bg] NFS share was lost! Will reboot."
        sleep 5
        reboot -f
    }
    sleep 5
done
