summarylogtreecommitdiffstats
path: root/zfs.install
diff options
context:
space:
mode:
Diffstat (limited to 'zfs.install')
-rw-r--r--zfs.install55
1 files changed, 55 insertions, 0 deletions
diff --git a/zfs.install b/zfs.install
index 28e3d168232..6cba9a63700 100644
--- a/zfs.install
+++ b/zfs.install
@@ -3,7 +3,9 @@ post_install() {
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_hook
}
pre_upgrade() {
@@ -21,3 +23,56 @@ post_upgrade() {
pre_remove() {
[ -n "${1%%[-_]*}" ] && dkms remove zfs/${1%%[-_]*} --all -q || true
}
+
+post_remove() {
+ check_hook remove
+}
+
+check_hook() {
+ ZFSHOOKFILES=()
+
+ for preset in /etc/mkinitcpio.d/*.preset; do
+ source $preset
+ CONF_FILE=()
+
+ if [ -n "${ALL_config}" ]; then
+ CONF_FILE+=("${ALL_config}")
+ unset ALL_config
+ fi
+
+ for prefix in ${PRESETS[@]}; do
+ varname="${prefix}_config"
+ if [ -n "$(eval echo \$$varname)" ]; then
+ eval CONF_FILE+=("$(eval echo \$$varname)")
+ unset $varname
+ fi
+ done
+
+ i=0
+ unset ZFSHOOKPRESENCE
+ while [ $i -lt ${#CONF_FILE[@]} ]; do
+ if [ -e "${CONF_FILE[$i]}" ] && [ $(grep -q "zfs" ${CONF_FILE[$i]} && echo -n "1") ]; then
+ ZFSHOOKPRESENCE=1
+ if [ "$1" == "remove" ] && [ $(echo -n "${ZFSHOOKFILES[@]}" | grep -q "${CONF_FILE[$i]}" || echo -n "1") ]; then
+ ZFSHOOKFILES+=("${CONF_FILE[$i]}")
+ fi
+ fi
+ i+=1
+ done
+
+ if [ ${ZFSHOOKPRESENCE} ]; then
+ if [ "$1" != "remove" ]; then
+ echo "==> Generating initial ramdisk for $(basename "$preset" .preset), using mkinitcpio. Please wait..."
+ mkinitcpio -p $(basename "$preset" .preset)
+ fi
+ fi
+ done
+
+ if [ "$1" == "remove" ] && [ ${#ZFSHOOKFILES[@]} -gt 0 ]; then
+ echo "==> zfs-dkms package has been removed but \"zfs\" is still in the hooks list of:"
+ for file in ${ZFSHOOKFILES[@]}; do
+ echo " -> ${file}"
+ done
+ echo "==> Remove \"zfs\" and generate a new initrd."
+ fi
+}