summarylogtreecommitdiffstats
path: root/zfs.install
blob: cd9d8543376927cccbd88f7ec529b58010840da3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
post_install() {
    dkms add zfs/${1%%[-_]*}
    cat << EOF
==> To build and install your modules run: dkms install zfs/${1%%[_-]*} -k [KERNEL]
==> To do this automatically at startup run: systemctl enable dkms.service
EOF
    check_initramfs "install"
}

pre_upgrade() {
    pre_remove "$2"
}

post_upgrade() {
    post_install "$1"
}

pre_remove() {
    [ -n "${1%%[-_]*}" ] && dkms remove zfs/${1%%[-_]*} --all &>/dev/null || true
}

post_remove() {
    check_initramfs "remove"
}

check_initramfs() {
    if grep -v '#' /etc/mkinitcpio.conf | grep zfs >/dev/null; then
        if [[ $1 == 'remove' ]]; then
            echo '==> The ZFS packages have been removed, but "zfs" remains in the "hooks"'
            echo '==> list in mkinitcpio.conf! You will need to remove "zfs" from the '
            echo '==> "hooks" list and then regenerate the initial ramdisk.'
        else
            echo '==> The ZFS packages are installed/updated, you need to (re)generate initial ramdisk yourself'
            echo '==> After modules are built and installed, run: mkinitcpio -p [PRESET]'
        fi
    fi
}