+# $Id$
+
+
+[ -f "/tmp/.firstboot" ] && {
+ echo "firstboot is already running"
+ return
+}
+touch /tmp/.firstboot
+
+jdev=$(mount | awk '/jffs2/ {print $3}')
+
+if [ -z "$jdev" ]; then
+ echo -n "Creating jffs2 partition... "
+ mtd erase OpenWrt >&-
+ mount -t jffs2 /dev/mtdblock/4 /jffs
+ echo "done"
+ cd /jffs
+else
+ echo "firstboot has already been run"
+ echo "jffs2 partition is mounted, only resetting files"
+ cd $jdev
+fi