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