dracut-functions: make local vars local and prefix with "_"
[platform/upstream/dracut.git] / modules.d / 95nbd / module-setup.sh
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
5 check() {
6     local _rootdev
7     # If our prerequisites are not met, fail.
8     type -P nbd-client >/dev/null || return 1
9
10     # if an nbd device is not somewhere in the chain of devices root is
11     # mounted on, fail the hostonly check.
12     [[ $hostonly ]] && {
13         is_nbd() { [[ -b /dev/block/$1 && $1 == 43:* ]] ;}
14         . $dracutfunctions
15
16         _rootdev=$(find_root_block_device)
17         [[ -b /dev/block/$_rootdev ]] || return 1
18         check_block_and_slaves is_nbd "$_rootdev" || return 1
19     }
20
21     return 0
22 }
23
24 depends() {
25     # We depend on network modules being loaded
26     echo network rootfs-block
27 }
28
29 installkernel() {
30     instmods nbd
31 }
32
33 install() {
34     inst nbd-client
35     inst_hook cmdline 90 "$moddir/parse-nbdroot.sh"
36
37     inst "$moddir/nbdroot" "/sbin/nbdroot"
38 }
39