HEX
Server: LiteSpeed
System: Linux ip-172-31-76-142.ec2.internal 4.14.158-129.185.amzn2.x86_64 #1 SMP Tue Dec 24 03:15:32 UTC 2019 x86_64
User: 69b4844ae61d4e92bf26ad98af552775 (1065)
PHP: 7.2.27
Disabled: exec,passthru,shell_exec,system,eval
Upload Files
File: //lib/dracut/modules.d/90multipath-hostonly/module-setup.sh
#!/bin/bash

# called by dracut
check() {
    return 255
}

# called by dracut
depends() {
    echo multipath
    return 0
}

# called by dracut
install() {
    local _f _allow

    is_mpath() {
        local _dev=$1
        [ -e /sys/dev/block/$_dev/dm/uuid ] || return 1
        [[ $(cat /sys/dev/block/$_dev/dm/uuid) =~ mpath- ]] && return 0
        return 1
    }

    majmin_to_mpath_dev() {
        local _dev
        for i in /dev/mapper/*; do
            [[ $i == /dev/mapper/control ]] && continue
            _dev=$(get_maj_min $i)
            if [ "$_dev" = "$1" ]; then
                echo $i
                return
            fi
        done
    }

    add_hostonly_mpath_conf() {
        is_mpath $1 && {
            local _dev

            _dev=$(majmin_to_mpath_dev $1)
            [ -z "$_dev" ] && return
            strstr "$_allow" "$_dev" && return
            _allow="$_allow --allow $_dev"
        }
    }

    [[ $hostonly ]] && {
        for_each_host_dev_and_slaves_all add_hostonly_mpath_conf
        [ -n "$_allow" ] && mpathconf $_allow --outfile ${initdir}/etc/multipath.conf
    }
}