Make sure minor changes are always applied

This commit is contained in:
JRGTH
2025-11-02 04:30:09 -04:00
parent 7452d2a08e
commit 4831551b4f
4 changed files with 27 additions and 28 deletions

View File

@@ -3,6 +3,7 @@
====================== ======================
Version Description Version Description
1.2.22......Make sure minor changes are always applied.
1.2.21......Check/update bastille config parameters on runtime. 1.2.21......Check/update bastille config parameters on runtime.
1.2.20......Allow install in zroot platform with optional zfs dataset. 1.2.20......Allow install in zroot platform with optional zfs dataset.
1.2.19......Fix typo in tarballs page and cleanup, thanks to Lux. 1.2.19......Fix typo in tarballs page and cleanup, thanks to Lux.
@@ -16,7 +17,7 @@ Version Description
1.2.11......Add all bastille Linux flavors bootstrap options. 1.2.11......Add all bastille Linux flavors bootstrap options.
1.2.10......Minor code improvements and cleanup. 1.2.10......Minor code improvements and cleanup.
1.2.09......Add Debian keyring and minor code changes. 1.2.09......Add Debian keyring and minor code changes.
1.2.08......Code cleanup, remove unnecessary statement. 1.2.08......Code cleanup, remove unnecessary statement.
1.2.07......Minor cosmetic/wording changes. 1.2.07......Minor cosmetic/wording changes.
1.2.06......Code changes, symlink bundled files in embedded platforms. 1.2.06......Code changes, symlink bundled files in embedded platforms.
1.2.05......Mount unionfs for pkg while fetching debootstrap packages. 1.2.05......Mount unionfs for pkg while fetching debootstrap packages.
@@ -151,7 +152,7 @@ Version Description
1.0.30......Ability to convert thin jail to thick jail. 1.0.30......Ability to convert thin jail to thick jail.
1.0.29......Added Chinese (Simplified) translation, thanks to lijinbiao. 1.0.29......Added Chinese (Simplified) translation, thanks to lijinbiao.
1.0.28......Improve fstab utility error handling. 1.0.28......Improve fstab utility error handling.
1.0.27......Improved fstab utility, don't allow blank fields. 1.0.27......Improved fstab utility, don't allow blank fields.
1.0.26......Improved jail IP search during import. 1.0.26......Improved jail IP search during import.
1.0.25......Add foreign jail import support, improved fstab utility. 1.0.25......Add foreign jail import support, improved fstab utility.
1.0.24......Improved Thick container upgrade process. 1.0.24......Improved Thick container upgrade process.

35
bastille-init Normal file → Executable file
View File

@@ -202,7 +202,7 @@ runtime_config()
bastille_initial_download() bastille_initial_download()
{ {
# Check if bastille already exist. # Check if bastille already exist.
if [ -n "${REQUIRED_UPDATE}" ] || [ ! -f "${CWDIR}/${FULLAPPNAME}${BASTILLEPATH}/${APPNAME}" ]; then if [ -n "${REQUIRED_UPDATE}" ] || [ ! -f "${CWDIR}/${FULLAPPNAME}${BASTILLEPATH}/${APPNAME}" ]; then
# Fetch latest bastille package. # Fetch latest bastille package.
echo "Fetching ${APPNAME} files..." echo "Fetching ${APPNAME} files..."
@@ -273,7 +273,7 @@ bastille_upgrade()
bastille_core_update() bastille_core_update()
{ {
# Check if bastille already exist. # Check if bastille already exist.
if [ -f "${CWDIR}/${FULLAPPNAME}${BASTILLEPATH}/${APPNAME}" ]; then if [ -f "${CWDIR}/${FULLAPPNAME}${BASTILLEPATH}/${APPNAME}" ]; then
# Fetch latest bastille package. # Fetch latest bastille package.
echo "Fetching ${APPNAME} files..." echo "Fetching ${APPNAME} files..."
@@ -348,7 +348,7 @@ extension_upgrade()
echo "* WARNING: System reboot is required when upgrading from v${CURRENTVER_FULL} to v${UPDATEVER_FULL} *" echo "* WARNING: System reboot is required when upgrading from v${CURRENTVER_FULL} to v${UPDATEVER_FULL} *"
echo "***********************************************************************************" echo "***********************************************************************************"
fi fi
# Tell the extension was upgraded. # Tell the extension was upgraded.
sysrc -f ${CWDIR}${EXTCONF} EXTENSION_UPGRADED="1" >/dev/null 2>&1 sysrc -f ${CWDIR}${EXTCONF} EXTENSION_UPGRADED="1" >/dev/null 2>&1
else else
echo "Extension is on the latest version!" echo "Extension is on the latest version!"
@@ -432,7 +432,7 @@ sys_symlinkdir()
mkdir -p ${USRLOCAL}/share/licenses mkdir -p ${USRLOCAL}/share/licenses
fi fi
# Required symlinks for bastille. # Required symlinks for bastille.
if [ -d "${INSTALLPATH}${USRLOCAL}/share/licenses" ]; then if [ -d "${INSTALLPATH}${USRLOCAL}/share/licenses" ]; then
cd ${INSTALLPATH}${USRLOCAL}/share/licenses cd ${INSTALLPATH}${USRLOCAL}/share/licenses
for file in * for file in *
@@ -562,7 +562,7 @@ require_once("functions.inc");
\$cmd = dirname(__FILE__)."/${SCRIPTNAME}"; \$cmd = dirname(__FILE__)."/${SCRIPTNAME}";
\$name = "${PRDNAME} Extension"; \$name = "${PRDNAME} Extension";
\$comment = "Start ${PRDNAME} Container Manager"; \$comment = "Start ${PRDNAME} Container Manager";
\$rc = &array_make_branch(\$config,'rc','param'); \$rc = &array_make_branch(\$config,'rc','param');
if(false === array_search_ex(\$cmd,\$rc,'cmd')): if(false === array_search_ex(\$cmd,\$rc,'cmd')):
\$rc_param = []; \$rc_param = [];
\$rc_param['uuid'] = uuid(); \$rc_param['uuid'] = uuid();
@@ -686,7 +686,7 @@ jail_update()
exit 1 exit 1
fi fi
if [ -d "${bastille_jailsdir}/${TARGET}" ]; then if [ -d "${bastille_jailsdir}/${TARGET}" ]; then
if ! cat "${bastille_jailsdir}/${TARGET}/fstab" 2>/dev/null | grep -w "${TARGET}" | grep -qw "/.*/.bastille"; then if ! cat "${bastille_jailsdir}/${TARGET}/fstab" 2>/dev/null | grep -w "${TARGET}" | grep -qw "/.*/.bastille"; then
if [ -f "${bastille_jailsdir}/${TARGET}/root/COPYRIGHT" ]; then if [ -f "${bastille_jailsdir}/${TARGET}/root/COPYRIGHT" ]; then
if [ "$(jls name | grep -w "${TARGET}")" ]; then if [ "$(jls name | grep -w "${TARGET}")" ]; then
@@ -777,7 +777,7 @@ release_upgrade()
release_install() release_install()
{ {
if [ -d "${bastille_releasesdir}/${TARGET}" ]; then if [ -d "${bastille_releasesdir}/${TARGET}" ]; then
if [ -f "${bastille_releasesdir}/${TARGET}/COPYRIGHT" ]; then if [ -f "${bastille_releasesdir}/${TARGET}/COPYRIGHT" ]; then
# Finish installing upgrade on a thick container. # Finish installing upgrade on a thick container.
env PAGER="/bin/cat" ${FREEBSD_UPDATE}/freebsd-update --not-running-from-cron -f ${FREEBSD_UPDATE}/freebsd-update.conf \ env PAGER="/bin/cat" ${FREEBSD_UPDATE}/freebsd-update --not-running-from-cron -f ${FREEBSD_UPDATE}/freebsd-update.conf \
@@ -876,7 +876,7 @@ thickjail_upgrade()
fi fi
# Verify for user input and handle some errors. # Verify for user input and handle some errors.
if [ -d "${bastille_jailsdir}/${TARGET}" ]; then if [ -d "${bastille_jailsdir}/${TARGET}" ]; then
if ! cat "${bastille_jailsdir}/${TARGET}/fstab" 2>/dev/null | grep -w "${TARGET}" | grep -qw "/.*/.bastille"; then if ! cat "${bastille_jailsdir}/${TARGET}/fstab" 2>/dev/null | grep -w "${TARGET}" | grep -qw "/.*/.bastille"; then
if [ -f "${bastille_jailsdir}/${TARGET}/root/COPYRIGHT" ]; then if [ -f "${bastille_jailsdir}/${TARGET}/root/COPYRIGHT" ]; then
if [ "$(jls name | grep -w "${TARGET}")" ]; then if [ "$(jls name | grep -w "${TARGET}")" ]; then
@@ -932,7 +932,7 @@ thickjail_install()
exit 1 exit 1
fi fi
if [ -d "${bastille_jailsdir}/${TARGET}" ]; then if [ -d "${bastille_jailsdir}/${TARGET}" ]; then
if ! cat "${bastille_jailsdir}/${TARGET}/fstab" 2>/dev/null | grep -w "${TARGET}" | grep -qw "/.*/.bastille"; then if ! cat "${bastille_jailsdir}/${TARGET}/fstab" 2>/dev/null | grep -w "${TARGET}" | grep -qw "/.*/.bastille"; then
if [ -f "${bastille_jailsdir}/${TARGET}/root/COPYRIGHT" ]; then if [ -f "${bastille_jailsdir}/${TARGET}/root/COPYRIGHT" ]; then
if [ "$(jls name | grep -w "${TARGET}")" ]; then if [ "$(jls name | grep -w "${TARGET}")" ]; then
@@ -1011,7 +1011,7 @@ zfs_activate()
echo "Synchronizing '${BASTILLE_DIR}' data on new dataset" echo "Synchronizing '${BASTILLE_DIR}' data on new dataset"
rsync -a ${CWDIR}.old/ ${CWDIR}/ rsync -a ${CWDIR}.old/ ${CWDIR}/
fi fi
else else
echo "Bastille ZFS is already configured." echo "Bastille ZFS is already configured."
fi fi
else else
@@ -1070,7 +1070,7 @@ reset_install()
# Reset the extension environment. # Reset the extension environment.
echo "Removing extension files..." echo "Removing extension files..."
if [ -f "${CWDIR}/conf/bastille_config" ]; then if [ -f "${CWDIR}/conf/bastille_config" ]; then
echo "Backup current extension config file." echo "Backup current extension config file."
if [ -f "${CWDIR}/conf/bastille_config.old" ]; then if [ -f "${CWDIR}/conf/bastille_config.old" ]; then
@@ -1226,15 +1226,12 @@ get_versions()
post_upgrade() post_upgrade()
{ {
# Check/apply for required/pending updates/fixes if any. # This function is intended to apply several/temporary changes to the extension once.
# This file will be removed after success execution. if sysrc -f ${CWDIR}${EXTCONF} -qc EXTENSION_UPGRADED=1; then
if sysrc -f ${CWDIR}${EXTCONF} -qc EXTENSION_UPGRADED=1; then
if [ -f "${CWDIR}/post_upgrade.sh" ]; then if [ -f "${CWDIR}/post_upgrade.sh" ]; then
echo "Executing post_upgrade.sh file..." echo "Executing post upgrade file..."
chmod +x ${CWDIR}/post_upgrade.sh && ${CWDIR}/post_upgrade.sh chmod +x ${CWDIR}/post_upgrade.sh && ${CWDIR}/post_upgrade.sh
sleep 3 sleep 3
else
echo "No post upgrade changes pending."
fi fi
sysrc -f ${CWDIR}${EXTCONF} EXTENSION_UPGRADED="0" >/dev/null 2>&1 sysrc -f ${CWDIR}${EXTCONF} EXTENSION_UPGRADED="0" >/dev/null 2>&1
fi fi
@@ -1543,7 +1540,7 @@ bastille_init()
# Check for system compatibility. # Check for system compatibility.
if [ ! "${PLATFORM}" = "amd64" ]; then if [ ! "${PLATFORM}" = "amd64" ]; then
echo "Unsupported platform!"; exit 1 echo "Unsupported platform!"; exit 1
fi fi
# Check for product compatibility. # Check for product compatibility.
if [ ! "${PRDVERSION}" -ge "112" ]; then if [ ! "${PRDVERSION}" -ge "112" ]; then
echo "Unsupported version!"; exit 1 echo "Unsupported version!"; exit 1
@@ -1591,7 +1588,7 @@ bootstrap_dist()
LINUX_FLAVOR="${_linux_flavor}" LINUX_FLAVOR="${_linux_flavor}"
break break
fi fi
done done
fi fi

View File

@@ -88,8 +88,11 @@ if ($_POST) {
ob_start(); ob_start();
include("{$logevent}"); include("{$logevent}");
$ausgabe = ob_get_contents(); $ausgabe = ob_get_contents();
ob_end_clean(); ob_end_clean();
$savemsg .= str_replace("\n", "<br />", $ausgabe)."<br />"; $savemsg .= str_replace("\n", "<br />", $ausgabe)."<br />";
// Silently execute bastille-init post upgrade for pending changes.
// This is to make sure that minor changes are always applied.
exec('bastille-init');
else: else:
$input_errors[] = gtext('An error has occurred during upgrade process.'); $input_errors[] = gtext('An error has occurred during upgrade process.');
$cmd = sprintf('echo %s: %s An error has occurred during upgrade process. >> %s',$date,$application,$logfile); $cmd = sprintf('echo %s: %s An error has occurred during upgrade process. >> %s',$date,$application,$logfile);
@@ -106,7 +109,7 @@ if ($_POST) {
ob_start(); ob_start();
include("{$logevent}"); include("{$logevent}");
$ausgabe = ob_get_contents(); $ausgabe = ob_get_contents();
ob_end_clean(); ob_end_clean();
$savemsg .= str_replace("\n", "<br />", $ausgabe)."<br />"; $savemsg .= str_replace("\n", "<br />", $ausgabe)."<br />";
else: else:
$input_errors[] = gtext('An error has occurred during core update process.'); $input_errors[] = gtext('An error has occurred during core update process.');
@@ -122,7 +125,7 @@ if ($_POST) {
if (is_link($textdomain_bastille)) mwexec("rm -f {$textdomain_bastille}", true); if (is_link($textdomain_bastille)) mwexec("rm -f {$textdomain_bastille}", true);
if (is_dir($confdir)) mwexec("rm -Rf {$confdir}", true); if (is_dir($confdir)) mwexec("rm -Rf {$confdir}", true);
mwexec("rm /usr/local/www/bastille_manager_gui.php && rm -R /usr/local/www/ext/bastille", true); mwexec("rm /usr/local/www/bastille_manager_gui.php && rm -R /usr/local/www/ext/bastille", true);
mwexec("{$rootfolder}/usr/local/sbin/bastille-init -t", true); mwexec("{$rootfolder}/usr/local/sbin/bastille-init -t", true);
$uninstall_cmd = "echo 'y' | /usr/local/sbin/bastille-init -U"; $uninstall_cmd = "echo 'y' | /usr/local/sbin/bastille-init -U";
mwexec($uninstall_cmd, true); mwexec($uninstall_cmd, true);
if (is_link("/usr/local/share/{$prdname}")) mwexec("rm /usr/local/share/{$prdname}", true); if (is_link("/usr/local/share/{$prdname}")) mwexec("rm /usr/local/share/{$prdname}", true);
@@ -217,7 +220,7 @@ if ($_POST) {
ob_start(); ob_start();
include("{$logevent}"); include("{$logevent}");
$ausgabe = ob_get_contents(); $ausgabe = ob_get_contents();
ob_end_clean(); ob_end_clean();
$savemsg .= str_replace("\n", "<br />", $ausgabe)."<br />"; $savemsg .= str_replace("\n", "<br />", $ausgabe)."<br />";
exec("/usr/sbin/sysrc -f {$configfile} ZFS_ACTIVATED=\"YES\""); exec("/usr/sbin/sysrc -f {$configfile} ZFS_ACTIVATED=\"YES\"");
else: else:
@@ -243,8 +246,6 @@ if ($_POST) {
$savemsg .= gtext("ZFS activation option has been skipped."); $savemsg .= gtext("ZFS activation option has been skipped.");
endif; endif;
endif; endif;
# Run bastille-init to update config.
exec("bastille-init");
} }
if (isset($_POST['restore']) && $_POST['restore']) { if (isset($_POST['restore']) && $_POST['restore']) {

View File

@@ -1 +1 @@
1.2.21 1.2.22