Commit inicial - estructura base del proyecto
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
$configPath = $argv[1] ?? '/config/www/nextcloud/config/config.php';
|
||||
$host = $argv[2] ?? 'nextcloudsuite.urieljareth.org';
|
||||
$dbHost = $argv[3] ?? null;
|
||||
$url = 'https://' . $host;
|
||||
|
||||
if (!is_file($configPath)) {
|
||||
fwrite(STDERR, "Config file not found: {$configPath}\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$CONFIG = [];
|
||||
$loaded = include $configPath;
|
||||
if (is_array($loaded)) {
|
||||
$CONFIG = $loaded;
|
||||
}
|
||||
|
||||
$CONFIG['overwriteprotocol'] = 'https';
|
||||
$CONFIG['overwritehost'] = $host;
|
||||
$CONFIG['overwrite.cli.url'] = $url;
|
||||
if ($dbHost !== null && $dbHost !== '') {
|
||||
$CONFIG['dbhost'] = $dbHost;
|
||||
}
|
||||
|
||||
$trustedDomains = $CONFIG['trusted_domains'] ?? [];
|
||||
if (!is_array($trustedDomains)) {
|
||||
$trustedDomains = [];
|
||||
}
|
||||
if (!in_array($host, $trustedDomains, true)) {
|
||||
$trustedDomains[] = $host;
|
||||
}
|
||||
$CONFIG['trusted_domains'] = array_values($trustedDomains);
|
||||
|
||||
$content = "<?php\n\$CONFIG = " . var_export($CONFIG, true) . ";\n";
|
||||
$tmpPath = $configPath . '.tmp';
|
||||
|
||||
if (file_put_contents($tmpPath, $content, LOCK_EX) === false) {
|
||||
fwrite(STDERR, "Could not write temporary config: {$tmpPath}\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!rename($tmpPath, $configPath)) {
|
||||
@unlink($tmpPath);
|
||||
fwrite(STDERR, "Could not replace config file: {$configPath}\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
echo "Updated {$configPath}\n";
|
||||
Reference in New Issue
Block a user