Fallback for custom bastille prefix name

Fallback for custom bastille prefix name, for example capitalized "Bastille" prefix.
This commit is contained in:
JRGTH
2025-10-05 01:06:40 -04:00
parent 3e8e2305ae
commit fb036a29da
4 changed files with 14 additions and 8 deletions

19
bastille-init Normal file → Executable file
View File

@@ -103,6 +103,11 @@ BASTILLE_ZFS_ZPOOL_MOUNTPOINT_TRIM=
# Get extension ZFS config info.
if [ "${bastille_zfs_enable}" = "YES" ] || [ "${bastille_zfs_enable}" = "yes" ]; then
if [ -n "${bastille_zfs_prefix}" ] && [ -n "${bastille_zfs_zpool}" ]; then
DAFAULT_BASTILLE_PREFIX="${APPNAME}"
if [ "${CWDIR##*/}" != "${APPNAME}" ]; then
# Assume custom bastille prefix.
DAFAULT_BASTILLE_PREFIX="${CWDIR##*/}"
fi
# 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}||")
@@ -111,7 +116,7 @@ if [ "${bastille_zfs_enable}" = "YES" ] || [ "${bastille_zfs_enable}" = "yes" ];
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
BASTILLE_ZFS_PREFIX_TRIM=$(echo "${bastille_zfs_prefix}" | sed "s|/${APPNAME}||")
BASTILLE_ZFS_PREFIX_TRIM=$(echo "${bastille_zfs_prefix}" | sed "s|/${DAFAULT_BASTILLE_PREFIX}||")
fi
# Check bastille ZFS config match on disk ZFS config.
BASTILLE_CONFIG_DISK=$(zfs list -H "${bastille_prefix}" 2>/dev/null | awk '{print $1}')
@@ -1341,7 +1346,7 @@ rc_params()
fi
# Check and make sure bastille_zfs_prefix end with "bastille".
if ! echo "${bastille_zfs_prefix}" | grep -qw "${APPNAME}"; then
if ! echo "${bastille_zfs_prefix}" | grep -qw "${DAFAULT_BASTILLE_PREFIX}"; then
zfs_support_error
exit 1
fi
@@ -1355,20 +1360,20 @@ rc_params()
fi
# Perform some checks against on-disk and file configurations.
if zfs list "${bastille_zfs_zpool}/${BASTILLE_ZFS_PREFIX_TRIM}/${APPNAME}" >/dev/null 2>&1; then
if zfs list "${bastille_zfs_zpool}/${BASTILLE_ZFS_PREFIX_TRIM}/${DAFAULT_BASTILLE_PREFIX}" >/dev/null 2>&1; then
# Looks like ZFS support is already configured, then set parameters.
zfs_support_enabled
elif zfs list "${bastille_zfs_zpool}" >/dev/null 2>&1 && \
[ "${bastille_zfs_prefix}" = "${BASTILLE_ZFS_PREFIX_TRIM}/${APPNAME}" ]; then
[ "${bastille_zfs_prefix}" = "${BASTILLE_ZFS_PREFIX_TRIM}/${DAFAULT_BASTILLE_PREFIX}" ]; then
# Looks like ZFS support is available for activation.
zfs_support_avail
elif zfs list "${bastille_zfs_zpool}/${APPNAME}" >/dev/null 2>&1; then
elif zfs list "${bastille_zfs_zpool}/${DAFAULT_BASTILLE_PREFIX}" >/dev/null 2>&1; then
zfs_support_enabled
elif zfs list "${bastille_zfs_zpool}" >/dev/null 2>&1 && \
[ "${BASTILLE_ZFS_PREFIX_TRIM}" = "${APPNAME}" ]; then
[ "${BASTILLE_ZFS_PREFIX_TRIM}" = "${DAFAULT_BASTILLE_PREFIX}" ]; then
# Looks like ZFS support is available for activation.
zfs_support_avail
elif zfs list "${bastille_zfs_zpool}/${APPNAME}" >/dev/null 2>&1; then
elif zfs list "${bastille_zfs_zpool}/${DAFAULT_BASTILLE_PREFIX}" >/dev/null 2>&1; then
zfs_support_enabled
else
zfs_support_error