]> git.ipfire.org Git - thirdparty/dracut.git/blame - modules.d/95nbd/module-setup.sh
Factor out all the "type -V" commands
[thirdparty/dracut.git] / modules.d / 95nbd / module-setup.sh
CommitLineData
95d2dabc
HH
1#!/bin/bash
2# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
3# ex: ts=8 sw=4 sts=4 et filetype=sh
4
8bcfd683 5# called by dracut
95d2dabc 6check() {
29b10e65 7 local _rootdev
95d2dabc 8 # If our prerequisites are not met, fail.
30e6e809 9 require_binaries nbd-client || return 1
95d2dabc 10
3b403b32 11 # if an nbd device is not somewhere in the chain of devices root is
95d2dabc 12 # mounted on, fail the hostonly check.
7f347723 13 [[ $hostonly ]] || [[ $mount_needs ]] && {
95d2dabc 14 is_nbd() { [[ -b /dev/block/$1 && $1 == 43:* ]] ;}
95d2dabc 15
29b10e65
HH
16 _rootdev=$(find_root_block_device)
17 [[ -b /dev/block/$_rootdev ]] || return 1
c2ab9909 18 check_block_and_slaves is_nbd "$_rootdev" || return 255
95d2dabc
HH
19 }
20
21 return 0
22}
23
8bcfd683 24# called by dracut
95d2dabc
HH
25depends() {
26 # We depend on network modules being loaded
27 echo network rootfs-block
28}
29
8bcfd683 30# called by dracut
95d2dabc
HH
31installkernel() {
32 instmods nbd
33}
34
8bcfd683 35# called by dracut
95d2dabc
HH
36install() {
37 inst nbd-client
38 inst_hook cmdline 90 "$moddir/parse-nbdroot.sh"
53fe81e7 39 inst_script "$moddir/nbdroot.sh" "/sbin/nbdroot"
41eba87b 40 dracut_need_initqueue
95d2dabc
HH
41}
42