]> git.ipfire.org Git - thirdparty/dracut.git/blob - modules.d/90btrfs/module-setup.sh
80a538fd574469c2455861af9a8a473965dcc665
[thirdparty/dracut.git] / modules.d / 90btrfs / 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 # called by dracut
6 check() {
7 local _rootdev
8 # if we don't have btrfs installed on the host system,
9 # no point in trying to support it in the initramfs.
10 type -P btrfs >/dev/null || return 1
11
12 [[ $hostonly ]] || [[ $mount_needs ]] && {
13 for fs in ${host_fs_types[@]}; do
14 [[ "$fs" == "btrfs" ]] && return 0
15 done
16 return 255
17 }
18
19 return 0
20 }
21
22 # called by dracut
23 depends() {
24 echo udev-rules
25 return 0
26 }
27
28 # called by dracut
29 installkernel() {
30 instmods btrfs
31 }
32
33 # called by dracut
34 install() {
35 if ! inst_rules 64-btrfs.rules; then
36 inst_rules "$moddir/80-btrfs.rules"
37 case "$(btrfs --help)" in
38 *device\ ready*)
39 inst_script "$moddir/btrfs_device_ready.sh" /sbin/btrfs_finished ;;
40 *)
41 inst_script "$moddir/btrfs_finished.sh" /sbin/btrfs_finished ;;
42 esac
43 fi
44
45 if ! dracut_module_included "systemd"; then
46 inst_hook initqueue/timeout 10 "$moddir/btrfs_timeout.sh"
47 fi
48
49 inst_multiple -o btrfsck btrfs-zero-log
50 inst $(command -v btrfs) /sbin/btrfs
51 }
52