in pgo/cases/mediawiki/TrainingCaseHandler.php [51:83]
protected function setupDist() : void
{
$php = new PHP\CLI($this->conf);
$port = $this->getHttpPort();
$host = $this->getHttpHost();
$vars = array(
$this->conf->buildTplVarName($this->getName(), "docroot") => str_replace("\\", "/", $this->base),
);
$tpl_fn = $this->conf->getCasesTplDir($this->getName()) . DIRECTORY_SEPARATOR . "nginx.partial.conf";
$this->nginx->addServer($tpl_fn, $vars);
$settings = $this->conf->getCaseWorkDir($this->getName()) . DIRECTORY_SEPARATOR . "LocalSettings.php";
if (is_file($settings)) {
unlink($settings);
}
$site_adm = trim(shell_exec("pwgen -1 -s 8"));
$this->conf->setSectionItem($this->getName(), "site_admin_user", $site_adm);
$site_pw = trim(shell_exec("pwgen -1 -s 8"));
$this->conf->setSectionItem($this->getName(), "site_admin_pass", $site_pw);
$db_dir = $this->conf->getCaseWorkDir($this->getName()) . DIRECTORY_SEPARATOR . "database";
$nom = $this->getName();
$db_dir = $this->conf->getCaseWorkDir($this->getName()) . DIRECTORY_SEPARATOR . "database";
if (!is_dir($db_dir)) {
mkdir($db_dir);
}
$cmd = $this->getToolFn("install") . " --dbtype=sqlite --dbpath=$db_dir --pass=$site_pw --server=http://$host:$port/ $nom $site_adm";
echo "$cmd\n";
$php->exec($cmd);
}