#!/bin/bash

# called by dracut
check() {
    # if we don't have btrfs installed on the host system,
    # no point in trying to support it in the initramfs.
    require_binaries btrfs || return 1

    [[ $hostonly ]] || [[ $mount_needs ]] && {
        for fs in "${host_fs_types[@]}"; do
            [[ $fs == "btrfs" ]] && return 0
        done
        return 255
    }

    return 0
}

# called by dracut
depends() {
    echo udev-rules initqueue
    return 0
}

# called by dracut
install() {
    inst_rules "$moddir/81-btrfs-wait.rules"
    inst_script "$moddir/btrfs_device_ready.sh" /sbin/btrfs_finished_pw
    inst_hook pre-mount 10 "$moddir/btrfs_pre_mount.sh"
    inst /usr/sbin/sleep
}
