upgrade the lzma-loader
[openwrt.git] / openwrt / target / default / target_skeleton / bin / firstboot
1 #!/bin/sh
2 # $Id$
3
4
5 [ -f "/tmp/.firstboot" ] && {
6 echo "firstboot is already running"
7 return
8 }
9 touch /tmp/.firstboot
10
11 jdev=$(mount | awk '/jffs2/ {print $3}')
12
13 if [ -z "$jdev" ]; then
14 echo -n "Creating jffs2 partition... "
15 mtd erase OpenWrt >&-
16 mount -t jffs2 /dev/mtdblock/4 /jffs
17 echo "done"
18 cd /jffs
19 else
20 echo "firstboot has already been run"
21 echo "jffs2 partition is mounted, only resetting files"
22 cd $jdev
23 fi
24
25 exec 2>/dev/null
26
27 mount /dev/mtdblock/2 /rom -o ro
28
29 echo -n "creating directories... "
30 {
31 cd /rom
32 find . -type d
33 cd -
34 } | xargs mkdir
35 echo "done"
36
37 echo -n "setting up symlinks... "
38 for file in $(cd /rom; find * -type f; find * -type l;)
39 do {
40 [ "${file%/*}" = "usr/lib/ipkg/info" ] && {
41 cp -f /rom/$file $file
42 } || {
43 ln -sf /rom/$file $file
44 }
45 } done
46 echo "done"
47
48 echo -n "fixing ipkg symlinks... "
49 for file in $( find /usr/lib/ipkg/info/*list -type l;)
50 do {
51 rm $file; cp -f /rom/$file $file
52 } done
53
54 touch /tmp/resolv.conf
55 ln -s /tmp/resolv.conf /etc/resolv.conf
56
57 umount /rom
58 mount none /jffs/proc -t proc
59 pivot_root /jffs /jffs/rom
60 mount none /dev -t devfs
61 mount none /tmp -t ramfs
62 umount /rom/proc
63 umount /rom/tmp
64 umount /rom/dev
This page took 0.05236 seconds and 5 git commands to generate.