Add initial ZFS activation guided support
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
bastille_manager_maintenance.php
|
||||
|
||||
Copyright (c) 2019 José Rivera (joserprg@gmail.com).
|
||||
Copyright (c) 2019-2020 José Rivera (joserprg@gmail.com).
|
||||
All rights reserved.
|
||||
|
||||
Copyright (c) 2016 Andreas Schmidhuber
|
||||
@@ -43,6 +43,17 @@ require_once("bastille_manager-lib.inc");
|
||||
|
||||
$pgtitle = array(gtext("Extensions"), "Bastille", "Maintenance");
|
||||
|
||||
if(!initial_install_banner()):
|
||||
$errormsg = gtext('Bastille Initial Configuration.')
|
||||
. ' '
|
||||
. '<a href="' . 'bastille_manager_config.php' . '">'
|
||||
. gtext('Please check and configure ZFS support option first.')
|
||||
. '</a>'
|
||||
. '</br>'
|
||||
. gtext('Or click Activate to save current configuration regardless.');
|
||||
$prerequisites_ok = false;
|
||||
endif;
|
||||
|
||||
// For legacy product versions.
|
||||
$return_val = mwexec("/bin/cat /etc/prd.version | cut -d'.' -f1 | /usr/bin/grep '10'", true);
|
||||
if ($return_val == 0) {
|
||||
@@ -61,6 +72,7 @@ $prdname = "bastille";
|
||||
$tarballversion = "/usr/local/bin/bastille";
|
||||
|
||||
if ($_POST) {
|
||||
global $zfs_activated;
|
||||
if(isset($_POST['upgrade']) && $_POST['upgrade']):
|
||||
$cmd = sprintf('%1$s/bastille-init -u > %2$s',$rootfolder,$logevent);
|
||||
$return_val = 0;
|
||||
@@ -147,6 +159,44 @@ if ($_POST) {
|
||||
$input_errors[] = gtext("Failed to save extension settings.");
|
||||
exec("echo '{$date}: {$application}: Failed to save extension settings' >> {$logfile}");
|
||||
}
|
||||
// ZFS activation support.
|
||||
if ($_POST['zfs_activate']):
|
||||
$zfs_status = get_state_zfs();
|
||||
if($zfs_status == "Available but not enabled" || $zfs_status == "Enabled"):
|
||||
if(!$zfs_activated):
|
||||
$cmd = sprintf('/bin/echo Y | %1$s/bastille-init -Z > %2$s',$rootfolder,$logevent);
|
||||
$return_val = 0;
|
||||
$output = [];
|
||||
exec($cmd,$output,$return_val);
|
||||
if($return_val == 0):
|
||||
ob_start();
|
||||
include("{$logevent}");
|
||||
$ausgabe = ob_get_contents();
|
||||
ob_end_clean();
|
||||
$savemsg .= str_replace("\n", "<br />", $ausgabe)."<br />";
|
||||
exec("/usr/sbin/sysrc -f {$configfile} ZFS_ACTIVATED=\"YES\"");
|
||||
else:
|
||||
$input_errors[] = gtext('An error has occurred during ZFS activation process.');
|
||||
$cmd = sprintf('echo %s: %s An error has occurred during ZFS activation process. >> %s',$date,$application,$logfile);
|
||||
exec($cmd);
|
||||
endif;
|
||||
endif;
|
||||
else:
|
||||
$input_errors[] = gtext("Cannot activate ZFS with either invalid or disabled configurations.");
|
||||
endif;
|
||||
else:
|
||||
$zfs_status = get_state_zfs();
|
||||
if($zfs_status == "Invalid ZFS configuration"):
|
||||
$input_errors[] = gtext("Cannot skip ZFS activation with an invalid configuration.");
|
||||
elseif($zfs_status == "Enabled"):
|
||||
exec("/usr/sbin/sysrc -f {$configfile} ZFS_ACTIVATED=\"YES\"");
|
||||
elseif(!$zfs_activated):
|
||||
exec("/usr/sbin/sysrc -f {$configfile} ZFS_ACTIVATED=\"NO\"");
|
||||
$savemsg .= gtext("ZFS activation option has been skipped.");
|
||||
endif;
|
||||
endif;
|
||||
# Run bastille-init to update config.
|
||||
exec("bastille-init");
|
||||
}
|
||||
|
||||
if (isset($_POST['restore']) && $_POST['restore']) {
|
||||
@@ -231,20 +281,6 @@ $(document).ready(function(){
|
||||
//-->
|
||||
</script>
|
||||
<form action="bastille_manager_maintenance.php" method="post" name="iform" id="iform" onsubmit="spinner()">
|
||||
<?php
|
||||
if(!empty($errormsg)):
|
||||
print_error_box($errormsg);
|
||||
endif;
|
||||
if(!empty($savemsg)):
|
||||
print_info_box($savemsg);
|
||||
endif;
|
||||
if(!empty($input_errors)):
|
||||
print_input_errors($input_errors);
|
||||
endif;
|
||||
if(file_exists($d_sysrebootreqd_path)):
|
||||
print_info_box(get_std_save_message(0));
|
||||
endif;
|
||||
?>
|
||||
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
||||
<tr><td class="tabnavtbl">
|
||||
<ul id="tabnav">
|
||||
@@ -261,6 +297,12 @@ $(document).ready(function(){
|
||||
</td></tr>
|
||||
<tr><td class="tabcont">
|
||||
<table width="100%" border="0" cellpadding="6" cellspacing="0">
|
||||
<?php
|
||||
if(!empty($errormsg)): print_error_box($errormsg); endif;
|
||||
if(!empty($savemsg)): print_info_box($savemsg); endif;
|
||||
if(!empty($input_errors)): print_input_errors($input_errors); endif;
|
||||
if(file_exists($d_sysrebootreqd_path)): print_info_box(get_std_save_message(0)); endif;
|
||||
?>
|
||||
<?php html_titleline(gtext("Bastille"));?>
|
||||
<?php html_text("installation_directory", gtext("Installation directory"), sprintf(gtext("The extension is installed in %s"), $rootfolder));?>
|
||||
<tr>
|
||||
@@ -275,6 +317,11 @@ $(document).ready(function(){
|
||||
<td class="vncellt"><?=gtext("ZFS support");?></td>
|
||||
<td class="vtable"><span name="getinfo_zfs" id="getinfo_zfs"><?=get_state_zfs()?></span></td>
|
||||
</tr>
|
||||
<?php
|
||||
if(!initial_install_banner()):
|
||||
html_checkbox2('zfs_activate',gtext('ZFS support activation'),'' ? true : false,gtext('Check this to activate ZFS support or leave unchecked to dismiss, this is a one time option and this row will disappear after clicking Save button.'),'',false);
|
||||
endif;
|
||||
?>
|
||||
<?php html_filechooser("backup_path", gtext("Backup directory"), $backup_path, gtext("Directory to store containers backup archives, use as file chooser for restoring from file."), $backup_path, true, 60);?>
|
||||
</table>
|
||||
<div id="submit">
|
||||
@@ -284,7 +331,7 @@ $(document).ready(function(){
|
||||
</div>
|
||||
<div id="remarks">
|
||||
<?php html_remark("note", gtext("Info"), sprintf(gtext("For general information visit the following link(s):")));?>
|
||||
<div id="enumeration"><ul><li><a href="http://bastillebsd.org/" target="_blank" > Bastille helps you quickly create and manage FreeBSD Jails.</a></li></ul></div>
|
||||
<div id="enumeration"><ul><li><a href="http://bastillebsd.org/" target="_blank" ><?=gtext("Bastille helps you quickly create and manage FreeBSD Jails.")?></a></li></ul></div>
|
||||
</div>
|
||||
<table width="100%" border="0" cellpadding="6" cellspacing="0">
|
||||
<?php html_separator();?>
|
||||
|
||||
Reference in New Issue
Block a user