From 046b5ca191328790f75b8b4994b71ec118b4bcdb Mon Sep 17 00:00:00 2001 From: JRGTH Date: Sun, 19 Dec 2021 20:02:24 -0400 Subject: [PATCH] Add patch to improve ZFS activation, contributed by disaster --- CHANGELOG | 1 + bastille-init | 22 +++++++++++++++++----- version | 2 +- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 28ced42..1d84022 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,6 +3,7 @@ ====================== Version Description +1.1.03......Add patch to improve ZFS activation, contributed by disaster. 1.1.02......Create required dir for templates link creation. 1.1.01......Cosmetic changes, update maintenance page. 1.1.00......Initial support for Linux jails(experimental). diff --git a/bastille-init b/bastille-init index 8bd5543..4ce30eb 100755 --- a/bastille-init +++ b/bastille-init @@ -44,6 +44,8 @@ CWDIR=$(dirname $(realpath $0)) # Global variables. CWDIR_TRIM="" +BASTILLE_ZFS_ZPOOL_MOUNTPOINT="" +BASTILLE_ZFS_ZPOOL_MOUNTPOINT_TRIM="" REQUIRED_UPDATE="" PLATFORM=$(uname -m) PRODUCT=$(uname -i) @@ -86,9 +88,19 @@ OPT="${1}" # Bastille required if [ -f "${BASTILLECONF}" ]; then . /${BASTILLECONF} - # Always enforce ZFS activation below "/mnt/" from the extension. - if echo "${CWDIR}" | grep -q '/mnt/'; then - CWDIR_TRIM=$(echo "${CWDIR}" | sed "s|/mnt/||;s|/${bastille_zfs_prefix}||") + if [ "${bastille_zfs_enable}" = "YES" -o "${bastille_zfs_enable}" = "yes" ]; then + if [ -n "${bastille_zfs_prefix}" ] && [ -n "${bastille_zfs_zpool}" ]; then + # Always enforce ZFS activation below "/mnt/" from the extension. + if echo "${CWDIR}" | grep -q '/mnt/'; then + CWDIR_TRIM=$(echo "${CWDIR}" | sed "s|/mnt/||;s|/${bastille_zfs_prefix}||") + fi + + BASTILLE_ZFS_ZPOOL_MOUNTPOINT=$(zfs get -H -o value mountpoint "${bastille_zfs_zpool}") + BASTILLE_ZFS_ZPOOL_MOUNTPOINT_TRIM="" + if echo "${BASTILLE_ZFS_ZPOOL_MOUNTPOINT}" | grep -q '/mnt/'; then + BASTILLE_ZFS_ZPOOL_MOUNTPOINT_TRIM=$(echo "${BASTILLE_ZFS_ZPOOL_MOUNTPOINT}" | sed "s|/mnt/||;s|/${bastille_zfs_prefix}||") + fi + fi fi fi @@ -828,7 +840,7 @@ zfs_activate() { # Check if ZFS is already configured. # Always enforce ZFS activation below "/mnt/" from the extension. - if echo "${bastille_zfs_zpool}" | grep -qw "${CWDIR_TRIM}$"; then + if echo "${BASTILLE_ZFS_ZPOOL_MOUNTPOINT_TRIM}" | grep -qw "${CWDIR_TRIM}$"; then BASTILLE_DIR=$(echo "${CWDIR}" | grep -o '[^/]*$') if [ "${bastille_zfs_prefix}" != "${BASTILLE_DIR}" ]; then @@ -1114,7 +1126,7 @@ rc_params() if zfs list "${bastille_zfs_zpool}/${BASTILLE_DIR}" > /dev/null 2>&1; then sysrc -f ${CWDIR}${EXTCONF} ZFS_SUPPORT="YES" >/dev/null 2>&1 else - if echo "${bastille_zfs_zpool}" | grep -qw "${CWDIR_TRIM}$"; then + if echo "${BASTILLE_ZFS_ZPOOL_MOUNTPOINT_TRIM}" | grep -qw "${CWDIR_TRIM}$"; then sysrc -f ${CWDIR}${EXTCONF} ZFS_SUPPORT="AVA" >/dev/null 2>&1 else sysrc -f ${CWDIR}${EXTCONF} ZFS_SUPPORT="ERR" >/dev/null 2>&1 diff --git a/version b/version index 43807dd..901d2aa 100644 --- a/version +++ b/version @@ -1 +1 @@ -1.1.02 +1.1.03