obmc-initfs shutdown: ping watchdog watchdog during flash update

Add code to start a watchdog daemon before calling the update script
as erasing the flash can take over 10 minutes.  This allows us to
reduce the shutdown timeout to a much more useful value.

The code kills the watchdog after the update script returns and
also resets the timeout to a different value by invoking and killing
the watchdog command a second time.

Tested with the following code added before the reboot -f code and
changing the timoeuts:

	while :
	do
		let count=$count+1
		echo -ne "\rloop $count"
		usleep 100
	done

Change-Id: Ibe2337339af67421733230b6a5b6df962618a00a
Signed-off-by: Milton Miller <miltonm@us.ibm.com>
diff --git a/common/recipes-phosphor/initfs/files/obmc-shutdown.sh b/common/recipes-phosphor/initfs/files/obmc-shutdown.sh
index 90e5dfb..c91f5ef 100644
--- a/common/recipes-phosphor/initfs/files/obmc-shutdown.sh
+++ b/common/recipes-phosphor/initfs/files/obmc-shutdown.sh
@@ -33,10 +33,21 @@
 update=/run/initramfs/update
 image=/run/initramfs/image-
 
+wdt="-t 1 -T 5"
+wdrst="-T 15"
+
 if ls $image* > /dev/null 2>&1
 then
 	if test -x $update
 	then
+		if test -c /dev/watchdog
+		then
+			echo Pinging watchdog ${wdt+with args $wdt}
+			watchdog $wdt -F /dev/watchdog &
+			wd=$!
+		else
+			wd=
+		fi
 		$update --clean-saved-files
 		remaining=$(ls $image*)
 		if test -n "$remaining"
@@ -46,6 +57,20 @@
 		else
 			echo "Flash update completed."
 		fi
+
+		if test -n "$wd"
+		then
+			kill -9 $wd
+			if test -n "$wdrst"
+			then
+				echo Reseting watchdog timeouts to $wdrst
+				watchdog $wdrst -F /dev/watchdog &
+				sleep 1
+				# Kill the watchdog daemon, setting a timeout
+				# for the remaining shutdown work
+				kill -9 $!
+			fi
+		fi
 	else
 		echo 1>&2 "Flash update requested but $update program missing!"
 	fi