#!/bin/sh
# startup stuff
export PATH=/usr/gnu/bin:/usr/local/bin:/bin:/usr/bin:/bin:/sbin
/sbin/devfsd /dev
/sbin/mount -t proc none /proc -n
/installer /first.png&
/bin/buttonquery
/bin/busybox killall -9 installer

# format nand
/installer /second.png&
/sbin/mkyaffs /dev/mtd/3
/bin/busybox killall -9 installer

# copy stuff to nand
/installer /third.png&
/sbin/mount -t yaffs /dev/mtdblock/3 /mnt -n
cd /mnt
/bin/busybox tar xzvf /o2xfs.tar.gz
/bin/busybox sync
cd /
/bin/busybox umount /mnt
/bin/busybox killall -9 installer

# clean up SD
/bin/busybox rm -f /gp2xkernel.img
/bin/busybox mv /gp2xkernel_flashme.img /gp2xkernel.img
/bin/busybox sync

# done!
/installer /done.png&
/bin/sh
