function run_demo($file) { list($exit_code, $output) = run_cmd($file); if ($exit_code != 0) { return false; } $expected = file_get_contents($file . '.expect'); return trim($output) == trim($expected); }
function get_cfg_value($cfg) { global $pbicdir; $jail = "#system"; $jailUrl = "__system__"; $key = $cfg['key']; $default = $cfg['default']; $jid = "__system__"; // Talk to dispatcher to get config value $output = run_cmd("getcfg " . escapeshellarg($pbicdir) . " " . escapeshellarg($jid) . " " . escapeshellarg($key)); if (!empty($output[0])) { return $output[0]; } return $default; }
$showForm = true; $jailMsg = "Please enter the following information to create a new jail:"; if (!empty($_POST['jailname']) or !empty($_POST['jailipv4'])) { $badData = false; // Lets validate the information before creating a new jail $jailname = $_POST['jailname']; if (empty($_POST['jailname'])) { $badData = true; $jailMsg = "Missing host name!"; } if (preg_match('/[\'^£$%&*()}{@#~?><>,|=_+¬-]/', $jailname)) { $badData = true; $jailMsg = "Invalid jail name, no special chars allowed!"; } if (!$badData) { $output = run_cmd("iocage create {$jailname}"); $showForm = false; ?> <h1>Jail Creation</h1> <br> <p>The jail, <?php echo "{$jailname}"; ?> , is queued for creation!</p><br> <a href="?p=jails">Back to Jails</a> <?php } // End of $badData } if ($showForm) { ?>
run_cmd("iocage destroy -f {$delJail}"); hideurl(); } if (!empty($_GET['toggle'])) { $tjail = $_GET['toggle']; $sjail = $_GET['status']; if ($sjail == "Running") { run_cmd("iocage stop {$tjail}"); } else { run_cmd("iocage start {$tjail}"); } hideurl(); } if (!empty($_GET['autostart'])) { $tjail = $_GET['autostart']; run_cmd("iocage set boot=on {$tjail}"); hideurl(); } 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";
function getDispatcherStatus() { return run_cmd("status"); }
$errormsg = "ERROR: The ranges must be numbers!"; } } if ($ip4start == "none") { $ip4start = ""; } if ($ip4end == "none") { $ip4end = ""; } if ($ip4subnet == "none") { $ip4subnet = ""; } if ($setranges) { run_cmd("iocage set ip4_autostart={$ip4start} default"); run_cmd("iocage set ip4_autoend={$ip4end} default"); run_cmd("iocage set ip4_autosubnet={$ip4subnet} default"); } if ($setranges and !empty($_GET['firstrun'])) { require "pages/plugins.php"; } else { if ($firstrun) { echo "<h1>Welcome to AppCafe Plugins!</h1><br>"; } else { echo "<h1>Plugin Configuration</h1><br>"; } echo "<p>Each AppCafe managed plugin requires an IP address on your network. Please specify a range of usable IPs which can be assigned to plugins.</p>"; if (!empty($errormsg)) { echo "<br><p style=\"color:red;\">{$errormsg}</p><br>"; } ?> <table class="jaillist" style="width:100%">
function install($posts) { $txt = join(':', $posts['disk']); $cmd = CBSD_CMD . 'wb_zfs_install dsk="' . $txt . '"'; $res = run_cmd($cmd); return $res['retval']; }
function is_clean_git_checkout($path) { list($exitCode, $output) = run_cmd("git status --porcelain {$path}"); return $exitCode === 0 && count($output) === 0; }
function display_jail_fstab_editor() { global $pbicdir; global $pbiorigin; global $jail; global $jailUrl; global $jailPath; // Get the jail path // Query the system for the running jail list $sccmd = array("jail {$jail} path"); $response = send_sc_query($sccmd); $jailPath = $response["jail {$jail} path"]; // Check for add action if (!empty($_POST['mount'])) { $adderror = run_cmd("iocage" . " addfstab " . escapeshellarg($jail) . " " . $_POST['mount']); } // Check for delete action if (!empty($_GET['delMnt'])) { $delerror = run_cmd("iocage" . " delfstab " . escapeshellarg($jail) . " " . $_GET['delMnt']); } // Get current fstab $fstab = run_cmd("iocage" . " getfstab " . escapeshellarg($jail)); echo "<br>"; echo "{$adderror['0']}{$delerror['0']}"; echo "<table width=\"95%\"><tr><th></th><th></th></tr>"; echo "<form method=\"post\" action=\"?p=plugininfo&app=" . rawurlencode($pbiorigin) . "#tabs-fstab\">\n"; echo "<tr><td><input name=\"mount\" type=\"text\"></td><td><input type=\"submit\" value=\"Add\" class=\"btn-style\"></td></tr>"; echo "</form>"; // Now display the existing fstab lines if any foreach ($fstab as $mntline) { $mntarray = preg_split('/[\\s]+/', $mntline); if ($mntarray[0] == "nullfs" and "{$jailPath}{$mntarray['1']}" == "{$mntarray['2']}") { echo "<tr><td>{$mntarray['1']}</td><td><a href=\"?p=plugininfo&app=" . rawurlencode($pbiorigin) . "&delMnt=" . rawurlencode($mntarray[1]) . "#tabs-fstab\"><img src=\"images/application-exit.png\" height=32 width=32></a></td></tr>"; } } echo "</table></form>"; }
<?php $mod_string = implode(' ', $successful_mods); echo 'Publishing module(s)...' . PHP_EOL; $ret = run_cmd('ssh mirror.freepbx.org "' . '/var/www/html/mirror/publish_modules ' . $vars['rver'] . ' ' . $mod_string . '"', $foo, true); if ($ret) { echo $mod_string . ' successfuly published!' . PHP_EOL; }
//if there are syntax errors then display them if ($syntax_errors) { $final_status[$module] = implode(PHP_EOL, $syntax_errors); freepbx::out("\t" . $final_status[$module]); freepbx::out("Module " . $module . " will not be tagged!"); continue; } freepbx::out("There are no errors"); //run unit tests if (file_exists($mod_dir . '/utests') && file_exists('/etc/freepbx.conf') && file_exists(__DIR__ . '/phpunit.phar')) { freepbx::outn("\tDetected Unit Tests..."); $config = ''; if (file_exists($mod_dir . "/utests/utests.xml")) { $config = "-c " . $mod_dir . "/utests/utests.xml"; } if (!run_cmd(__DIR__ . '/phpunit.phar ' . $config . ' ' . $mod_dir . '/utests', $outline, true)) { freepbx::out("Unit tests failed"); freepbx::out("Module " . $module . " will not be tagged!"); continue; } freepbx::out("all unit tests passed"); } //bump version if requested if ($vars['bump'] && !$vars['debug']) { freepbx::outn("\tBumping Version as Requested..."); $ver = package_bump_version($module, $vars['bump']); freepbx::out("Done"); $vars['log'] = true; } fix_publisher($module); //add changelog if requested
} if (preg_match('/[\'^£$%&*()}{@#~?><>,|=_+¬-]/', $jailname)) { $badData = true; $jailMsg = "Invalid jail name, no special chars allowed!"; } $jailipv4 = $_POST['jailipv4']; if (!filter_var($jailipv4, FILTER_VALIDATE_IP) and !$badData) { $badData = true; $jailMsg = "Invalid IPV4 address!"; } // CHeck for the /24 at the end of the IP if (strpos($jailipv4, '/') === false) { $jailipv4 = $jailipv4 . "/24"; } if (!$badData) { $output = run_cmd("iocage create tag={$jailname} ip4_addr={$jailipv4} boot=on"); $showForm = false; ?> <h1>Jail Creation</h1> <br> <p>The jail, <?php echo "{$jailname}"; ?> , is queued for creation!</p><br> <a href="?p=jails">Back to Jails</a> <?php } // End of $badData } if ($showForm) { ?>
function get_cfg_value($cfg) { global $jail; global $jailUrl; global $pbicdir; global $sc; $key = $cfg['key']; $default = $cfg['default']; exec("{$sc} " . escapeshellarg("jail " . $jail . " id"), $jarray); $jid = $jarray[0]; // Talk to dispatcher to get config value $output = run_cmd("getcfg " . escapeshellarg($pbicdir) . " " . escapeshellarg($jid) . " " . escapeshellarg($key)); if (!empty($output[0])) { return $output[0]; } return $default; }
function get_iocage_pool() { $output = run_cmd("iocage activate"); $rtn = explode(" ", $output[0]); return $rtn[1]; }
} // If we are on plugins section, make sure we have a start-end range if (stripos($page, "plugin") !== false) { // Check for VIMAGE support $vimage = exec("/sbin/sysctl -qn kern.features.vimage"); if ($vimage == 1) { // Get the iocage pool $curpool = get_iocage_pool(); if (empty($curpool)) { $firstrun = true; $page = "pluginconfig"; } } else { $output = run_cmd("iocage get ip4_autostart default"); $ip4start = $output[0]; $output = run_cmd("iocage get ip4_autoend default"); $ip4end = $output[0]; if (empty($ip4start) or empty($ip4end) or ($ip4start == "none" or $ip4end == "none")) { $firstrun = true; $page = "pluginconfig"; } } } // Set some globals for mobile detection $detect = new Mobile_Detect(); $deviceType = $detect->isMobile() ? $detect->isTablet() ? 'tablet' : 'phone' : 'computer'; $scriptVersion = $detect->getScriptVersion(); require "include/header.php"; if ($deviceType == "computer") { require "include/nav-computer.php"; } else {
// Are we saving this jail? if (!empty($_POST['jailipv4'])) { $postjailipv4 = $_POST['jailipv4']; $postjailnic = $_POST['jailnic']; if ($postjailnic == "SYSDEFAULT") { $postjailnic = $defaultnic; } // Has the IP changed? if ($postjailipv4 != $jailipv4) { $jailipv4 = $postjailipv4; } // Has the jail NIC changed? if ($postjailnic != $jailnic) { $jailnic = $postjailnic; } run_cmd("iocage set ip4_addr=\"{$postjailnic}|{$postjailipv4}\" {$jail}"); } ?> <p><?php echo "{$jailMsg}"; ?> </p> <button title="Delete <?php echo "{$jail}"; ?> " style="background-color: Transparent;background-repeat:no-repeat;float:right;border: none;background-image: url('/images/remove.png');background-size: 100%; height: 48px; width: 48px;" onclick="delJailConfirm('<?php echo "{$jail}"; ?> ')"></button> <h1>Jail Configuration for <?php echo "{$jail}";
echo "<h1><center><img src=\"/images/noupdates.png\" height=24 width=24 title=\"Up to date!\">All packages and jails are up to date!</h1><br>"; ?> <h1><center>Recent application actions</h1> <br> <table class="status" style="width:768px"> <tr> <th>Action</th> <th>Application</th> <th>Target</th> <th>Result</th> </tr> <? $rarray = run_cmd("results"); // Loop through the results $rarray = array_reverse($rarray); foreach ($rarray as $res) { $results = explode(" ", $res); if ( $results[2] == "iocage" ) { echo "<tr><td>jail: $results[3]</td>"; echo "<td>$results[4]</td>"; echo "<td>$results[5]</td>"; echo "<td><a href=\"?p=$newpage&log=$results[1]\" style=\"text-decoration: underline;\">$results[0]</a></td></tr>"; } elseif ( $results[2] == "pkgupdate" ) { $target=$results[3]; if ( $results[3] == "__system__" ) $target="Local System";
// missing configuration (eg. mailserver) if (!$verbose) { echo implode("\n", (array) $output) . "\n"; } break; case 0: echo "\nEGroupware successful updated\n"; break; } // install/upgrade required pear packages check_install_pear_packages(); // fix egw_cache evtl. created by root, stoping webserver from accessing it fix_perms(); // restart running Apache, to force APC to update changed sources and/or Apache configuration $output = array(); run_cmd($config['start_webserver'] . ' status && ' . $config['start_webserver'] . ' restart', $output, true); exit($ret); } /** * Patches a given password (for header admin) into the EGroupware header.inc.php and returns the old one * * @param string $filename * @param string &$user username on return(!) * @param string $password new password * @return string old password */ function patch_header($filename, &$user, $password) { $header = file_get_contents($filename); if (!preg_match('/' . preg_quote("\$GLOBALS['egw_info']['server']['header_admin_user'] = '******']+)';/m", $header, $umatches) || !preg_match('/' . preg_quote("\$GLOBALS['egw_info']['server']['header_admin_password'] = '******']*)';/m", $header, $pmatches)) { bail_out(99, "{$filename} is no regular EGroupware header.inc.php!");