/dev/null | /usr/bin/tr -s ' ' '\n'",$relinfo); exec("/bin/echo; /bin/ls {$rootfolder}/releases | grep RELEASE 2>/dev/null | /usr/bin/tr -s ' ' '\n'",$relinfo); array_shift($relinfo); $rellist = []; foreach($relinfo as $rel): $arel = preg_split("/\s+/",ltrim($rel)); $relname = chop($arel[0]); if(substr($relname,-1) === '*'): $relname = substr($relname,0,strlen($relname) - 1); endif; $rellist[$relname] = []; endforeach; return $rellist; } // Get all interface list. function get_all_interface_list() { global $g; exec("/bin/echo; /sbin/ifconfig -l | /usr/bin/tr -s ' ' '\n'; /bin/echo 'Config'",$linkinfo); array_shift($linkinfo); $iflist = []; foreach($linkinfo as $link): $alink = preg_split("/\s+/",ltrim($link)); $ifname = chop($alink[0]); if(substr($ifname,-1) === '*'): $ifname = substr($ifname,0,strlen($ifname) - 1); endif; $iflist[$ifname] = []; endforeach; return $iflist; } // list base releases $a_release = get_all_release_list(); $l_release = []; foreach($a_release as $k_release => $release): $l_release[$k_release] = $k_release; endforeach; // list of configured interfaces $a_interface = get_all_interface_list(); $l_interfaces = []; foreach($a_interface as $k_interface => $ifinfo): $l_interfaces[$k_interface] = $k_interface; endforeach; // Get jail infos. function get_jail_infos() { global $img_path; global $image_dir; global $configfile; global $jail_dir; $result = []; if(is_dir($jail_dir)): $cmd = '/usr/local/bin/bastille list jail 2>&1'; else: $cmd = ":"; endif; mwexec2($cmd,$rawdata); foreach($rawdata as $line): $a = preg_split('/\t/',$line); $r = []; $name = $a[0]; if(preg_match('/(.*)/', $name, $m)): $r['name'] = $m[1]; else: $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}'"); 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 ';'"); 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 //'"); endif; 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; endif; // We can't get release version info or jail stopped. 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']; endif; // Display running status icons. $jail_running = exec("/usr/sbin/jls name | /usr/bin/awk '/^{$item}\$/'"); if ($jail_running): $r['stat'] = $img_path['ena']; else: $r['stat'] = $img_path['dis']; endif; // Display custom template icons if available. $template_icon = "{$jail_dir}/{$item}/plugin_icon.png"; if(file_exists($template_icon)): if(!file_exists("{$image_dir}/{$item}_icon.png")): copy("$template_icon", "{$image_dir}/{$item}_icon.png"); endif; $r['logo'] = "{$image_dir}/{$item}_icon.png"; else: $template_icon = exec("/usr/bin/grep linsysfs {$jail_dir}/{$item}/fstab"); if($template_icon): // Display standard Linux icon. $r['logo'] = "{$image_dir}/linux_icon.png"; else: // Display standard FreeBSD icon. $r['logo'] = "{$image_dir}/bsd_icon.png"; endif; endif; $result[] = $r; endforeach; return $result; } ?>