diff options
author | Iacopo Isimbaldi <isiachi@rhye.it> | 2016-01-15 02:22:55 +0100 |
---|---|---|
committer | Iacopo Isimbaldi <isiachi@rhye.it> | 2016-01-15 02:23:07 +0100 |
commit | 693ba6e8a6f15556be2a1bfd247f614475688d16 (patch) | |
tree | d642dd79a3532a6f32c645f1ad86c09206d7c8e5 | |
parent | remove myself from maintainers (diff) | |
download | zfs-dkms-693ba6e8a6f15556be2a1bfd247f614475688d16.tar.xz |
Updated zfs.install
Now invoke mkinitcpio if "zfs" hook is present in mkinitcpio.conf file
-rw-r--r-- | zfs.install | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/zfs.install b/zfs.install index 28e3d16..6cba9a6 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 +} |