Quick update to support bastille 0.9.x

This commit is contained in:
JRGTH
2021-07-15 11:38:31 -04:00
parent 5c82d2f4f6
commit 40ffe9cea4
5 changed files with 37 additions and 19 deletions

View File

@@ -3,6 +3,7 @@
======================
Version Description
1.0.93......Quick update to support bastille 0.9.x.
1.0.92......Set file permissions.
1.0.91......Add required files from FreeBSD 13.0 base release, update config.
1.0.90......Update release list, fix bug in tarballs page.

View File

@@ -40,6 +40,7 @@ require_once 'system.inc';
// internal PHP functions rather than external shell commands.
//$rootfolder = dirname($config['rc']['postinit']['cmd'][$i]);
$prdname = "bastille";
$application = "Bastille Manager";
$restore_name = "restore";
$confdir = "/var/etc/bastille_conf";
@@ -62,6 +63,7 @@ $reldir = "{$rootfolder}/releases";
$backup_path_bastille = exec("/usr/sbin/sysrc -f $rootfolder/bastille-dist/usr/local/etc/bastille/bastille.conf -qn bastille_backupsdir");
$zfs_support = exec("/usr/bin/grep 'ZFS_SUPPORT=' $configfile | /usr/bin/cut -d'\"' -f2");
$zfs_activated = exec("/usr/bin/grep 'ZFS_ACTIVATED=' $configfile | /usr/bin/cut -d'\"' -f2");
$tarballversion = "/usr/local/bin/bastille";
// Ensure the root directory is configured.
if ($rootfolder == "")
@@ -81,6 +83,20 @@ function is_dir_empty($reldir) {
return (count(scandir($reldir)) == 2);
}
// Get bastille version
function get_version_bastille() {
global $tarballversion, $prdname;
if (is_file("{$tarballversion}")) {
//exec("/bin/cat {$tarballversion}", $result);
exec("/usr/bin/grep 'BASTILLE_VERSION=' {$tarballversion} | cut -d'\"' -f2", $result);
return ($result[0]);
}
else {
exec("/usr/local/bin/{$prdname} version | awk 'NR==1'", $result);
return ($result[0]);
}
}
// Initial install banner
function initial_install_banner() {
// Never display this if bastille is already bootstraped/activated.

View File

@@ -68,9 +68,6 @@ if (1 == mwexec("/bin/cat {$configfile} | /usr/bin/grep 'BACKUP_DIR='")) {
}
$backup_path = exec("/bin/cat {$configfile} | /usr/bin/grep 'BACKUP_DIR=' | cut -d'\"' -f2");
$prdname = "bastille";
$tarballversion = "/usr/local/bin/bastille";
if ($_POST) {
global $zfs_activated;
global $backup_path_bastille;
@@ -189,6 +186,7 @@ if ($_POST) {
$output = [];
exec($cmd,$output,$return_val);
if($return_val == 0):
unset ($errormsg);
ob_start();
include("{$logevent}");
$ausgabe = ob_get_contents();
@@ -254,19 +252,6 @@ if ($_POST) {
}
}
function get_version_bastille() {
global $tarballversion, $prdname;
if (is_file("{$tarballversion}")) {
//exec("/bin/cat {$tarballversion}", $result);
exec("/usr/bin/grep 'BASTILLE_VERSION=' {$tarballversion} | cut -d'\"' -f2", $result);
return ($result[0]);
}
else {
exec("/usr/local/bin/{$prdname} version | awk 'NR==1'", $result);
return ($result[0]);
}
}
function get_version_ext() {
global $versionfile;
exec("/bin/cat {$versionfile}", $result);

View File

@@ -112,7 +112,23 @@ if($_POST):
$container['jailname'] = $_POST['jailname'];
$confirm_name = $pconfig['confirmname'];
$item = $container['jailname'];
$cmd = ("/usr/local/bin/bastille export '{$item}'");
$bastille_version = get_version_bastille();
$bastille_version_min = "0920210714";
$bastille_version_format = str_replace(".", "", $bastille_version);
$bastille_bin_path = "/usr/local/bin";
if($bastille_version_format >= $bastille_version_min):
if ($zfs_activated == "YES"):
$export_format = "--xz";
$cmd = ("$bastille_bin_path/bastille export $export_format '{$item}'");
else:
$export_format = "--txz";
$cmd = ("$bastille_bin_path/bastille export $export_format '{$item}'");
endif;
else:
$cmd = ("$bastille_bin_path/bastille export '{$item}'");
endif;
unset($output,$retval);mwexec2($cmd,$output,$retval);
if($retval == 0):
$savemsg .= gtext("Container backup process completed successfully.");
@@ -120,7 +136,7 @@ if($_POST):
//header('Location: bastille_manager_gui.php');
//exit;
else:
$input_errors[] = gtext("Failed to backup container.");
$input_errors[] = gtext("Failed to backup container, please stop [{$item}] before backup.");
exec("echo '{$date}: {$application}: Failed to backup container {$item}' >> {$logfile}");
endif;
endif;

View File

@@ -1 +1 @@
1.0.92
1.0.93