blob: cdf82a6e9b91277dea4c0c70b2b09666275a5649 (
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 spl/${1%%[_-]*}
check_hostid
cat << EOF
==> To build and install your modules run: dkms install spl/${1%%[_-]*} -k [KERNEL]
==> To do this automatically at startup run: systemctl enable dkms.service
EOF
}
pre_upgrade() {
if [ "${1%%[-_]*}" != "${2%%[-_]*}" ]; then
pre_remove "$2"
fi
}
post_upgrade() {
if [ "${1%%[-_]*}" != "${2%%[-_]*}" ]; then
post_install "$1"
fi
}
pre_remove() {
[ -n "${1%%[_-]*}" ] && dkms remove spl/${1%%[_-]*} --all -q || true
}
check_hostid() {
# Check /etc/hostid to see if it set to the sentinel value, see
# https://wiki.archlinux.org/index.php/ZFS for more information.
HOSTID=$(hostid)
if [ "0x$HOSTID" == "0xffffffff" ]; then
# Generate a new hostid
: >/etc/hostid
HOSTID=$(hostid)
# hostid is 4 byte little endian
printf $(echo -n $HOSTID | sed 's/\(..\)\(..\)\(..\)\(..\)/\\x\4\\x\3\\x\2\\x\1/') >/etc/hostid
fi
}
|