#!/bin/bash
# Derived from grub-btrfs-overlayfs in Antynea/grub-btrfs.

build() {
    map add_module 'btrfs' 'overlay'

    # _hooks is the complete hook set computed by mkinitcpio before build hooks
    # run, so this remains correct regardless of relative hook ordering.
    # shellcheck disable=SC2154
    if in_array systemd "${_hooks[@]}"; then
        add_file '/usr/lib/systemd/system/systemd-volatile-root.service'
        add_binary '/usr/lib/systemd/systemd-volatile-root'
        return
    fi

    add_binary btrfs
    add_binary btrfsck
    add_binary blkid
    add_runscript
}

help() {
    cat <<HELPEOF
This hook uses overlayfs to boot on a read only snapshot.
HELPEOF
}

# vim: set ft=sh ts=4 sw=4 et:
