Option to automatically configure the dev shard in the web database

ryzomclassic-develop
kaetemi 4 years ago
parent c5ccd66749
commit dea792a3f7
No known key found for this signature in database
GPG Key ID: 9873C4D40BB479BC

@ -1,8 +0,0 @@
call ..\path_config.bat
set PATH=%RC_PYTHON2%;%PATH%
python web_config.py
cd mariadb
.\bin\mysql -P 9040 -u root < ..\web_config_local.sql
if %errorlevel% neq 0 pause
cd ..
pause

@ -1,8 +0,0 @@
import socket, os
hostname = socket.gethostname()
root = os.getenv('RC_ROOT').replace('\\', '/')
shardDev = root + '/pipeline/shard_dev'
with open("web_config.sql", "r") as fr:
with open("web_config_local.sql", "w") as fw:
for l in fr:
fw.write(l.replace("%RC_HOSTNAME%", hostname).replace("%RC_SHARD_DEV%", shardDev))

@ -140,4 +140,16 @@ function upgrade_domain_databases($continue_r) {
return $continue;
}
function configure_shard_dev($continue_r) {
$continue = $continue_r;
$con = null;
$con = connect_database($continue, "ring");
$continue = ($con != null);
$continue = update_database_configure($continue, $con, "configure_shard_dev.sql");
disconnect_database($con, "ring");
return $continue;
}
?>

@ -103,6 +103,31 @@ function update_database_structure($continue_r, $con, $file) {
}
return $continue;
}
function update_database_configure($continue_r, $con, $file) {
$continue = $continue_r;
global $PRIVATE_PHP_PATH;
if ($continue) {
$sql = file_get_contents($PRIVATE_PHP_PATH . "/setup/sql/" . $file);
$sql = str_replace('%RC_HOSTNAME%', mysqli_real_escape_string($con, gethostname()), $sql);
$shardDevDir = str_replace('/www', '', str_replace('\\', '/', $_POST["domainUsersDir"]));
$sql = str_replace('%RC_SHARD_DEV%', mysqli_real_escape_string($con, $shardDevDir), $sql);
if (!$sql) {
printalert("danger", "Cannot read <em>" . $file . "</em>");
$continue = false;
} else {
if (mysqli_multi_query($con, $sql)) {
printalert("success", "Database updated using <em>" . $file . "</em>");
while (mysqli_more_results($con) && mysqli_next_result($con)) {
// no-op
}
} else {
printalert("danger", "Error updating database using <em>" . $file . "</em>: " . mysqli_error($con));
$continue = false;
}
}
}
return $continue;
}
?>
<body>

@ -11,8 +11,8 @@ include('header.php');
require_once('setup/version.php');
$shardWinDev = (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN');
$shardDev = $shardWinDev;
$shardDev = isset($_GET['dev']);
$shardWin = (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN');
?>
@ -33,6 +33,7 @@ $shardDev = $shardWinDev;
$roleService = isset($_POST["roleService"]) && $_POST["roleService"] == "on";
$roleSupport = isset($_POST["roleSupport"]) && $_POST["roleSupport"] == "on";
$roleDomain = isset($_POST["roleDomain"]) && $_POST["roleDomain"] == "on";
$configureShardDev = isset($_POST["configureShardDev"]) && $_POST["configureShardDev"] == "on";
$continue = true;
@ -265,8 +266,10 @@ $shardDev = $shardWinDev;
}
}
if ($roleDomain) {
// TODO: Register the domain with the nel database etc
if ($continue && $roleDomain) {
if ($configureShardDev) {
$continue = configure_shard_dev($continue) && $continue;
}
}
if ($continue && $roleService) {
@ -490,6 +493,7 @@ $shardDev = $shardWinDev;
<h2 class="panel-title">Domain <small>(Multiple domains require separate installations, as they may run different versions)</small></h2>
</div>
<div class="panel-body">
<?php if (!$shardDev) { ?>
<div class="panel panel-danger">
<div class="panel-heading"><span class="glyphicon glyphicon-info-sign"></span> Database Only</div>
<div class="panel-body">
@ -503,6 +507,18 @@ $shardDev = $shardWinDev;
<p>There can be multiple instances of the domain role, there can only be one support and one service role setup.</p>
</div>
</div>
<?php } ?>
<?php if ($shardDev) { ?>
<div class="form-group">
<div class="col-sm-offset-3 col-sm-8">
<div class="checkbox">
<label>
<input id="configureShardDev" name="configureShardDev" type="checkbox" checked> Configure Development Shard</small>
</label>
</div>
</div>
</div>
<?php } ?>
<div class="form-group">
<label for="nelDomainName" class="col-sm-3 control-label">Name</label>
<div class="col-sm-6">
@ -519,17 +535,17 @@ $shardDev = $shardWinDev;
<label for="domainUsersDir" class="col-sm-3 control-label">Users Directory (MFS, etc)</label>
<div class="col-sm-6">
<input type="text" class="form-control" id="domainUsersDir" name="domainUsersDir" value="<?php
if ($shardWinDev)
{
if ($shardDev && $shardWin) {
print str_replace("\\", "/", str_replace("\\code\\web\\public_php\\setup\\install.php", "/pipeline/shard_dev/www", __FILE__));
}
else if ($shardDev)
{
else if ($shardDev) {
print str_replace("/code/web/public_php/setup/install.php", "/pipeline/shard_dev/www", __FILE__);
}
else
{
print "/home/nevrax/" + gethostname() + "/www";
else if ($shardWin) {
print "C:/nevrax/" . gethostname() . "/www";
}
else {
print "/home/nevrax/" . gethostname() . "/www";
}
?>">
</div>

Loading…
Cancel
Save