From 1036ce9c5b2bd3c57deaebf191e5cda8a7c6302d Mon Sep 17 00:00:00 2001
From: hygienic-books <hygienic-books@tentic.net>
Date: Fri, 17 Jan 2025 21:08:44 +0100
Subject: [PATCH] fix(zfs): Install ZFS only when needed (#26)

In situations where this script runs on alternative Arch Linux live
CD ISOs such as github.com/stevleibelt/arch-linux-live-cd-iso-with
-zfs we may not have to insall ZFS kernel modules. Test if the 'zfs'
module is loaded and skip installation if yes.
---
 setup.sh | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/setup.sh b/setup.sh
index 955ce5e..7cd7172 100644
--- a/setup.sh
+++ b/setup.sh
@@ -451,7 +451,12 @@ function install_pkgs () {
 function install_zfs () {
     #1.6
     declare reset_colors='\033[0m'
-    curl -s 'https://raw.githubusercontent.com/eoli3n/archiso-zfs/master/init' | bash
+    if modinfo 'zfs' &>/dev/null; then
+        >&3 printf -- '%s\n' \
+            'ZFS kernel module is loaded, no need to install ...'
+    else
+        curl -s 'https://raw.githubusercontent.com/eoli3n/archiso-zfs/master/init' | bash
+    fi
     printf -- "${reset_colors}"
 }