#!/bin/sh

depmod -a
update-rc.d -s watchdog defaults
if ! grep -q watchdog /usr/sbin/install-image 2>&-; then
	# Patch in a security warning
	sed -e '2a\
if [ -n "$(pidof watchdog)" ]; then\
	echo "Disable the watchdog before flashing!"\
	echo "This may be done with these commands:"\
	echo\
	echo "chmod -x /etc/init.d/watchdog;reboot"\
	exit 1\
fi\
' /usr/sbin/install-image > /tmp/install-image.$$
	chmod +x /tmp/install-image.$$
	cp /tmp/install-image.$$ /usr/sbin/install-image
	rm /tmp/install-image.$$
fi
