summaryrefslogtreecommitdiffstats
path: root/init_functions
blob: 72bf6ae5b5e63b2af3125e7e6786c9526a4ae5b7 (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
# This file contains common functions used in init and in hooks

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

poll_device() {
    device="$1"
    if [ "$2" -gt 0 ]; then
        seconds="$2"
    else
        seconds=5
    fi
    echo "Waiting ${seconds} seconds for device ${device} ..."
    while [ ! -b "${device}" -a ! -h "${device}" -a ${seconds} -gt 0 ]; do
        sleep 1
        seconds=$((${seconds}-1))
    done
    [ -b "${device}" -o -h "${device}" ]
}

launch_interactive_shell() {
    PS1='[ramfs \W]\$ '
    [ "$1" = "--exec" ] && exec /bin/sh -i
    /bin/sh -i
}