Fix for jail auto-start settings with names containing dashes

This commit is contained in:
Jose
2020-08-25 18:37:41 -04:00
parent 6e7f479ed1
commit 9932b00a37
4 changed files with 7 additions and 6 deletions

View File

@@ -3,6 +3,7 @@
====================== ======================
Version Description Version Description
1.0.69......Fix for jail auto-start settings with names containing dashes.
1.0.68......Remove the -q option in utilities page. 1.0.68......Remove the -q option in utilities page.
1.0.67......Fix for properly identify the jail type, thanks to mvdhoeven. 1.0.67......Fix for properly identify the jail type, thanks to mvdhoeven.
1.0.66......Update extension and bastille config files at once. 1.0.66......Update extension and bastille config files at once.

View File

@@ -229,7 +229,7 @@ function get_jail_infos() {
$r['path'] = "-"; $r['path'] = "-";
endif; endif;
// Display auto-start settings. // Display auto-start settings.
$jail_autostart = exec("/usr/sbin/sysrc -qn -f {$configfile} {$item}_AUTO_START"); $jail_autostart = exec("/usr/bin/grep -w {$item}_AUTO_START $configfile | cut -d'=' -f2 | tr -d '\"'");
if ($jail_autostart == 'YES') { if ($jail_autostart == 'YES') {
$r['boot'] = $img_path['ena']; $r['boot'] = $img_path['ena'];
} elseif ($jail_autostart == 'NO') { } elseif ($jail_autostart == 'NO') {

View File

@@ -65,7 +65,7 @@ $jail_config = "$jail_dir/$container/jail.conf";
// Get some jail system settings. // Get some jail system settings.
$is_vnet = exec("/usr/bin/grep '.*vnet;' $jail_config"); $is_vnet = exec("/usr/bin/grep '.*vnet;' $jail_config");
$pconfig['autostart'] = exec("/usr/bin/grep '{$container}_AUTO_START=\"YES\"' $bastille_config"); $pconfig['autostart'] = exec("/usr/bin/grep -w '{$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.
@@ -304,7 +304,7 @@ if ($_POST):
if (isset($_POST['autostart']) && $_POST['autostart']): if (isset($_POST['autostart']) && $_POST['autostart']):
if($jail_name_def !== $jail_name): if($jail_name_def !== $jail_name):
// Remove obsolete variable. // Remove obsolete variable.
exec("/usr/sbin/sysrc -f $configfile -qx {$jail_name_def}_AUTO_START"); exec("/usr/bin/sed -i '' 's/{$jail_name_def}_AUTO_START.*//' $configfile");
endif; endif;
$cmd = ("/usr/sbin/sysrc -f $configfile {$jail_name}_AUTO_START=\"YES\""); $cmd = ("/usr/sbin/sysrc -f $configfile {$jail_name}_AUTO_START=\"YES\"");
unset($output,$retval);mwexec2($cmd,$output,$retval); unset($output,$retval);mwexec2($cmd,$output,$retval);
@@ -316,9 +316,9 @@ if ($_POST):
else: else:
if($jail_name_def !== $jail_name): if($jail_name_def !== $jail_name):
// Remove obsolete variable. // Remove obsolete variable.
exec("/usr/sbin/sysrc -f $configfile -qx {$jail_name_def}_AUTO_START"); exec("/usr/bin/sed -i '' 's/{$jail_name_def}_AUTO_START.*//' $configfile");
endif; endif;
$cmd = ("/usr/sbin/sysrc -f {$configfile} {$jail_name}_AUTO_START=\"NO\""); $cmd = ("/usr/bin/sed -i '' 's/{$jail_name}_AUTO_START.*//' $configfile");
unset($output,$retval);mwexec2($cmd,$output,$retval); unset($output,$retval);mwexec2($cmd,$output,$retval);
if($retval == 0): if($retval == 0):
//$savemsg .= gtext("Autostart changed successfully."); //$savemsg .= gtext("Autostart changed successfully.");

View File

@@ -1 +1 @@
1.0.68 1.0.69