summaryrefslogtreecommitdiffstats
path: root/init
blob: 72452c1623005ce452225801fb9b623232cdb769 (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
#!/bin/sh

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

msg ":: Begin Initramfs"

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

CMDLINE=$(/bin/cat /proc/cmdline)

for cmd in $CMDLINE; do
    case "$cmd" in
        *=*) export "${cmd}" ;;
        *) export "${cmd}=y" ;;
    esac
done

#this should be part of the 'base' hook
msg -n "Loading pci modules..."
/bin/modprobe -a -q $(/bin/cat /sys/bus/pci/devices/*/modalias) >/dev/null 2>&1 &
msg "done."

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

. /config

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

msg -n ":: Loading root filesystem module..."
if [ "x${rootfstype}" != "x" ]; then
    FSTYPE="${rootfstype}"
else
    if [ "x${root}" != "x" ]; then
        msg "Attempting mkrootdev ${root}"
        if /bin/mkrootdev "${root}"; then
            eval $(/bin/fstype < /dev/root)
        else
            FSTYPE="unknown"
            echo "ERROR: mkrootdev failed. Try passing the rootfstype= parameter to the kernel."
        fi
    else
        FSTYPE="unknown"
        echo "ERROR: root fs cannot be detected. Use the rootfstype= kernel parameter..."
    fi
fi
msg "fs=${FSTYPE}"
/bin/modprobe -q "${FSTYPE}" 2>&1 >/dev/null

if [ "${break}" = "y" ]; then
    echo ":: Break requested, type 'exit' to resume operation"
    PS1="ramfs$ " /bin/sh -i
fi

# Optimize fs type loop for mounting rootfs
msg ":: End Initramfs - control passing to kinit"
exec /bin/kinit rootfstype=${FSTYPE} $CMDLINE < /dev/console > /dev/console