summaryrefslogtreecommitdiffstats
path: root/init
blob: 7bdac5b06aa7021c34cc183fb33f41c7adfb9353 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/bin/sh

msg () { [ "${quiet}" != "y" ] && echo $@; }
err () { echo "ERROR: $@"; }

msg ":: Loading Initramfs"

/bin/mount -t sysfs none /sys
/bin/mount -t proc  none /proc

read CMDLINE </proc/cmdline
export CMDLINE

# Used so hooks can override params to kinit
export root=""
export rootdelay="0"
export kinit_params=""
echo "/bin/modprobe" > /proc/sys/kernel/modprobe

for cmd in $CMDLINE; do
    case "$cmd" in
        [0123456Ss]) continue ;;
        *=*) export "${cmd}" ;;
        *) export "${cmd}=y" ;;
    esac
done

OLDIFS=$IFS
IFS=,
if [ "x${disablehooks}" != "x" ]; then
    for d in ${disablehooks}; do
        export "hook_${d}=disabled"
    done
fi

if [ "x${disablemodules}" != "x" ]; then
    for d in ${disablemodules}; do
        export "mod_${d}=disabled"
    done
fi
IFS=$OLDIFS

. /config

for m in $MODULES; do
    TST=""
    eval "TST=\$mod_${h}"
    if [ "${TST}" != "disabled" ]; then
        /bin/modprobe -q $m > /dev/null 2>&1
    fi
done

if [ -e "/hooks" ]; then
    for h in $HOOKS; do
        TST=""
        eval "TST=\$hook_${h}"
        if [ "${TST}" != "disabled" ]; then
            run_hook () { msg "$h: no run function defined"; }
            if [ -e "/hooks/$h" ]; then
               . /hooks/$h
               msg ":: Running Hook [${h}]"
               run_hook
            fi
        fi
    done
fi

if [ "${break}" = "y" ]; then
    echo ":: Break requested, type 'exit' to resume operation"
    echo "   NOTE: klibc contains no 'ls' binary, used 'echo *' instead"
    PS1="ramfs$ " /bin/sh -i
fi

#Special handling is udev is running
udevpid=$(/bin/minips -C udevd -o pid=)
if [ "x${udevpid}" != "x" ]; then
    /bin/kill -9 $udevpid
    /bin/sleep 0.01
fi

# Optimize fs type loop for mounting rootfs
msg ":: Initramfs Completed - control passing to kinit"

echo "/sbin/modprobe" > /proc/sys/kernel/modprobe
exec /bin/kinit "root=${root}" "rootdelay=${rootdelay}" ${kinit_params} < /dev/console > /dev/null 2>&1