function print_jail($jail, $status) { // Get some information about this jail $sccmd = array("jail {$jail} autostart", "jail {$jail} type", "jail {$jail} tag"); $response = send_sc_query($sccmd); $jauto = $response["jail {$jail} autostart"]; $jtype = $response["jail {$jail} type"]; $jtag = $response["jail {$jail} tag"]; $jtag = substr($jtag, 8); if ($jauto == "true") { $autostatus = "Enabled"; } else { $autostatus = "Disabled"; } print "<tr>\n"; print " <td><a href=\"?p=jailinfo&jail={$jail}\" style=\"text-decoration: underline;\">{$jtag}</a></td>\n"; print " <td><a href=\"/?p=jails&autostart={$jail}\" style=\"text-decoration: underline;\">{$autostatus}</a></td>\n"; if ($status == "Running") { print " <td><a href=\"/?p=jails&toggle={$jail}&status={$status}\" style=\"color: green; text-decoration: underline;\">{$status}</a></td>\n"; } else { print " <td><a href=\"/?p=jails&toggle={$jail}&status={$status}\" style=\"color: red; text-decoration: underline;\">{$status}</a></td>\n"; } if ($status == "Running") { $dccmd = array("iocage getip4 {$jail}"); $response = send_dc_cmd($dccmd); $jip = $response["iocage getip4 {$jail}"]; print " <td>{$jip}</td>\n"; } else { print " <td></td>\n"; } print "</tr>\n"; }
} // No dispatch ID set? User probably trying to access through browser if (!isset($DISPATCHID)) { echo "Please access through the AppCafe utility! (pc-softweb command)"; exit(0); } } $login_on_fail = true; // Load our websocket library require 'vendor/autoload.php'; require "include/globals.php"; require "include/functions.php"; require "include/functions-config.php"; // Auth this WS connection $sccmd = array("username" => "root"); $response = send_sc_query($sccmd, "auth"); // Check if we have updates to display check_update_reboot(); // Do any install / delete requests if (!empty($_GET["deleteApp"])) { queueDeleteApp(); } if (!empty($_GET["installApp"])) { queueInstallApp(); } if (!empty($_GET["deletePlugin"])) { queueDeletePlugin(); } if (!empty($_GET["installPlugin"])) { queueInstallPlugin(); }
function display_install_chooser() { global $pbiorigin; global $pbiname; global $ioid; global $pbiInstalled; if ($pbiInstalled) { $output = ""; print " <button title=\"Delete {$pbiname}\" style=\"background-color: Transparent;background-repeat:no-repeat;border: none;background-image: url('/images/application-exit.png');background-size: 100%; height: 48px; width: 48px;\" onclick=\"delAppConfirm('" . $pbiname . "','" . rawurlencode($pbiorigin) . "','" . $ioid . "')\" height=48 width=48></button>\n"; } else { $sccmd = array("pbi cage {$pbiorigin} git"); $response = send_sc_query($sccmd); $ghrepo = $response["pbi cage {$pbiorigin} git"]; print " <button title=\"Install {$pbiname}\" style=\"background-color: Transparent;background-repeat:no-repeat;border: none;float:right;\" onclick=\"addAppConfirm('" . $pbiname . "','" . rawurlencode($pbiorigin) . "','" . rawurlencode($ghrepo) . "')\"><img src=\"/images/install.png\" height=22 width=22></button>\n"; } }
function display_config_details() { global $pbicdir; global $pbiorigin; global $jailPath; $jail = "#system"; $jailUrl = "__system__"; global $updatedConfig; $updatedConfig = false; // Get the jail path $sccmd = array("jail " . $jail . " path"); $response = send_sc_query($sccmd); $jailPath = $response["jail " . $jail . " path"]; // Init the array to load in config data unset($appConfig); // Load the config file $contents = file_get_contents($pbicdir . "/service-config.json"); $appConfig = json_decode($contents, true); // Start the form echo "<form method=\"post\" action=\"?p=appinfo&app=" . rawurlencode($pbiorigin) . "&jail={$jailUrl}#tabs-configure\">\n"; echo " <table class=\"jaillist\" style=\"width:100%\">"; echo " <tr>\n"; echo " <th></th>\n"; echo " <th width=99%></th>\n"; echo " </tr>"; // Set some globals we use for widget items global $currentval; global $desc; global $longdesc; global $default; global $postkey; global $itemup; // Now loop through the array and build the form foreach ($appConfig as $cfgWidget) { // Skip any array missing the type if (empty($cfgWidget["type"])) { continue; } // Get some of the basic settings $currentval = get_cfg_value($cfgWidget); $desc = $cfgWidget['desc']; $longdesc = str_replace("<br>", "\n", $cfgWidget['longdesc']); $default = $cfgWidget['default']; $postkey = md5($desc); $itemup = ""; // Check if the value has been updated in the UI if (!empty($_POST["{$postkey}"])) { $newval = $_POST["{$postkey}"]; if ($currentval != $newval) { $currentval = $newval; set_cfg_value($cfgWidget, $currentval); $itemup = "<img src=\"/images/dialog-ok.png\" title=\"Updated!\" width=22 height=22 style=\"float: right;\">"; $updatedConfig = true; } } switch ($cfgWidget['type']) { case "COMBOBOX": display_combo_box($cfgWidget); break; case "NUMBERBOX": display_number_box($cfgWidget); break; case "STRINGBOX": case "PASSWORDBOX": display_string_box($cfgWidget); break; } } // All done, finish the form echo " <tr><td colspan=2 align=center><input type=\"submit\" value=\"Save Config\" class=\"btn-style\"></td></tr>\n"; echo " </table>\n"; echo "<form>\n"; // If we updated settings, we can now run the done script if ($updatedConfig) { done_cfg(); } }
$jail = $_GET['jail']; if (empty($jail) or $jail == "#system") { die("Invalid jail specified!"); } if ($vimage == 1) { $sccmd = array("jail {$jail} tag"); $response = send_sc_query($sccmd); $jtag = $response["jail {$jail} tag"]; // Get IPv4 $dccmd = array("iocage getip4 {$jail}"); $response = send_dc_cmd($dccmd); $jailipv4 = $response["iocage getip4 {$jail}"]; $dnic = ""; } else { $sccmd = array("jail {$jail} ipv4", "jail {$jail} ipv6", "jail {$jail} tag"); $response = send_sc_query($sccmd); $jailipv4 = $response["jail {$jail} ipv4"]; $dnic = strstr($jailipv4, "|", TRUE); $jailipv4 = substr(strstr($jailipv4, "|"), 1); $jailipv6 = $response["jail {$jail} ipv6"]; $jtag = $response["jail {$jail} tag"]; } // Get the default network interface for this jail $defaultnic = exec("netstat -f inet -nrW | grep '^default' | awk '{ print \$6 }'"); if (empty($dnic)) { $dnic = $defaultnic; } $jailnic = $dnic; // Get the list of nics available $nics = get_nics(); // Are we saving this jail?
exit(0); } else { $_SESSION['timeout'] = time(); } $login_on_fail = true; // Load our websocket library require 'vendor/autoload.php'; require "include/globals.php"; require "include/functions.php"; require "include/functions-config.php"; $loadedglobals = true; // Check for VIMAGE support $vimage = exec("/sbin/sysctl -qn kern.features.vimage"); // Auth this WS connection $sccmd = array("token" => "{$APIKEY}"); $response = send_sc_query($sccmd, "auth_token"); if ($response["code"] == "401" or $response["message"] == "Unauthorized") { include 'include/login.php'; exit(0); } // Check if we have updates to display check_update_reboot(); // Do any install / delete requests if (!empty($_GET["deleteApp"])) { queueDeleteApp(); } if (!empty($_GET["installApp"])) { queueInstallApp(); } if (!empty($_GET["deletePlugin"])) { queueDeletePlugin();
function display_install_chooser() { global $pbiorigin; global $pbiname; global $pbiInstalled; global $pkgCmd; global $SCERROR; global $isPBI; $jail = "#system"; $jailUrl = "__system__"; $appdivid = "button-" . str_replace("/", "-", $pbiorigin); if ($pbiInstalled) { $sccmd = array("{$jail} app-summary {$pbiorigin}"); $response = send_sc_query($sccmd); $pbiarray = $response["{$jail} app-summary {$pbiorigin}"]; if ($isPBI) { $pbicanremove = $pbiarray[9]; } else { $pbicanremove = $pbiarray[5]; } if ($pbiorigin == "ports-mgmt/pkg") { $pbicanremove = false; } // Dont display removal option unless app is not required by others if ("{$pbicanremove}" == "true") { print "<div id='" . $appdivid . "'><button title=\"Delete {$pbiname} from {$jail}\" style=\"background-color: Transparent;background-repeat:no-repeat;border: none;background-image: url('/images/application-exit.png');background-size: 100%; height: 48px; width: 48px;\" onclick=\"delConfirm('" . $pbiname . "','" . $pbiorigin . "','" . $pkgCmd . "','" . $appdivid . "')\" height=48 width=48></button></div>\n"; } else { print "<center><img align=\"center\" height=48 width=48 src=\"/images/warning.png\" alt=\"This application has dependencies which prevent it from being removed.\"><p>Required</p></center>"; } } else { print "<div id='" . $appdivid . "'><button title=\"Install {$pbiname}\" style=\"background-color: Transparent;background-repeat:no-repeat;border: none;\" onclick=\"addConfirm('" . $pbiname . "','" . $pbiorigin . "','" . $pkgCmd . "','" . $appdivid . "')\"><img src=\"/images/install.png\" height=48 width=48></button></div>\n"; } }
function get_iocage_id_from_origin($origin) { $sccmd = array("jail stoppedcages", "jail runningcages"); $response = send_sc_query($sccmd); $stopped = $response["jail stoppedcages"]; $running = $response["jail runningcages"]; if (is_array($running)) { $runningarray = $running; } else { $runningarray = explode(", ", $running); } if (is_array($stopped)) { $stoppedarray = $stopped; } else { $stoppedarray = explode(", ", $stopped); } // Check stopped cages first foreach ($stoppedarray as $jail) { if (stripos($jail, $origin . " ") !== false) { $jitem = explode(" ", $jail); return $jitem[1]; } } foreach ($runningarray as $jail) { if (stripos($jail, $origin . " ") !== false) { $jitem = explode(" ", $jail); return $jitem[1]; } } return ""; }