fix failsafe on broadcom, send netlink events in diag when running linux 2.6
[openwrt.git] / package / base-files / files / etc / preinit
1 #!/bin/sh
2 # Copyright (C) 2006 OpenWrt.org
3 export PATH=/bin:/sbin:/usr/bin:/usr/sbin
4 . /etc/diag.sh
5
6 failsafe() {
7 lock /tmp/.failsafe
8 ash --login
9 }
10
11 mount none /proc -t proc
12 mount none /sys -t sysfs
13
14 size=$(awk '/MemTotal:/ {l=5242880;mt=($2*1024);print((s=mt/2)<l)?mt-l:s}' /proc/meminfo)
15 mount none /tmp -t tmpfs -o size=$size,nosuid,nodev,mode=1777
16
17 if grep devfs /proc/filesystems > /dev/null; then
18 mount none /dev -t devfs
19 M0=/dev/pty/m0
20 M1=/dev/pty/m1
21 HOTPLUG=/sbin/hotplug-call
22 else
23 mount -t tmpfs tmpfs /dev -o size=512K
24 mknod /dev/console c 5 1
25 mkdir /dev/shm
26 /sbin/hotplug2 --coldplug --set-rules-file /etc/hotplug2-init.rules
27 /sbin/hotplug2 --no-coldplug --persistent --set-rules-file /etc/hotplug2-init.rules &
28 M0=/dev/ptmx
29 M1=/dev/ptmx
30 HOTPLUG=
31 fi
32
33 mkdir -p /dev/pts /dev/shm
34 mount none /dev/pts -t devpts
35
36 # the shell really doesn't like having stdin/out closed
37 # that's why we use /dev/pty/m0 and m1 as replacement
38 # for /dev/console if there's no serial console available
39 dd if=/dev/console of=/dev/null bs=1 count=0 >/dev/null 2>/dev/null && {
40 M0=/dev/console
41 M1=/dev/console
42 }
43
44 exec <$M0 >$M1 2>&0
45
46 echo "- preinit -"
47
48 [ -e /etc/preinit.arch ] && . /etc/preinit.arch
49 set_state preinit
50 echo "$HOTPLUG" > /proc/sys/kernel/hotplug
51 eval ${FAILSAFE:+failsafe}
52 lock -w /tmp/.failsafe
53 mount_root
54
55 echo "- init -"
56
57 killall hotplug2
58 exec /sbin/init
This page took 0.054682 seconds and 5 git commands to generate.