fix typo
[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 --no-persistent --coldplug --set-rules-file /etc/hotplug2-init.rules
27 M0=/dev/ptmx
28 M1=/dev/ptmx
29 HOTPLUG=
30 fi
31
32 mkdir -p /dev/pts /dev/shm
33 mount none /dev/pts -t devpts
34
35 # the shell really doesn't like having stdin/out closed
36 # that's why we use /dev/pty/m0 and m1 as replacement
37 # for /dev/console if there's no serial console available
38 dd if=/dev/console of=/dev/null bs=1 count=0 >/dev/null 2>/dev/null && {
39 M0=/dev/console
40 M1=/dev/console
41 }
42
43 exec <$M0 >$M1 2>&0
44
45 {
46 echo "- preinit -"
47 [ -e /etc/preinit.arch ] && . /etc/preinit.arch
48 set_state preinit
49
50 echo "$HOTPLUG" > /proc/sys/kernel/hotplug
51
52 eval ${FAILSAFE:+failsafe}
53 lock -w /tmp/.failsafe
54
55 mount_root
56
57 echo "- init -"
58 } | tee /tmp/preinit.log
59
60 exec /sbin/init
This page took 0.047616 seconds and 5 git commands to generate.