massive rewrite of firstboot
[openwrt/svn-archive/archive.git] / openwrt / package / base-files / default / sbin / mount_root
1 #!/bin/sh
2 is_dirty() {
3 grep Broadcom /proc/cpuinfo >&- || return 1
4 OFFSET="$(($(hexdump -v /dev/mtdblock/1 -s 20 -n 2 -e '"%d"')-1))"
5 return $(hexdump -v /dev/mtdblock/1 -s $OFFSET -n 1 -e '"%d"')
6 }
7
8 if [ "$1" != "failsafe" -a "$(nvram get no_root_swap)" != 1 ]; then
9 mtd unlock linux
10 mount | grep jffs2 >&-
11 if [ $? = 0 ] ; then
12 if [ $(cat /proc/mtd | wc -l) = 6 ]; then
13 mtd erase OpenWrt
14 jffs2root --move
15 else
16 mount -o remount,rw /dev/root /
17 fi
18 else
19 is_dirty
20 if [ $? = 0 ]; then
21 firstboot ramoverlay >&- 2>&-
22 else
23 mount /dev/mtdblock/4 /jffs
24 pivot_root /jffs /jffs/rom
25 mount none /proc -t proc
26 umount /rom/proc
27 mount -o move /rom/dev /dev
28 fi
29 fi
30 fi
31
32 mount none /tmp -t tmpfs -o nosuid,nodev,mode=1777,size=50%
33 mkdir -p /dev/pts
34 mount none /dev/pts -t devpts
35 mount -t sysfs none /sys 2>&-