#!/usr/bin/ash

run_earlyhook() {
    mkdir /run/lvm
    lvmetad
}

# We suffer a race condition without systemd: if lvmetad is killed before
# pvscan processes finish, we have stale processes and uninitialized physical
# volume. Wait up to 10 seconds for pvscan to finish.
run_latehook() {
    local i=50

    while [ $i -gt 0 ] && pgrep -f pvscan >/dev/null 2>/dev/null; do
        sleep 0.2
        i=$((i - 1))
    done
}

run_cleanuphook() {
    kill $(cat /run/lvmetad.pid)
}

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