create /var/run in firstboot
[openwrt.git] / openwrt / package / base-files / default / 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 >&- 2>&-
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 case "${file%/*}" in
46 "usr/lib/ipkg/info"|"etc/config") cp -f /rom/$file $file;;
47 *) ln -sf /rom/$file $file;;
48 esac
49 } done
50 echo "done"
51
52 touch /tmp/resolv.conf
53 ln -s /tmp/resolv.conf /etc/resolv.conf
54
55 umount /rom
56 mount none /jffs/proc -t proc
57 pivot_root /jffs /jffs/rom
58 mount none /dev -t devfs
59 mount none /tmp -t ramfs
60 umount /rom/proc
61 umount /rom/tmp
62 umount /rom/dev
63
64 # normally created by boot script
65 mkdir -p /var/run
This page took 0.044388 seconds and 5 git commands to generate.