From 9c8043a71fa0b7b96993519b7aa6c3e832dc57c3 Mon Sep 17 00:00:00 2001 From: JRGTH Date: Wed, 21 Jan 2026 14:02:01 -0400 Subject: [PATCH] Code improvements/fixes and dashboard cosmetic changes --- CHANGELOG | 3 +- LICENSE | 2 +- bastille-init | 2 +- gui/bastille_manager-lib.inc | 119 ++++++++++++++------------- gui/bastille_manager_add.php | 2 +- gui/bastille_manager_config.php | 2 +- gui/bastille_manager_editor.php | 2 +- gui/bastille_manager_gui.php | 45 ++++++---- gui/bastille_manager_info.php | 2 +- gui/bastille_manager_jconf.php | 2 +- gui/bastille_manager_maintenance.php | 2 +- gui/bastille_manager_tarballs.php | 2 +- gui/bastille_manager_util.php | 2 +- unionfs.sh | 2 +- version | 2 +- 15 files changed, 102 insertions(+), 89 deletions(-) mode change 100755 => 100644 unionfs.sh diff --git a/CHANGELOG b/CHANGELOG index 1281ca8..5e20f9b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,7 +3,8 @@ ====================== Version Description -1.3.31......Minor cosmetic/wording changes. +1.3.00......Code improvements/fixes and dashboard cosmetic changes. +1.2.31......Minor cosmetic/wording changes. 1.2.30......Add auto and live export modes, add ZST compression support. 1.2.29......Fix jail backup. 1.2.28......Minor cosmetic/wording changes. diff --git a/LICENSE b/LICENSE index 39f2630..5800f1c 100644 --- a/LICENSE +++ b/LICENSE @@ -1,5 +1,5 @@ --------------------------------------------------------- - Copyright (c) 2019-2025, Jose Rivera + Copyright (c) 2019-2026, Jose Rivera All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/bastille-init b/bastille-init index fcbada6..7348000 100644 --- a/bastille-init +++ b/bastille-init @@ -9,7 +9,7 @@ # Debug script #set -x -# Copyright (c) 2019-2025, José Rivera (joserprg@gmail.com). +# Copyright (c) 2019-2026, José Rivera (joserprg@gmail.com). # All rights reserved. # Redistribution and use in source and binary forms, with or without diff --git a/gui/bastille_manager-lib.inc b/gui/bastille_manager-lib.inc index 906fe78..98581a4 100644 --- a/gui/bastille_manager-lib.inc +++ b/gui/bastille_manager-lib.inc @@ -2,7 +2,7 @@ /* bastille_manager-lib.inc - Copyright (c) 2019-2025 José Rivera (joserprg@gmail.com). + Copyright (c) 2019-2026 José Rivera (joserprg@gmail.com). All rights reserved. Redistribution and use in source and binary forms, with or without @@ -219,87 +219,90 @@ function get_jail_infos() { $r['name'] = '-'; endif; $r['jailname'] = $r['name']; - - // Set the JID on the running jails. $item = $r['jailname']; - $r['id'] = exec("/usr/sbin/jls | /usr/bin/awk '/{$item}\ /{print $1}'"); + + # Get some jail infos from 'bastille list' then dump data to temporary file. + # JID Name Boot Prio State Type IP_Address Published_Ports Release Tags + $jail_info = "bastille list | grep -w $item | while read _jid _name _boot _prio _state _type _ip _ports _release _tag; do \ + echo \$_jid \$_name \$_boot \$_prio \$_state \$_type \$_ip \$_ports \$_release \$_tag > /tmp/jail.$item.state; done"; + exec("$jail_info"); + $jid = exec("cat /tmp/jail.$item.state | awk '{print $1}'"); + $boot = exec("cat /tmp/jail.$item.state | awk '{print $3}'"); + $prio = exec("cat /tmp/jail.$item.state | awk '{print $4}'"); + $state = exec("cat /tmp/jail.$item.state | awk '{print $5}'"); + $type = exec("cat /tmp/jail.$item.state | awk '{print $6}'"); + $ipvx = exec("cat /tmp/jail.$item.state | awk '{print $7}'"); + $ports = exec("cat /tmp/jail.$item.state | awk '{print $8}'"); + $release = exec("cat /tmp/jail.$item.state | awk '{print $9}'"); + $tags = exec("cat /tmp/jail.$item.state | awk '{print $10}'"); + + // Set the jail JID. + $r['id'] = $jid; if (!$r['id']): $r['id'] = "-"; endif; - // Set the IP address on the running jails using bastille list command instead. - //$r['ip'] = exec("/usr/bin/grep -w 'ip4.addr' {$jail_dir}/{$item}/jail.conf | /usr/bin/awk '{print $3}' | /usr/bin/tr -d ';'"); - $r['ip'] = exec("/usr/local/bin/bastille list {$item} | awk '{print $7}' | sed 1d"); - if (!$r['ip']): - $r['ip'] = exec("/usr/bin/grep -w 'ip6.addr' {$jail_dir}/{$item}/jail.conf | /usr/bin/awk '{print $3}' | /usr/bin/tr -d ';'"); + // Set the jail Boot. + $r['boot'] = $boot; + if (!$r['boot']): + $r['boot'] = "-"; endif; - // Try to get ip from vnet config. - if(!$r['ip']): - $r['ip'] = exec("/usr/local/bin/bastille cmd {$item} cat /etc/rc.conf | /usr/bin/grep 'ifconfig_vnet0=' | cut -d'\"' -f2 | sed 's/inet //'"); + + // Set the jail Prio. + $r['prio'] = $prio; + if (!$r['prio']): + $r['prio'] = "-"; endif; + + // Set the jail State. + $r['state'] = $state; + if (!$r['state']): + $r['state'] = "-"; + endif; + + // Set the jail Type. + $r['type'] = $type; + if (!$r['type']): + $r['type'] = "-"; + endif; + + // Set the jail IP Address. + $r['ip'] = $ipvx; if (!$r['ip']): $r['ip'] = "-"; endif; - // Display release. - $r['rel'] = exec("/usr/sbin/jexec {$item} freebsd-version 2>/dev/null"); - if (!$r['rel']): - if(is_file("{$jail_dir}/{$item}/root/etc/os-release")): - $r['rel'] = exec("/bin/cat {$jail_dir}/{$item}/root/etc/os-release | grep 'PRETTY_NAME=' | tr -d 'PRETTY_NAME=\"'"); - else: - $r['rel'] = exec("/usr/sbin/jexec {$item} uname -o 2>/dev/null"); - endif; + // Set the jail Published Ports. + $r['ports'] = $ports; + if (!$r['ports']): + $r['ports'] = "-"; endif; - // We can't get release version info or jail stopped. + + // Set the jail Release. + $r['rel'] = $release; if (!$r['rel']): $r['rel'] = "-"; endif; - // Display interface name for VNET jails. - if (exec("/usr/bin/grep -w '.*vnet.interface.*=.*;' {$jail_dir}/{$item}/jail.conf")): - $r['nic'] = exec("/usr/bin/grep -w '.*vnet.interface.*=.*;' {$jail_dir}/{$item}/jail.conf | /usr/bin/awk '{print $3}' | /usr/bin/tr -d ';'"); - if (!$r['nic']): - $r['nic'] = "-"; - endif; - // Display interface name from the previous jail.conf syntax for simple shared IP jails. - elseif (exec("/usr/bin/grep -w '.*interface.*=.*;' {$jail_dir}/{$item}/jail.conf")): - $r['nic'] = exec("/usr/bin/grep -w '.*interface.*=.*;' {$jail_dir}/{$item}/jail.conf | /usr/bin/awk '{print $3}' | /usr/bin/tr -d ';'"); - if (!$r['nic']): - $r['nic'] = "-"; - endif; - // Display interface name from the new jail.conf syntax for simple shared IP jails. - elseif (exec("/usr/bin/grep -w '.*ip4.addr.*=.*|.*' {$jail_dir}/{$item}/jail.conf")): - $r['nic'] = exec("/usr/bin/grep -w '.*ip4.addr.*=.*|.*' {$jail_dir}/{$item}/jail.conf | cut -d'|' -f1 | awk '{print $3}'"); - if (!$r['nic']): - $r['nic'] = "-"; - endif; - endif; - - // Display path. - $r['path'] = exec("/usr/bin/grep -w 'path' {$jail_dir}/{$item}/jail.conf | /usr/bin/awk '{print $3}' | /usr/bin/tr -d ';'"); - if (!$r['path']): - $r['path'] = "-"; - endif; - - // Display auto-start settings. - //$jail_autostart = exec("/usr/bin/grep -w {$item}_AUTO_START $configfile | cut -d'=' -f2 | tr -d '\"'"); - $jail_autostart = exec("/usr/bin/grep -w boot {$jail_dir}/{$item}/settings.conf | cut -d'=' -f2 | tr -d '\"'"); - if ($jail_autostart == 'on'): - $r['boot'] = $img_path['ena']; - elseif ($jail_autostart == 'off'): - $r['boot'] = $img_path['dis']; - else: - $r['boot'] = $img_path['dis']; + // Set the jail Tags. + $r['tags'] = $tags; + if (!$r['tags']): + $r['tags'] = "-"; endif; // Display running status icons. - $jail_running = exec("/usr/sbin/jls name | /usr/bin/awk '/^{$item}\$/'"); - if ($jail_running): + if ($state == "Up"): $r['stat'] = $img_path['ena']; else: $r['stat'] = $img_path['dis']; endif; + # Cleanup temporary file. + $info_tmpfile = "/tmp/jail.$item.state"; + if(is_file("$info_tmpfile")): + unlink("$info_tmpfile"); + endif; + // Display custom template icons if available. $template_icon = "{$jail_dir}/{$item}/plugin_icon.png"; if(file_exists($template_icon)): diff --git a/gui/bastille_manager_add.php b/gui/bastille_manager_add.php index 06e9bf8..cb11c48 100644 --- a/gui/bastille_manager_add.php +++ b/gui/bastille_manager_add.php @@ -2,7 +2,7 @@ /* bastille_manager_add.php - Copyright (c) 2019-2025 José Rivera (joserprg@gmail.com). + Copyright (c) 2019-2026 José Rivera (joserprg@gmail.com). All rights reserved. Portions of XigmaNAS® (https://www.xigmanas.com). diff --git a/gui/bastille_manager_config.php b/gui/bastille_manager_config.php index 09d49fc..8f3c422 100644 --- a/gui/bastille_manager_config.php +++ b/gui/bastille_manager_config.php @@ -2,7 +2,7 @@ /* bastille_manager_config.php - Copyright (c) 2019-2025 José Rivera (joserprg@gmail.com). + Copyright (c) 2019-2026 José Rivera (joserprg@gmail.com). All rights reserved. Copyright (c) 2018 Andreas Schmidhuber diff --git a/gui/bastille_manager_editor.php b/gui/bastille_manager_editor.php index 9f1ba47..0b20b38 100644 --- a/gui/bastille_manager_editor.php +++ b/gui/bastille_manager_editor.php @@ -2,7 +2,7 @@ /* bastille_manager_editor.php - Copyright (c) 2019-2025 José Rivera (joserprg@gmail.com). + Copyright (c) 2019-2026 José Rivera (joserprg@gmail.com). All rights reserved. Portions of XigmaNAS® (https://www.xigmanas.com). diff --git a/gui/bastille_manager_gui.php b/gui/bastille_manager_gui.php index c3f828e..2d868e3 100644 --- a/gui/bastille_manager_gui.php +++ b/gui/bastille_manager_gui.php @@ -2,7 +2,7 @@ /* bastille_manager_gui.php - Copyright (c) 2019-2025 José Rivera (joserprg@gmail.com). + Copyright (c) 2019-2026 José Rivera (joserprg@gmail.com). All rights reserved. Portions of XigmaNAS® (https://www.xigmanas.com). @@ -284,32 +284,38 @@ $document->render(); - - - + + + + + + + + - - - - + + - - - - + + + + + + + @@ -338,12 +344,15 @@ $document->render(); ?> - + + + + + + - - - + - + diff --git a/gui/bastille_manager_info.php b/gui/bastille_manager_info.php index 20607cf..ef8e620 100644 --- a/gui/bastille_manager_info.php +++ b/gui/bastille_manager_info.php @@ -2,7 +2,7 @@ /* bastille_manager_info.php - Copyright (c) 2019-2025 José Rivera (joserprg@gmail.com). + Copyright (c) 2019-2026 José Rivera (joserprg@gmail.com). All rights reserved. Portions of XigmaNAS® (https://www.xigmanas.com). diff --git a/gui/bastille_manager_jconf.php b/gui/bastille_manager_jconf.php index beb8aed..366f2a4 100644 --- a/gui/bastille_manager_jconf.php +++ b/gui/bastille_manager_jconf.php @@ -2,7 +2,7 @@ /* bastille_manager_jconf.inc - Copyright (c) 2019-2025 José Rivera (joserprg@gmail.com). + Copyright (c) 2019-2026 José Rivera (joserprg@gmail.com). All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/gui/bastille_manager_maintenance.php b/gui/bastille_manager_maintenance.php index 2cf08a1..50e3f20 100644 --- a/gui/bastille_manager_maintenance.php +++ b/gui/bastille_manager_maintenance.php @@ -2,7 +2,7 @@ /* bastille_manager_maintenance.php - Copyright (c) 2019-2025 José Rivera (joserprg@gmail.com). + Copyright (c) 2019-2026 José Rivera (joserprg@gmail.com). All rights reserved. Copyright (c) 2016 Andreas Schmidhuber diff --git a/gui/bastille_manager_tarballs.php b/gui/bastille_manager_tarballs.php index 13c8c0e..0041eee 100644 --- a/gui/bastille_manager_tarballs.php +++ b/gui/bastille_manager_tarballs.php @@ -2,7 +2,7 @@ /* bastille_manager_tarballs.php - Copyright (c) 2019-2025 José Rivera (joserprg@gmail.com). + Copyright (c) 2019-2026 José Rivera (joserprg@gmail.com). All rights reserved. Portions of XigmaNAS® (https://www.xigmanas.com). diff --git a/gui/bastille_manager_util.php b/gui/bastille_manager_util.php index 0281a29..545897d 100644 --- a/gui/bastille_manager_util.php +++ b/gui/bastille_manager_util.php @@ -2,7 +2,7 @@ /* bastille_manager_util.php - Copyright (c) 2019-2025 José Rivera (joserprg@gmail.com). + Copyright (c) 2019-2026 José Rivera (joserprg@gmail.com). All rights reserved. Portions of XigmaNAS® (https://www.xigmanas.com). diff --git a/unionfs.sh b/unionfs.sh old mode 100755 new mode 100644 index a60ddc2..66d4234 --- a/unionfs.sh +++ b/unionfs.sh @@ -10,7 +10,7 @@ # Debug script #set -x -# Copyright (c) 2019-2025, José Rivera (joserprg@gmail.com). +# Copyright (c) 2019-2026, José Rivera (joserprg@gmail.com). # All rights reserved. # Redistribution and use in source and binary forms, with or without diff --git a/version b/version index 0848465..608c196 100644 --- a/version +++ b/version @@ -1 +1 @@ -1.2.31 +1.3.00
                @@ -381,7 +390,7 @@ $document->render();
<?=$gt_record_add;?>