merge of '07a342693675fe2b1daacf0eb62302579d9fade3'
[org.openembedded.dev.git] / packages / initscripts / initscripts-1.0 / openprotium / flashclean
blobd9a0e1b592a9877ef1e7008fd871590f34e20ef3
1 #! /bin/sh
3 # This is an init script for openprotium for storcenter
4 #
5 # This script cleansup after a successful uboot based reflash.
6 # A uboot reflash is done by changing the bootloader boot command
7 # to tftp a flash image and flash the firmware. However the boot command
8 # is never reset back to a regular boot. This way if the flash did
9 # not work the next power cycle will cause another reflash. A nice
10 # development recovery feature. So this boot script is the mechanism
11 # to reset the uboot boot command. Once booted and access it validated
12 # this script will issue command to reset the boot command.
14 # This command only has a start so stop is not necessary and should
15 # as late in the boot process as possible to ensure a successful reboot
17 # Copy it to /etc/init.d/flashclean and type
18 # update-rc.d flashclean start 99 5
20 BOOTCMD="bootm FF800000"
22 dmesg | grep StorCenter >/dev/null 2>&1
23 if [ $? -ne 0 ]; then
24 exit 0
27 printenv=/sbin/fw_printenv
28 setenv=/sbin/fw_setenv
29 test -x "$printenv" -a -x "$setenv" || exit 0
31 case "$1" in
32 start)
33 # Check to see if any work needs to be done
34 # Need to quote the right hand side, hence the ugly awk.
35 eval `$printenv bootcmd | awk -F= '{printf("%s=\"%s\"", $1, $2)}'`
36 if [ "$bootcmd" = "$BOOTCMD" ]; then
37 exit 0
40 echo -n "Restoring u-Boot bootcmd"
41 $setenv bootcmd $BOOTCMD > /dev/null 2>&1
42 eval `$printenv bootcmd | awk -F= '{printf("%s=\"%s\"", $1, $2)}'`
43 if [ "$bootcmd" != "$BOOTCMD" ]; then
44 echo " FAILED."
45 exit 1
47 echo "."
49 stop)
51 reload|force-reload)
53 restart)
56 echo "Usage: /etc/init.d/flashclean {start|stop|reload|restart|force-reload}"
57 exit 1
58 esac
60 exit 0