#!/bin/sh

# uncomment the following line as needed
#insmod nand.ko

dd if=7800.mbr of=/dev/mtdblock0
if test "$?" != "0"; then
  exit 3
fi

mtdcopy ImageKernel 1 0
if test "$?" != "0"; then
  exit 3
fi

mtdcopy 7800initrd 2 0
if test "$?" != "0"; then
  exit 3
fi

eraseall /dev/mtd3 > /dev/null 2>&1
if test "$?" != "0"; then
  exit 3
fi

mkdir tmp
mount -t yaffs2 /dev/mtdblock3 tmp
if test "$?" != "0"; then
  exit 3
fi

cd tmp
tar -xzf ../sarge-7800.tar.gz
if test "$?" != "0"; then
  exit 3
fi

md5sum -c ../files.md5
if test "$?" != "0"; then
  exit 3
fi

cd ..
umount tmp
if test "$?" != "0"; then
  exit 3
fi
