aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/find_1st_vfat.sh
blob: 677cc1313b546f5f669f19a2e6c56fd77628c6ae (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
#!/bin/sh

find_blkpart() {
    local fstype_exp="$1"
    local res=""
    local blkparts=$(lsblk -l | grep part | cut -d" " -f1)
    if [ -z "${blkparts}" ]; then
        # May take some time on PC's after loading device modules (usb, ..)
        local blkpartwait=180
        while [ "$(time_elapsed)" -lt "$blkpartwait" ]; do
            blkparts=$(lsblk -l | grep part | cut -d" " -f1)
            if [ -n "${blkparts}" ]; then
                break
            fi
            sleep 1
        done
        if [ -z "${blkparts}" ]; then
            panic "loop_rootfs: Block devices did not appear in time"
            exit 1
        fi
    fi
    for i in ${blkparts} ; do
        local FSTYPE=$(blkid -o value -s TYPE /dev/$i)
        if [ "${FSTYPE}" = "${fstype_exp}" ]; then
            res="/dev/$i"
            break
        fi
    done
    echo -n "${res}"
}

BLKDEV=$(find_blkpart vfat)
echo "BLKDEV ${BLKDEV}"