From 50e465f5e22135aa246facbd04e21135ed1c485e Mon Sep 17 00:00:00 2001 From: JRGTH Date: Sun, 14 Sep 2025 05:30:35 -0400 Subject: [PATCH] always execute extension script after upgrade Always execute extension script after upgrade from WebGUI, code changes. --- CHANGELOG | 1 + bastille-init | 37 +++++++++++++++++++--------- gui/bastille_manager_maintenance.php | 3 +++ version | 2 +- 4 files changed, 30 insertions(+), 13 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index cf184b8..00874e1 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,6 +3,7 @@ ====================== Version Description +1.2.02......Always execute extension script after upgrade from WebGUI, code changes. 1.2.01......Fix extension script missing statement preventing for new installs. 1.2.00......Re-add Linux jail feature, WebGUI fixes and overall improvements. 1.1.53......Code changes, handle osrelease parameter update in bastille-init. diff --git a/bastille-init b/bastille-init index a564603..546c6bf 100755 --- a/bastille-init +++ b/bastille-init @@ -111,7 +111,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|/${BASTILLE_DIR}||") + BASTILLE_ZFS_PREFIX_TRIM=$(echo "${bastille_zfs_prefix}" | sed "s|/${APPNAME}||") fi # Check bastille ZFS config match on disk ZFS config. BASTILLE_CONFIG_DISK=$(zfs list -H "${bastille_prefix}" 2>/dev/null | awk '{print $1}') @@ -308,6 +308,8 @@ extension_upgrade() # Compare version files and fetch latest package if available. if [ -f "${CWDIR}/update/version" ]; then + UPDATEVER_FULL=$(cat ${CWDIR}/update/version) + CURRENTVER_FULL=$(cat ${CWDIR}/version) UPDATEVER=$(cat ${CWDIR}/update/version | tr -d .) CURRENTVER=$(cat ${CWDIR}/version | tr -d .) if [ "${UPDATEVER}" -gt "${CURRENTVER}" ]; then @@ -325,6 +327,11 @@ extension_upgrade() echo "${DATE}: Extension upgraded to ${UPDATEVERSION}" >> ${EXTLOGFILE} echo "Extension upgraded to version ${UPDATEVERSION}" echo "Extension package upgrade completed!" + if [ "${CURRENTVER}" -le "1153" ]; then + echo "***********************************************************************************" + echo "* WARNING: System reboot is required when upgrading from v${CURRENTVER_FULL} to v${UPDATEVER_FULL} *" + echo "***********************************************************************************" + fi else echo "Extension is on the latest version!" rm -R ${CWDIR}/update @@ -1299,35 +1306,41 @@ rc_params() if [ -n "${bastille_zfs_zpool}" ]; then if zfs list "${bastille_zfs_zpool}" >/dev/null 2>&1; then + # Check and don't allow child datasets in bastille_zfs_zpool. + if echo "${bastille_zfs_zpool}" | grep -q '\/'; then + zfs_support_error + exit 1 + fi + + # Check and make sure bastille_zfs_prefix end with "bastille". + if ! echo "${bastille_zfs_prefix}" | grep -qw "${APPNAME}"; then + zfs_support_error + exit 1 + fi + # Check bastille ZFS config match on disk ZFS config if activation is already enabled in the config file. if sysrc -f ${CWDIR}${EXTCONF} -qc ZFS_SUPPORT=YES && sysrc -f ${CWDIR}${EXTCONF} -qc ZFS_ACTIVATED=YES; then if [ "${BASTILLE_CONFIG_DISK}" != "${BASTILLE_CONFIG_FILE}" ]; then zfs_support_error exit 1 - else - # Check and don't allow child datasets in bastille_zfs_zpool. - if echo "${bastille_zfs_zpool}" | grep -q '\/'; then - zfs_support_error - exit 1 - fi fi fi # Perform some checks against on-disk and file configurations. - if zfs list "${bastille_zfs_zpool}/${BASTILLE_ZFS_PREFIX_TRIM}/${BASTILLE_DIR}" >/dev/null 2>&1; then + if zfs list "${bastille_zfs_zpool}/${BASTILLE_ZFS_PREFIX_TRIM}/${APPNAME}" >/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}/${BASTILLE_DIR}" ]; then + [ "${bastille_zfs_prefix}" = "${BASTILLE_ZFS_PREFIX_TRIM}/${APPNAME}" ]; then # Looks like ZFS support is available for activation. zfs_support_avail - elif zfs list "${bastille_zfs_zpool}/${BASTILLE_DIR}" >/dev/null 2>&1; then + elif zfs list "${bastille_zfs_zpool}/${APPNAME}" >/dev/null 2>&1; then zfs_support_enabled elif zfs list "${bastille_zfs_zpool}" >/dev/null 2>&1 && \ - [ "${BASTILLE_ZFS_PREFIX_TRIM}" = "${BASTILLE_DIR}" ]; then + [ "${BASTILLE_ZFS_PREFIX_TRIM}" = "${APPNAME}" ]; then # Looks like ZFS support is available for activation. zfs_support_avail - elif zfs list "${bastille_zfs_zpool}/${BASTILLE_DIR}" >/dev/null 2>&1; then + elif zfs list "${bastille_zfs_zpool}/${APPNAME}" >/dev/null 2>&1; then zfs_support_enabled else zfs_support_error diff --git a/gui/bastille_manager_maintenance.php b/gui/bastille_manager_maintenance.php index d8748e5..d441f56 100644 --- a/gui/bastille_manager_maintenance.php +++ b/gui/bastille_manager_maintenance.php @@ -85,6 +85,9 @@ if ($_POST) { $output = []; exec($cmd,$output,$return_val); if($return_val == 0): + // Execute extension script after upgrade for convenience. + // This will cause the script to early trigger zfs config checks. + exec("{$rootfolder}/bastille-init"); ob_start(); include("{$logevent}"); $ausgabe = ob_get_contents(); diff --git a/version b/version index aa9e242..5ab1bb5 100644 --- a/version +++ b/version @@ -1 +1 @@ -1.2.01 +1.2.02