Skip to content

Commit

Permalink
Apply several fixes to ZFS
Browse files Browse the repository at this point in the history
  • Loading branch information
igorpecovnik committed Dec 6, 2024
1 parent 5c61cda commit 19a1a0e
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 17 deletions.
3 changes: 3 additions & 0 deletions tools/modules/functions/set_runtime_variables.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions tools/modules/runtime/config.runtime.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"]}"
Expand Down
6 changes: 3 additions & 3 deletions tools/modules/system/module_armbian_firmware.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"

Expand Down Expand Up @@ -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
Expand Down
33 changes: 19 additions & 14 deletions tools/modules/system/module_zfs.sh
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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
Expand All @@ -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"]} <command>"
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
}

0 comments on commit 19a1a0e

Please sign in to comment.