From c2b74495d997d739c068e73c472c353c998b1c10 Mon Sep 17 00:00:00 2001 From: Jose Date: Fri, 17 Jul 2020 05:39:48 -0400 Subject: [PATCH] Update extension and bastille config files at once --- CHANGELOG | 1 + gui/bastille_manager-lib.inc | 1 + gui/bastille_manager_maintenance.php | 21 ++++++++++++++------- version | 2 +- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 34290ab..77c28f3 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,6 +3,7 @@ ====================== Version Description +1.0.66......Update extension and bastille config files at once. 1.0.65......Add ability to create empty containers, minor improvements. 1.0.64......Switch back to official bastille repository, simplify initial help banner. 1.0.63......Always apply required updates after platform check. diff --git a/gui/bastille_manager-lib.inc b/gui/bastille_manager-lib.inc index 612220e..b5afb73 100755 --- a/gui/bastille_manager-lib.inc +++ b/gui/bastille_manager-lib.inc @@ -46,6 +46,7 @@ $confdir = "/var/etc/bastille_conf"; $cwdir = exec("/usr/bin/grep 'INSTALL_DIR=' $confdir/conf/bastille_config | /usr/bin/cut -d'\"' -f2"); $rootfolder = $cwdir; $configfile = "$rootfolder/conf/bastille_config"; +$configfile_bastille = "$rootfolder/bastille-dist/usr/local/etc/bastille/bastille.conf"; $versionfile = "$rootfolder/version"; $date = strftime('%c'); $logfile = "$rootfolder/log/bastille_ext.log"; diff --git a/gui/bastille_manager_maintenance.php b/gui/bastille_manager_maintenance.php index ba99049..f168a24 100644 --- a/gui/bastille_manager_maintenance.php +++ b/gui/bastille_manager_maintenance.php @@ -74,6 +74,7 @@ $tarballversion = "/usr/local/bin/bastille"; if ($_POST) { global $zfs_activated; global $backup_path_bastille; + global $configfile_bastille; if(isset($_POST['upgrade']) && $_POST['upgrade']): $cmd = sprintf('%1$s/bastille-init -u > %2$s',$rootfolder,$logevent); $return_val = 0; @@ -150,12 +151,19 @@ if ($_POST) { } if (!is_file($backup_path)) { if($backup_path_bastille !== $backup_path): - $errormsg = gtext('Selected backup path does not match with bastille_backupsdir in bastille.conf.') - . ' ' - . '' - . gtext('Please set the bastille_backupsdir in bastille.conf first.') - . ''; - else: + // Update bastille config if required. + $cmd = "/usr/sbin/sysrc -f {$configfile_bastille} bastille_backupsdir={$backup_path}"; + unset($retval);mwexec($cmd,$retval); + if ($retval == 0) { + $savemsg .= gtext("Bastille config updated successfully."); + exec("echo '{$date}: {$application}: Bastille config updated successfully' >> {$logfile}"); + } + else { + $input_errors[] = gtext("Failed to update Bastille config."); + exec("echo '{$date}: {$application}: Failed to update Bastille config' >> {$logfile}"); + } + endif; + // Update extension config. $cmd = "/usr/sbin/sysrc -f {$configfile} BACKUP_DIR={$backup_path}"; unset($retval);mwexec($cmd,$retval); if ($retval == 0) { @@ -166,7 +174,6 @@ if ($_POST) { $input_errors[] = gtext("Failed to save extension settings."); exec("echo '{$date}: {$application}: Failed to save extension settings' >> {$logfile}"); } - endif; } else { $input_errors[] = gtext("Failed to save extension settings."); diff --git a/version b/version index 7b8d6b7..7f2b140 100644 --- a/version +++ b/version @@ -1 +1 @@ -1.0.65 +1.0.66