summaryrefslogtreecommitdiffstats
path: root/meta-linaro/recipes-core/initrdscripts/files/init-boot-linaro.sh
blob: 2af2f929e4f1c7c78d78466a0849079d46fb144a (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
#!/bin/sh

HOME=/root
PATH=/sbin:/bin:/usr/sbin:/usr/bin
PS1="linaro-test [rc=$(echo \$?)]# "
export HOME PS1 PATH

early_setup() {
    mkdir -p /proc /sys /tmp /run
    mount -t proc proc /proc
    mount -t sysfs sysfs /sys
    mount -t devtmpfs none /dev

    ln -s /run /var/run

    chmod 0666 /dev/tty*
    chown root:tty /dev/tty*
}

read_args() {
    [ -z "$CMDLINE" ] && CMDLINE=`cat /proc/cmdline`
    for arg in $CMDLINE; do
        optarg=`expr "x$arg" : 'x[^=]*=\(.*\)'`
        case $arg in
            console=*)
                tty=${arg#console=}
                tty=${tty#/dev/}

                case $tty in
                    tty[a-zA-Z]* )
                        port=${tty%%,*}
                esac ;;
            debug) set -x ;;
        esac
    done
}

early_setup
read_args

setsid sh </dev/${port} >/dev/${port} 2>&1