Cosmetic changes, add misc configuration row to jail quick config
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
======================
|
======================
|
||||||
Version Description
|
Version Description
|
||||||
|
|
||||||
|
1.0.50......Cosmetic changes, add misc configuration row to jail quick config.
|
||||||
1.0.49......Don't allow for blank fields in the jail config page.
|
1.0.49......Don't allow for blank fields in the jail config page.
|
||||||
1.0.48......Added jail name validation.
|
1.0.48......Added jail name validation.
|
||||||
1.0.47......Cosmetic changes, display notify on success.
|
1.0.47......Cosmetic changes, display notify on success.
|
||||||
|
|||||||
@@ -63,9 +63,12 @@ endif;
|
|||||||
$pgtitle = [gtext('Extensions'),gtext('Bastille'),gtext('Configuration'), $container];
|
$pgtitle = [gtext('Extensions'),gtext('Bastille'),gtext('Configuration'), $container];
|
||||||
$jail_config = "$jail_dir/$container/jail.conf";
|
$jail_config = "$jail_dir/$container/jail.conf";
|
||||||
|
|
||||||
|
// Get some jail system settings.
|
||||||
|
$is_vnet = exec("/usr/bin/grep '.*vnet;' $jail_config");
|
||||||
|
$pconfig['autostart'] = exec("/usr/bin/grep '{$container}_AUTO_START=\"YES\"' $bastille_config");
|
||||||
|
|
||||||
// Get some jail config parameters.
|
// Get some jail config parameters.
|
||||||
// This could be done with a nice php preg loop in the future.
|
// This could be done with a nice php preg loop in the future.
|
||||||
$is_vnet = exec("/usr/bin/grep '.*vnet;' $jail_config");
|
|
||||||
$pconfig['jname'] = "$container";
|
$pconfig['jname'] = "$container";
|
||||||
$pconfig['hostname'] = exec("/usr/bin/grep '.*host.hostname.*=' $jail_config | /usr/bin/sed 's/.*host.hostname.*= //;s/;//'");
|
$pconfig['hostname'] = exec("/usr/bin/grep '.*host.hostname.*=' $jail_config | /usr/bin/sed 's/.*host.hostname.*= //;s/;//'");
|
||||||
$pconfig['ipv4'] = exec("/usr/bin/grep '.*ip4.addr.*=' $jail_config | /usr/bin/sed 's/.*ip4.addr.*= //;s/;//'");
|
$pconfig['ipv4'] = exec("/usr/bin/grep '.*ip4.addr.*=' $jail_config | /usr/bin/sed 's/.*ip4.addr.*= //;s/;//'");
|
||||||
@@ -88,6 +91,7 @@ $jail_enforce_statfs_def = $pconfig['enforce_statfs'];
|
|||||||
$jail_vnet_interface_def = $pconfig['vnet_interface'];
|
$jail_vnet_interface_def = $pconfig['vnet_interface'];
|
||||||
|
|
||||||
if ($_POST):
|
if ($_POST):
|
||||||
|
global $configfile;
|
||||||
unset($savemsg);
|
unset($savemsg);
|
||||||
unset($input_errors);
|
unset($input_errors);
|
||||||
$pconfig = $_POST;
|
$pconfig = $_POST;
|
||||||
@@ -153,24 +157,50 @@ if ($_POST):
|
|||||||
else:
|
else:
|
||||||
if(isset($_POST['Submit']) && $_POST['Submit']):
|
if(isset($_POST['Submit']) && $_POST['Submit']):
|
||||||
|
|
||||||
// Check if the jail is running.
|
// Set current config values.
|
||||||
$cmd = "/usr/sbin/jls -j $container >/dev/null 2>&1";
|
$jail_name = $pconfig['jname'];
|
||||||
unset($output,$retval);mwexec2($cmd,$output,$retval);
|
$jail_hostname = $pconfig['hostname'];
|
||||||
if($retval == 0):
|
$jail_ipv4 = $pconfig['ipv4'];
|
||||||
$savemsg .= gtext("This jail is running, please stop it before making config changes.");
|
$jail_ipv6 = $pconfig['ipv6'];
|
||||||
|
$jail_interface = $pconfig['interface'];
|
||||||
|
$jail_securelevel = $pconfig['securelevel'];
|
||||||
|
$jail_devfs_ruleset = $pconfig['devfs_ruleset'];
|
||||||
|
$jail_enforce_statfs = $pconfig['enforce_statfs'];
|
||||||
|
$jail_vnet_interface = $pconfig['vnet_interface'];
|
||||||
|
|
||||||
|
// Check if the config has changed.
|
||||||
|
// This could be done with a nice foreach loop in the future.
|
||||||
|
if($jail_name_def !== $jail_name):
|
||||||
|
$is_changed = "1";
|
||||||
|
elseif($jail_hostname_def !== $jail_hostname):
|
||||||
|
$is_changed = "1";
|
||||||
|
elseif(isset($_POST['ipv4']) && ($jail_ipv4_def !== $jail_ipv4)):
|
||||||
|
$is_changed = "1";
|
||||||
|
elseif(isset($_POST['ipv6']) && ($jail_ipv6_def !== $jail_ipv6)):
|
||||||
|
$is_changed = "1";
|
||||||
|
elseif(isset($_POST['interface']) && ($jail_interface_def !== $jail_interface)):
|
||||||
|
$is_changed = "1";
|
||||||
|
elseif($jail_securelevel_def !== $jail_securelevel):
|
||||||
|
$is_changed = "1";
|
||||||
|
elseif($jail_devfs_ruleset_def !== $jail_devfs_ruleset):
|
||||||
|
$is_changed = "1";
|
||||||
|
elseif($jail_enforce_statfs_def !== $jail_enforce_statfs):
|
||||||
|
$is_changed = "1";
|
||||||
|
elseif(isset($_POST['vnet_interface']) && ($jail_vnet_interface_def !== $jail_vnet_interface)):
|
||||||
|
$is_changed = "1";
|
||||||
|
endif;
|
||||||
|
|
||||||
|
if($is_changed):
|
||||||
|
// Check if the jail is running.
|
||||||
|
$cmd = "/usr/sbin/jls -j $container >/dev/null 2>&1";
|
||||||
|
unset($output,$retval);mwexec2($cmd,$output,$retval);
|
||||||
|
else:
|
||||||
|
// Skip jail running check.
|
||||||
|
$retval = "1";
|
||||||
|
endif;
|
||||||
|
if($retval == 0):
|
||||||
|
$input_errors[] = gtext("This jail is running, please stop it before making jail.conf changes.");
|
||||||
else:
|
else:
|
||||||
|
|
||||||
// Set current config values.
|
|
||||||
$jail_name = $pconfig['jname'];
|
|
||||||
$jail_hostname = $pconfig['hostname'];
|
|
||||||
$jail_ipv4 = $pconfig['ipv4'];
|
|
||||||
$jail_ipv6 = $pconfig['ipv6'];
|
|
||||||
$jail_interface = $pconfig['interface'];
|
|
||||||
$jail_securelevel = $pconfig['securelevel'];
|
|
||||||
$jail_devfs_ruleset = $pconfig['devfs_ruleset'];
|
|
||||||
$jail_enforce_statfs = $pconfig['enforce_statfs'];
|
|
||||||
$jail_vnet_interface = $pconfig['vnet_interface'];
|
|
||||||
|
|
||||||
if (isset($_POST['hostname']) && $_POST['hostname']):
|
if (isset($_POST['hostname']) && $_POST['hostname']):
|
||||||
if($jail_hostname_def !== $jail_hostname):
|
if($jail_hostname_def !== $jail_hostname):
|
||||||
$cmd = "/usr/bin/sed -i '' 's/.*host.hostname.*=.*;/ host.hostname = $jail_hostname;/' $jail_config";
|
$cmd = "/usr/bin/sed -i '' 's/.*host.hostname.*=.*;/ host.hostname = $jail_hostname;/' $jail_config";
|
||||||
@@ -282,6 +312,24 @@ if ($_POST):
|
|||||||
endif;
|
endif;
|
||||||
endif;
|
endif;
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
|
if (isset($_POST['autostart']) && $_POST['autostart']):
|
||||||
|
$cmd = ("/usr/sbin/sysrc -f $configfile {$container}_AUTO_START=\"YES\"");
|
||||||
|
unset($output,$retval);mwexec2($cmd,$output,$retval);
|
||||||
|
if($retval == 0):
|
||||||
|
//$savemsg .= gtext("Autostart changed successfully.");
|
||||||
|
else:
|
||||||
|
$input_errors[] = gtext("Failed to enable autostart.");
|
||||||
|
endif;
|
||||||
|
else:
|
||||||
|
$cmd = ("/usr/sbin/sysrc -f $configfile {$container}_AUTO_START=\"NO\"");
|
||||||
|
unset($output,$retval);mwexec2($cmd,$output,$retval);
|
||||||
|
if($retval == 0):
|
||||||
|
//$savemsg .= gtext("Autostart changed successfully.");
|
||||||
|
else:
|
||||||
|
$input_errors[] = gtext("Failed to disable autostart.");
|
||||||
|
endif;
|
||||||
|
endif;
|
||||||
//header("Location: bastille_manager_gui.php");
|
//header("Location: bastille_manager_gui.php");
|
||||||
$savemsg .= gtext("Configuration has been saved successfully.");
|
$savemsg .= gtext("Configuration has been saved successfully.");
|
||||||
endif;
|
endif;
|
||||||
@@ -294,11 +342,11 @@ endif;
|
|||||||
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
||||||
<tr>
|
<tr>
|
||||||
<tr><td class="tabnavtbl">
|
<tr><td class="tabnavtbl">
|
||||||
<ul id="tabnav">
|
<ul id="tabnav">
|
||||||
<li class="tabinact"><a href="bastille_manager_gui.php"><span><?=gettext("Containers");?></span></a></li>
|
<li class="tabinact"><a href="bastille_manager_gui.php"><span><?=gtext("Containers");?></span></a></li>
|
||||||
<li class="tabact"><a href="bastille_manager_maintenance.php"><span><?=gettext("Maintenance");?></span></a></li>
|
<li class="tabact"><a href="bastille_manager_maintenance.php"><span><?=gtext("Maintenance");?></span></a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</td></tr>
|
</td></tr>
|
||||||
<td class="tabcont">
|
<td class="tabcont">
|
||||||
<form action="bastille_manager_jconf.php" method="post" name="iform" id="iform" onsubmit="spinner()">
|
<form action="bastille_manager_jconf.php" method="post" name="iform" id="iform" onsubmit="spinner()">
|
||||||
<?php if(!empty($savemsg)) print_info_box($savemsg); ?>
|
<?php if(!empty($savemsg)) print_info_box($savemsg); ?>
|
||||||
@@ -326,6 +374,12 @@ endif;
|
|||||||
html_inputbox("vnet_interface", gtext("VNET Interface"), $pconfig['vnet_interface'], gtext("Set the VNET interface manually, usually should not be changed unless renaming the interface or moving jail from host."), false, 20);
|
html_inputbox("vnet_interface", gtext("VNET Interface"), $pconfig['vnet_interface'], gtext("Set the VNET interface manually, usually should not be changed unless renaming the interface or moving jail from host."), false, 20);
|
||||||
endif;
|
endif;
|
||||||
?>
|
?>
|
||||||
|
<?php
|
||||||
|
html_separator2();
|
||||||
|
html_titleline2(gtext("Misc Configuration"));
|
||||||
|
html_checkbox2('autostart',gtext('Autoboot'),!empty($pconfig['autostart']) ? true : false,gtext('Autoboot this jail after system reboot.'),'',false);
|
||||||
|
//html_checkbox2('force_edit',gtext('Force edit'),!empty($pconfig['force_edit']) ? true : false,gtext('Automatically stop and start this jail if is already running.'),'',false);
|
||||||
|
?>
|
||||||
</table>
|
</table>
|
||||||
<div id="submit">
|
<div id="submit">
|
||||||
<input name="Submit" type="submit" class="formbtn" value="<?=gtext("Save");?>" />
|
<input name="Submit" type="submit" class="formbtn" value="<?=gtext("Save");?>" />
|
||||||
|
|||||||
@@ -185,43 +185,43 @@ if($_POST):
|
|||||||
endif;
|
endif;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'autoboot':
|
//case 'autoboot':
|
||||||
// Input validation not required
|
// // Input validation not required
|
||||||
if(empty($input_errors)):
|
// if(empty($input_errors)):
|
||||||
$container = [];
|
// $container = [];
|
||||||
$container['uuid'] = $_POST['uuid'];
|
// $container['uuid'] = $_POST['uuid'];
|
||||||
$container['jailname'] = $_POST['jailname'];
|
// $container['jailname'] = $_POST['jailname'];
|
||||||
$confirm_name = $pconfig['confirmname'];
|
// $confirm_name = $pconfig['confirmname'];
|
||||||
$item = $container['jailname'];
|
// $item = $container['jailname'];
|
||||||
$cmd = ("/usr/sbin/sysrc -f {$configfile} {$item}_AUTO_START=\"YES\"");
|
// $cmd = ("/usr/sbin/sysrc -f {$configfile} {$item}_AUTO_START=\"YES\"");
|
||||||
unset($output,$retval);mwexec2($cmd,$output,$retval);
|
// unset($output,$retval);mwexec2($cmd,$output,$retval);
|
||||||
if($retval == 0):
|
// if($retval == 0):
|
||||||
header('Location: bastille_manager_gui.php');
|
// header('Location: bastille_manager_gui.php');
|
||||||
exit;
|
// exit;
|
||||||
else:
|
// else:
|
||||||
$input_errors[] = gtext("Failed to set auto-boot.");
|
// $input_errors[] = gtext("Failed to set auto-boot.");
|
||||||
endif;
|
// endif;
|
||||||
endif;
|
// endif;
|
||||||
break;
|
// break;
|
||||||
|
|
||||||
case 'noauto':
|
//case 'noauto':
|
||||||
// Input validation not required
|
// // Input validation not required
|
||||||
if(empty($input_errors)):
|
// if(empty($input_errors)):
|
||||||
$container = [];
|
// $container = [];
|
||||||
$container['uuid'] = $_POST['uuid'];
|
// $container['uuid'] = $_POST['uuid'];
|
||||||
$container['jailname'] = $_POST['jailname'];
|
// $container['jailname'] = $_POST['jailname'];
|
||||||
$confirm_name = $pconfig['confirmname'];
|
// $confirm_name = $pconfig['confirmname'];
|
||||||
$item = $container['jailname'];
|
// $item = $container['jailname'];
|
||||||
$cmd = ("/usr/sbin/sysrc -f {$configfile} {$item}_AUTO_START=\"NO\"");
|
// $cmd = ("/usr/sbin/sysrc -f {$configfile} {$item}_AUTO_START=\"NO\"");
|
||||||
unset($output,$retval);mwexec2($cmd,$output,$retval);
|
// unset($output,$retval);mwexec2($cmd,$output,$retval);
|
||||||
if($retval == 0):
|
// if($retval == 0):
|
||||||
header('Location: bastille_manager_gui.php');
|
// header('Location: bastille_manager_gui.php');
|
||||||
exit;
|
// exit;
|
||||||
else:
|
// else:
|
||||||
$input_errors[] = gtext("Failed to set no-auto.");
|
// $input_errors[] = gtext("Failed to set no-auto.");
|
||||||
endif;
|
// endif;
|
||||||
endif;
|
// endif;
|
||||||
break;
|
// break;
|
||||||
|
|
||||||
case 'fstab':
|
case 'fstab':
|
||||||
// Input validation not required
|
// Input validation not required
|
||||||
@@ -361,14 +361,14 @@ function action_change() {
|
|||||||
showElementById('jail_release_tr', 'show');
|
showElementById('jail_release_tr', 'show');
|
||||||
showElementById('release_tr','show');
|
showElementById('release_tr','show');
|
||||||
break;
|
break;
|
||||||
case "autoboot":
|
//case "autoboot":
|
||||||
showElementById('confirmname_tr','hide');
|
// showElementById('confirmname_tr','hide');
|
||||||
showElementById('nowstop_tr','hide');
|
// showElementById('nowstop_tr','hide');
|
||||||
break;
|
// break;
|
||||||
case "noauto":
|
//case "noauto":
|
||||||
showElementById('confirmname_tr','hide');
|
// showElementById('confirmname_tr','hide');
|
||||||
showElementById('nowstop_tr','hide');
|
// showElementById('nowstop_tr','hide');
|
||||||
break;
|
// break;
|
||||||
case "fstab":
|
case "fstab":
|
||||||
showElementById('confirmname_tr','hide');
|
showElementById('confirmname_tr','hide');
|
||||||
showElementById('nowstop_tr','hide');
|
showElementById('nowstop_tr','hide');
|
||||||
@@ -451,8 +451,8 @@ $document->render();
|
|||||||
'backup' => gettext('Backup'),
|
'backup' => gettext('Backup'),
|
||||||
'update' => gettext('Update'),
|
'update' => gettext('Update'),
|
||||||
'base' => gettext('Release'),
|
'base' => gettext('Release'),
|
||||||
'autoboot' => gettext('Autoboot'),
|
//'autoboot' => gettext('Autoboot'),
|
||||||
'noauto' => gettext('Noauto'),
|
//'noauto' => gettext('Noauto'),
|
||||||
'fstab' => gettext('Fstab'),
|
'fstab' => gettext('Fstab'),
|
||||||
'delete' => gettext('Destroy'),
|
'delete' => gettext('Destroy'),
|
||||||
'advanced' => gettext('Advanced'),
|
'advanced' => gettext('Advanced'),
|
||||||
|
|||||||
Reference in New Issue
Block a user