Skip to content

Commit

Permalink
Add ZFS filesystem module
Browse files Browse the repository at this point in the history
  • Loading branch information
igorpecovnik committed Dec 2, 2024
1 parent ab67aa6 commit 21c885c
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 0 deletions.
Binary file added tools/include/images/SY018.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions tools/json/config.system.json
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,26 @@
"status": "Stable",
"author": "@viraniac @igorpecovnik",
"condition": "[ -d /boot/dtb/ ]"
},
{
"id": "SY018",
"description": "ZFS filesystem - enable support",
"command": [
"module_zfs install"
],
"status": "Stable",
"author": "@armbian",
"condition": "! module_zfs status && linux-version compare ${KERNELID} le $(module_zfs kernel_max)"
},
{
"id": "SY019",
"description": "ZFS filesystem - remove support",
"command": [
"module_zfs remove"
],
"status": "Stable",
"author": "@armbian",
"condition": "module_zfs status"
}
]
}
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 @@ -97,6 +97,9 @@ update_sub_submenu_data "Software" "Media" "SW24" "https://localhost:$emby_media
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"

# ZSH show version in the menu
update_submenu_data "System" "SY019" "$(module_zfs zfs_version)"

update_sub_submenu_data "Software" "Containers" "CON006" "http://$LOCALIPADD:${module_options["module_portainer,port"]}"
update_sub_submenu_data "Software" "HomeAutomation" "HA004" "http://$LOCALIPADD:${module_options["module_haos,port"]}"

Expand Down
59 changes: 59 additions & 0 deletions tools/modules/system/install_zfs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
module_options+=(
["module_zfs,author"]="@armbian"
["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,port"]=""
["module_zfs,status"]="Active"
["module_zfs,arch"]=""
)
#
# Mmodule_zfs
#
function module_zfs () {
local title="zfs"
local condition=$(which "$title" 2>/dev/null)

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]}")
module_headers install
apt_install_wrapper apt-get -y install zfsutils-linux zfs-dkms || exit 1
;;
"${commands[1]}")
module_headers remove
apt_install_wrapper apt-get -y autopurge zfsutils-linux zfs-dkms || exit 1
;;
"${commands[2]}")
if check_if_installed zfsutils-linux; then
return 0
else
return 1
fi
;;
"${commands[3]}")
echo "${kernel_max}"
;;
"${commands[4]}")
echo "v${zfs_dkms}"
;;
"${commands[5]}")
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
;;
*)
${module_options["module_zfs,feature"]} ${commands[3]}
;;
esac
}

0 comments on commit 21c885c

Please sign in to comment.