Commit inicial - estructura base del proyecto

This commit is contained in:
2026-05-31 08:24:12 -06:00
commit cd998ce6b0
143 changed files with 18354 additions and 0 deletions
+8
View File
@@ -0,0 +1,8 @@
$ErrorActionPreference = "Stop"
. "$PSScriptRoot\ProxmoxAgent.ps1"
$config = Get-ProxmoxConfig
$command = "echo ===HOST===; hostname; pveversion; echo; echo ===LXC===; pct list; echo; echo ===QEMU===; qm list; echo; echo ===DOCKER_LXC_$($config.CoolifyLxc)===; pct exec $($config.CoolifyLxc) -- docker ps --format 'table {{.Names}}\t{{.Status}}\t{{.Ports}}'"
Invoke-ProxmoxSshCommand -Command $command
+9
View File
@@ -0,0 +1,9 @@
param(
[Parameter(Mandatory = $true)]
[string]$Command
)
$ErrorActionPreference = "Stop"
. "$PSScriptRoot\ProxmoxAgent.ps1"
Invoke-ProxmoxSshCommand -Command $Command
+95
View File
@@ -0,0 +1,95 @@
Set-StrictMode -Version Latest
function Get-ProxmoxConfig {
$tokenHeader = $null
if ($env:PROXMOX_API_TOKEN_ID -and $env:PROXMOX_API_TOKEN_SECRET) {
$tokenHeader = "PVEAPIToken=$($env:PROXMOX_API_TOKEN_ID)=$($env:PROXMOX_API_TOKEN_SECRET)"
}
[pscustomobject]@{
HostName = if ($env:PROXMOX_HOST) { $env:PROXMOX_HOST } else { "192.168.0.200" }
Node = if ($env:PROXMOX_NODE) { $env:PROXMOX_NODE } else { "thinkcentre" }
User = if ($env:PROXMOX_USER) { $env:PROXMOX_USER } else { "root" }
SshKey = if ($env:PROXMOX_SSH_KEY) { $env:PROXMOX_SSH_KEY } else { "C:\Users\Uriel Jareth\.openclaw\workspace\proxmox_key_win" }
ApiBaseUrl = if ($env:PROXMOX_API_BASE_URL) { $env:PROXMOX_API_BASE_URL } else { "https://192.168.0.200:8006/api2/json" }
ApiTokenHeader = $tokenHeader
CoolifyLxc = if ($env:PROXMOX_COOLIFY_LXC) { $env:PROXMOX_COOLIFY_LXC } else { "102" }
}
}
function Assert-ProxmoxConfig {
$config = Get-ProxmoxConfig
if (-not (Get-Command ssh -ErrorAction SilentlyContinue)) {
throw "ssh executable not found in PATH."
}
if (-not (Test-Path -LiteralPath $config.SshKey)) {
throw "SSH key not found: $($config.SshKey)"
}
return $config
}
function Invoke-ProxmoxSshCommand {
param(
[Parameter(Mandatory = $true)]
[string]$Command,
[int]$ConnectTimeoutSec = 15
)
$config = Assert-ProxmoxConfig
$target = "$($config.User)@$($config.HostName)"
$sshArgs = @(
"-o", "BatchMode=yes",
"-o", "ConnectTimeout=$ConnectTimeoutSec",
"-o", "StrictHostKeyChecking=no",
"-i", $config.SshKey,
$target,
$Command
)
& ssh @sshArgs
$exitCode = $LASTEXITCODE
if ($exitCode -ne 0) {
throw "SSH command failed with exit code $exitCode."
}
}
function Invoke-ProxmoxApi {
param(
[Parameter(Mandatory = $true)]
[string]$Path
)
$config = Get-ProxmoxConfig
if (-not $config.ApiTokenHeader) {
throw "Set PROXMOX_API_TOKEN_ID and PROXMOX_API_TOKEN_SECRET before API calls."
}
if (-not (Get-Command curl.exe -ErrorAction SilentlyContinue)) {
throw "curl.exe not found in PATH."
}
$base = $config.ApiBaseUrl.TrimEnd("/")
$cleanPath = $Path.TrimStart("/")
$uri = "$base/$cleanPath"
$output = & curl.exe -sS -k -H "Authorization: $($config.ApiTokenHeader)" $uri
$exitCode = $LASTEXITCODE
if ($exitCode -ne 0) {
throw "Proxmox API request failed with exit code $exitCode."
}
if (-not $output) {
throw "Proxmox API returned an empty response."
}
try {
return ($output | ConvertFrom-Json)
}
catch {
throw "Proxmox API returned non-JSON output."
}
}
+15
View File
@@ -0,0 +1,15 @@
# Example only. Put real secrets in a private .env.local.ps1 file.
$env:PROXMOX_HOST = "192.168.0.200"
$env:PROXMOX_NODE = "thinkcentre"
$env:PROXMOX_USER = "root"
$env:PROXMOX_SSH_KEY = "C:\Users\Uriel Jareth\.openclaw\workspace\proxmox_key_win"
$env:PROXMOX_API_BASE_URL = "https://192.168.0.200:8006/api2/json"
$env:PROXMOX_API_TOKEN_ID = "root@pam!openclaw"
$env:PROXMOX_API_TOKEN_SECRET = "REPLACE_WITH_TOKEN_SECRET"
$env:PROXMOX_COOLIFY_LXC = "102"
$env:COOLIFY_API_URL = "https://coolify.urieljareth.org/api/v1"
$env:COOLIFY_TOKEN = "REPLACE_WITH_COOLIFY_TOKEN"
Write-Host "Example Proxmox/Coolify environment loaded. Replace token secrets before API tests."
+65
View File
@@ -0,0 +1,65 @@
$ErrorActionPreference = "Stop"
. "$PSScriptRoot\ProxmoxAgent.ps1"
$results = New-Object System.Collections.Generic.List[object]
function Add-Result {
param(
[string]$Check,
[string]$Status,
[string]$Detail
)
$results.Add([pscustomobject]@{
Check = $Check
Status = $Status
Detail = $Detail
}) | Out-Null
}
$config = Get-ProxmoxConfig
try {
Assert-ProxmoxConfig | Out-Null
Add-Result "config" "PASS" "host=$($config.HostName), node=$($config.Node), key present"
}
catch {
Add-Result "config" "FAIL" $_.Exception.Message
}
try {
$sshOutput = Invoke-ProxmoxSshCommand -ConnectTimeoutSec 8 -Command "hostname && pveversion && pct list && qm list"
$summary = ($sshOutput | Select-Object -First 2) -join " | "
Add-Result "ssh-read" "PASS" $summary
}
catch {
Add-Result "ssh-read" "FAIL" $_.Exception.Message
}
try {
$dockerOutput = Invoke-ProxmoxSshCommand -ConnectTimeoutSec 8 -Command "pct exec $($config.CoolifyLxc) -- docker ps --format '{{.Names}}\t{{.Status}}' | head -n 8"
$count = @($dockerOutput | Where-Object { $_ }).Count
Add-Result "docker-lxc-$($config.CoolifyLxc)" "PASS" "$count containers sampled"
}
catch {
Add-Result "docker-lxc-$($config.CoolifyLxc)" "FAIL" $_.Exception.Message
}
if ($config.ApiTokenHeader) {
try {
$version = Invoke-ProxmoxApi -Path "/version"
Add-Result "api-auth" "PASS" "version=$($version.data.version), release=$($version.data.release)"
}
catch {
Add-Result "api-auth" "FAIL" $_.Exception.Message
}
}
else {
Add-Result "api-auth" "SKIP" "set PROXMOX_API_TOKEN_ID and PROXMOX_API_TOKEN_SECRET"
}
$results | Format-Table -AutoSize
if ($results.Status -contains "FAIL") {
exit 1
}
+49
View File
@@ -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";