#!/bin/sh
#	$Id: rcS,v 1.7 2007/10/25 21:58:06 jwessel Exp $
# This is a minmal rcS file for target startup
# Make sure that /proc is mounted.
/bin/mount -n -o remount,ro /
/bin/mount -n /proc
/bin/mount -n /var
/bin/mount -n /etc

##/bin/mkdir /mnt 0777 root system
##/bin/mkdir /mnt/sdcard 0777 system system
 

(
   cd /etc
   ln -s ../etc.ro/* .
   ln -s /proc/mounts mtab
)

/bin/mount -a

cd /
#/bin/cat start.bmp > /dev/fb0

chmod ugo+rwx,o+t /tmp


dd if=/dev/zero of=/dev/fb0 bs=2400 count=480
#dd if=/dev/zero of=/dev/fb0 bs=2400 count=480
/sbin/start_udev
/bin/showlogo start.rle
# Assign an address to the loopback device.
ifconfig lo 127.0.0.1 up

# copy /bin/ff4 to /tmp/ff4
################/bin/cp /bin/ff4 /tmp/ff4
/bin/mount -o loop -t ext3 /dev/mmcblk0p6 /mnt

sleep 1
cd /mnt
/bin/ls -l
/bin/rm -rf data
/bin/rm -rf app-private  
/bin/rm -rf backup  
/bin/rm -rf dalvik-cache
/bin/rm -rf drm
/bin/rm -rf local
/bin/rm -rf misc
/bin/rm -rf property
/bin/rm -rf resource-cache
/bin/rm -rf system
/bin/rm -rf user
/bin/rm -rf app

sleep 10
/bin/ls -l 
cd /
cd /mnt
/bin/ls -l
cd /
sync
sleep 6
sync
/bin/umount /mnt
sleep 6

/bin/showlogo ok.rle
#/bin/cat ok.bmp > /dev/fb0
cd /
cd /
###MMC_TYPE=`cat /sys/block/mmcblk1/device/type`
##if [ "$MMC_TYPE" = "SD" ]; then
##    /bin/mkdir /tmp/sd
##
##    MOUNT_SD=`ls /dev/mmcblk1p1`
##    if [ "$MOUNT_SD" = "/dev/mmcblk1p1" ]; then
##        /bin/mount -t vfat -o codepage=932,iocharset=euc-jp,sync /dev/mmcblk1p1 /tmp/sd
##    else
##        /bin/mount -t vfat -o codepage=932,iocharset=euc-jp,sync /dev/mmcblk1 /tmp/sd
##    fi
    # copy ff4 from /tmp/sd/ff4 to /tmp/ff4
##    FF_EXE=`ls /tmp/sd/ff4`
##    if [ "$FF_EXE" = "/tmp/sd/ff4" ]; then
##        /bin/cp /tmp/sd/ff4 /tmp/ff4
##    fi

##    INSTALL_SH=`ls /tmp/sd/install.sh`
##    if [ "$INSTALL_SH" = "/tmp/sd/install.sh" ]; then
##        /tmp/sd/install.sh
##    fi

##    /bin/umount /tmp/sd
##    /bin/rmdir /tmp/sd
##fi

# execute factorymode
##/tmp/ff4 &

# Startup any daemon scripts
#for e in `ls /etc/rcS.d/S* 2> /dev/null`; do
#	$e
#done
#exit 0
