From ed3fc8b716e0b8d1bc8061d2a300b07d2bf80fb7 Mon Sep 17 00:00:00 2001 From: JRGTH Date: Fri, 5 Sep 2025 23:42:52 -0400 Subject: [PATCH] Add action to set priority value from utilities --- CHANGELOG | 1 + gui/bastille_manager_util.php | 41 +++++++++++++++++++++++++++++++++++ version | 2 +- 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index fbe65b0..e0216b9 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,6 +3,7 @@ ====================== Version Description +1.1.48......Add action to set priority value from utilities. 1.1.47......Cosmetic changes and improvements. 1.1.46......Display jail IP using bastille list buil-in command. 1.1.45......Code update for recent bastille boot settings changes. diff --git a/gui/bastille_manager_util.php b/gui/bastille_manager_util.php index 52ccc84..a6312e4 100644 --- a/gui/bastille_manager_util.php +++ b/gui/bastille_manager_util.php @@ -318,6 +318,31 @@ if($_POST): endif; break; + case 'priority': + // Input validation required + if(empty($input_errors)): + $container = []; + $container['uuid'] = $_POST['uuid']; + $container['jailname'] = $_POST['jailname']; + $set_priority = $pconfig['prioritynumber']; + $item = $container['jailname']; + if(exec("/usr/sbin/sysrc -f {$jail_dir}/{$item}/{$jail_settings} -qn priority")): + if (is_numeric($set_priority)): + $cmd = ("/usr/local/bin/bastille config {$item} set priority {$set_priority}"); + unset($output,$retval);mwexec2($cmd,$output,$retval); + if($retval == 0): + header('Location: bastille_manager_gui.php'); + exit; + else: + $input_errors[] = gtext("Failed to set priority."); + endif; + else: + $input_errors[] = gtext("Priority value must be a number."); + endif; + endif; + endif; + break; + case 'fstab': // Input validation not required if(empty($input_errors)): @@ -458,33 +483,44 @@ function action_change() { showElementById('backup_tr', 'show'); showElementById('format_tr', 'show'); showElementById('safemode_tr', 'show'); + showElementById('prioritynumber_tr','hide'); break; case "clone": showElementById('newname_tr','show'); showElementById('newipaddr_tr','show'); showElementById('clonestop_tr','show'); + showElementById('prioritynumber_tr','hide'); break; case "update": showElementById('confirmname_tr','hide'); showElementById('nowstop_tr','hide'); showElementById('update_base_tr','show'); showElementById('update_jail_tr','show'); + showElementById('prioritynumber_tr','hide'); break; case "base": showElementById('confirmname_tr','hide'); showElementById('nowstop_tr','hide'); showElementById('jail_release_tr', 'show'); showElementById('release_tr','show'); + showElementById('prioritynumber_tr','hide'); break; case "autoboot": showElementById('confirmname_tr','hide'); showElementById('nowstop_tr','hide'); showElementById('auto_boot_tr', 'show'); + showElementById('prioritynumber_tr','hide'); break; case "noauto": showElementById('confirmname_tr','hide'); showElementById('nowstop_tr','hide'); showElementById('no_autoboot_tr', 'show'); + showElementById('prioritynumber_tr','hide'); + break; + case "priority": + showElementById('confirmname_tr','hide'); + showElementById('nowstop_tr','hide'); + showElementById('prioritynumber_tr','show'); break; case "fstab": showElementById('confirmname_tr','hide'); @@ -495,15 +531,18 @@ function action_change() { showElementById('readonly_tr','show'); showElementById('createdir_tr','show'); showElementById('automount_tr','show'); + showElementById('prioritynumber_tr','hide'); break; case "delete": showElementById('confirmname_tr','show'); showElementById('nowstop_tr','show'); + showElementById('prioritynumber_tr','hide'); break; case "advanced": showElementById('confirmname_tr','hide'); showElementById('nowstop_tr','hide'); showElementById('advanced_tr','show'); + showElementById('prioritynumber_tr','hide'); break; default: break; @@ -577,6 +616,7 @@ $document->render(); 'base' => gettext('Release'), 'autoboot' => gettext('Autoboot'), 'noauto' => gettext('Noauto'), + 'priority' => gettext('Priority'), 'fstab' => gettext('Fstab'), 'delete' => gettext('Destroy'), 'advanced' => gettext('Advanced'), @@ -605,6 +645,7 @@ $document->render(); html_checkbox2('safemode',gettext('Safe ZFS export'),!empty($pconfig['safemode']) ? true : false,gettext('Safely stop and start a ZFS jail before the exporting process, this has no effect on .TGZ/TXZ since the jail should be stopped regardless.'),'',false); endif; html_inputbox2('confirmname',gettext('Enter name for confirmation'),!empty($pconfig['confirmname']),'',true,30); + html_inputbox2('prioritynumber',gettext('Enter priority value'),!empty($pconfig['prioritynumber']),'',true,30); html_checkbox2('nowstop',gettext('Stop container'),!empty($pconfig['nowstop']) ? true : false,gettext('Stop the container if running before deletion.'),'',false); html_inputbox2('newname',gettext('Enter a name for the new container'),!empty($pconfig['newname']),'',true,30); html_inputbox2('newipaddr',gettext('Enter a IP address for the new container'),!empty($pconfig['newipaddr']),'',true,30); diff --git a/version b/version index d388d61..a8646df 100644 --- a/version +++ b/version @@ -1 +1 @@ -1.1.47 +1.1.48