2005-03-23 15:31:22 +02:00
|
|
|
#!/bin/sh
|
2006-04-05 05:09:22 +03:00
|
|
|
is_dirty() {
|
|
|
|
grep Broadcom /proc/cpuinfo >&- || return 1
|
|
|
|
OFFSET="$(($(hexdump -v /dev/mtdblock/1 -s 20 -n 2 -e '"%d"')-1))"
|
|
|
|
return $(hexdump -v /dev/mtdblock/1 -s $OFFSET -n 1 -e '"%d"')
|
2005-10-22 22:54:33 +03:00
|
|
|
}
|
|
|
|
|
2006-04-05 05:09:22 +03:00
|
|
|
size=$(awk '/Mem:/ {l=5242880;print((s=$2/2)<l)?$2-l:s}' /proc/meminfo)
|
|
|
|
mount none /tmp -t tmpfs -o size=$size
|
|
|
|
|
2005-03-23 15:31:22 +02:00
|
|
|
if [ "$1" != "failsafe" ]; then
|
2006-04-05 05:09:22 +03:00
|
|
|
mtd unlock linux
|
2005-03-23 15:31:22 +02:00
|
|
|
mount | grep jffs2 >&-
|
|
|
|
if [ $? = 0 ] ; then
|
2005-05-04 17:35:13 +03:00
|
|
|
if [ $(cat /proc/mtd | wc -l) = 6 ]; then
|
2005-03-23 15:31:22 +02:00
|
|
|
mtd erase OpenWrt
|
|
|
|
jffs2root --move
|
2005-05-04 17:35:13 +03:00
|
|
|
else
|
|
|
|
mount -o remount,rw /dev/root /
|
|
|
|
fi
|
2005-03-23 15:31:22 +02:00
|
|
|
else
|
2006-04-05 05:09:22 +03:00
|
|
|
. /bin/firstboot
|
|
|
|
is_dirty
|
|
|
|
[ $? != 0 ] && {
|
2006-04-09 00:11:49 +03:00
|
|
|
echo "switching to jffs2"
|
|
|
|
mount /dev/mtdblock/4 /jffs -t jffs2
|
2006-04-05 05:09:22 +03:00
|
|
|
pivot /jffs /rom
|
2006-04-09 00:11:49 +03:00
|
|
|
} || {
|
|
|
|
echo "jffs2 unusable; using ramdisk"
|
|
|
|
ramoverlay
|
|
|
|
}
|
2005-03-23 15:31:22 +02:00
|
|
|
fi
|
|
|
|
fi
|
2006-04-05 05:09:22 +03:00
|
|
|
|
|
|
|
mount none /tmp -t tmpfs -o remount,nosuid,nodev,mode=1777
|
2005-03-23 15:31:22 +02:00
|
|
|
mkdir -p /dev/pts
|
|
|
|
mount none /dev/pts -t devpts
|
2006-04-05 05:09:22 +03:00
|
|
|
mount -t sysfs none /sys 2>&-
|