From f9293037257eae8dd1b42d5de9599dfe1dfea5b8 Mon Sep 17 00:00:00 2001 From: Igor Pecovnik Date: Fri, 6 Dec 2024 19:27:52 +0100 Subject: [PATCH] Apply several fixes to ZFS --- tools/json/config.system.json | 4 +-- .../functions/set_runtime_variables.sh | 3 ++ tools/modules/runtime/config.runtime.sh | 3 ++ .../modules/system/module_armbian_firmware.sh | 6 ++-- tools/modules/system/module_zfs.sh | 33 +++++++++++-------- 5 files changed, 30 insertions(+), 19 deletions(-) diff --git a/tools/json/config.system.json b/tools/json/config.system.json index 6e383e95b..411a54ab3 100644 --- a/tools/json/config.system.json +++ b/tools/json/config.system.json @@ -24,7 +24,7 @@ ], "status": "Stable", "author": "@igorpecovnik", - "condition": "! module_armbian_firmware hold status" + "condition": "#! module_armbian_firmware hold status" }, { "id": "SY003", @@ -55,7 +55,7 @@ ], "status": "Stable", "author": "@igorpecovnik", - "condition": "module_armbian_firmware headers status" + "condition": "#module_armbian_firmware headers status" }, { "id": "SY006", diff --git a/tools/modules/functions/set_runtime_variables.sh b/tools/modules/functions/set_runtime_variables.sh index 64d82043c..27ba271c7 100644 --- a/tools/modules/functions/set_runtime_variables.sh +++ b/tools/modules/functions/set_runtime_variables.sh @@ -60,6 +60,9 @@ function set_runtime_variables() { BACKTITLE="Contribute: https://github.com/armbian/configng" TITLE="Armbian configuration utility" [[ -z "${DEFAULT_ADAPTER// /}" ]] && DEFAULT_ADAPTER="lo" + # zfs subsystem - determine if our kernel is not too recent + ZFS_DKMS_VERSION=$(LC_ALL=C apt-cache policy zfs-dkms | grep Candidate | xargs | cut -d" " -f2 | cut -c-5) + ZFS_KERNEL_MAX=$(wget -qO- https://github.com/openzfs/zfs/raw/refs/tags/zfs-${ZFS_DKMS_VERSION}/META | grep Maximum | cut -d" " -f2) # detect desktop check_desktop diff --git a/tools/modules/runtime/config.runtime.sh b/tools/modules/runtime/config.runtime.sh index d5fb48d3c..ecba32484 100644 --- a/tools/modules/runtime/config.runtime.sh +++ b/tools/modules/runtime/config.runtime.sh @@ -94,6 +94,9 @@ fi #plex_media_port="$(lsof -i -P -n | grep TCP | grep LISTEN | grep 'plex' | awk -F: '{print $2}' | awk '{print $1}' | head -n 1)" #update_sub_submenu_data "Software" "Media" "SW22" "https://localhost:$plex_media_port" +update_submenu_data "System" "SY018" "$(module_zfs zfs_version)" +update_submenu_data "System" "SY019" "$(module_zfs zfs_installed_version)" + update_sub_submenu_data "Software" "Database" "DAT002" "Server: $LOCALIPADD" update_sub_submenu_data "Software" "Database" "DAT006" "http://$LOCALIPADD:${module_options["module_phpmyadmin,port"]}" update_sub_submenu_data "Software" "Media" "MED006" "http://$LOCALIPADD:${module_options["module_stirling,port"]}" diff --git a/tools/modules/system/module_armbian_firmware.sh b/tools/modules/system/module_armbian_firmware.sh index d9bb68343..853c08e65 100644 --- a/tools/modules/system/module_armbian_firmware.sh +++ b/tools/modules/system/module_armbian_firmware.sh @@ -42,7 +42,7 @@ function module_armbian_firmware() { done ) local installed_kernel_version=$(dpkg -l | grep '^ii' | grep linux-image | awk '{print $2"="$3}' | head -1) - + # workaroun in case current is not installed [[ -n ${installed_kernel_version} ]] && local grep_current_kernel=" | grep -v ${installed_kernel_version}" @@ -269,8 +269,8 @@ function module_armbian_firmware() { apt_install_wrapper apt-get install "linux-headers-$(uname -r | sed 's/'-$(dpkg --print-architecture)'//')" fi elif [[ "${command}" == "remove" ]]; then - ${module_options["module_armbian_firmware,feature"]} ${commands[2]} "" "${version}" "hide" "" "true" - apt_install_wrapper apt-get -y autopurge ${packages[@]} + ${module_options["module_armbian_firmware,feature"]} ${commands[2]} "" "${version}" "hide" "" "true" + apt_install_wrapper apt-get -y autopurge ${packages[@]} else ${module_options["module_armbian_firmware,feature"]} ${commands[2]} "" "${version}" "hide" "" "true" if check_if_installed ${packages[@]}; then diff --git a/tools/modules/system/module_zfs.sh b/tools/modules/system/module_zfs.sh index 538373289..239622af3 100644 --- a/tools/modules/system/module_zfs.sh +++ b/tools/modules/system/module_zfs.sh @@ -1,14 +1,14 @@ module_options+=( - ["module_zfs,author"]="@armbian" + ["module_zfs,author"]="@igorpecovnik" ["module_zfs,feature"]="module_zfs" ["module_zfs,desc"]="Install zfs filesystem support" - ["module_zfs,example"]="install remove status kernel_max zfs_version help" + ["module_zfs,example"]="install remove status kernel_max zfs_version zfs_installed_version help" ["module_zfs,port"]="" ["module_zfs,status"]="Active" ["module_zfs,arch"]="" ) # -# Mmodule_zfs +# Module OpenZFS # function module_zfs () { local title="zfs" @@ -17,20 +17,17 @@ function module_zfs () { local commands IFS=' ' read -r -a commands <<< "${module_options["module_zfs,example"]}" - # determine if our kernel is not too recent - local zfs_dkms=$(LC_ALL=C apt-cache policy zfs-dkms | grep Candidate | xargs | cut -d" " -f2 | cut -c-5) - local kernel_max=$(wget -qO- https://github.com/openzfs/zfs/raw/refs/tags/zfs-${zfs_dkms}/META | grep Maximum | cut -d" " -f2) - case "$1" in "${commands[0]}") + # headers are needed, lets install then if they are not there already if ! module_armbian_firmware headers status; then module_armbian_firmware headers install fi - apt_install_wrapper DEBIAN_FRONTEND=noninteractive apt-get -y install zfsutils-linux zfs-dkms || exit 1 + DEBIAN_FRONTEND=noninteractive apt-get -y install zfsutils-linux zfs-dkms ;; "${commands[1]}") - module_headers remove - apt_install_wrapper apt-get -y autopurge zfsutils-linux zfs-dkms || exit 1 + module_armbian_firmware headers remove + apt_install_wrapper apt-get -y autopurge zfsutils-linux zfs-dkms ;; "${commands[2]}") if check_if_installed zfsutils-linux; then @@ -40,22 +37,30 @@ function module_zfs () { fi ;; "${commands[3]}") - echo "${kernel_max}" + echo "${ZFS_KERNEL_MAX}" ;; "${commands[4]}") - echo "v${zfs_dkms}" + echo "v${ZFS_DKMS_VERSION}" ;; "${commands[5]}") + if check_if_installed zfsutils-linux; then + zfs --version 2>/dev/null| head -1 | cut -d"-" -f2 + fi + ;; + "${commands[6]}") echo -e "\nUsage: ${module_options["module_zfs,feature"]} " echo -e "Commands: ${module_options["module_zfs,example"]}" echo "Available commands:" echo -e "\tinstall\t- Install $title." - echo -e "\tstatus\t- Installation status $title." echo -e "\tremove\t- Remove $title." + echo -e "\tstatus\t- Installation status $title." + echo -e "\kernel_max\t- Determine maximum version of kernel to support $title." + echo -e "\zfs_version\t- Gets $title version from Git." + echo -e "\zfs_installed_version\t- Read $title module info." echo ;; *) - ${module_options["module_zfs,feature"]} ${commands[3]} + ${module_options["module_zfs,feature"]} ${commands[6]} ;; esac }