Files
Varaverk/Plugin/unraid/api/rawconf.php
T
Gmer4Lfe da0c303f22 Push master.conf to all partners immediately on raw-editor save
vv_push_master_conf() in config.php: finds all remote HOST* entries,
resolves Tailscale IPs, SCPs master.conf to each.
rawconf.php calls it after a successful write when file=master.conf.
Scheduler save button shows sync status: "✓ Saved · synced to HOST2"
or "✓ Saved · push failed: HOST2" on error.

Also fix path bug in partnership_transfer.sh — was SCPing to
appdata root instead of Configurations/.
2026-05-30 14:21:02 -04:00

32 lines
1.1 KiB
PHP

<?php
// Raw conf read/write — respects per-host file visibility from vv_get_conf_files().
header('Content-Type: application/json');
require_once dirname(__DIR__) . '/include/config.php';
$allowed = vv_get_conf_files();
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$file = trim($_GET['file'] ?? 'master.conf');
if (!in_array($file, $allowed, true) || str_contains($file, '..')) {
echo json_encode(['ok' => false, 'error' => 'Not allowed']);
exit;
}
echo json_encode(['ok' => true, 'content' => vv_read_conf_raw($file), 'file' => $file, 'allowed' => $allowed]);
exit;
}
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$file = trim($_POST['file'] ?? '');
$content = $_POST['content'] ?? '';
if (!in_array($file, $allowed, true) || str_contains($file, '..')) {
echo json_encode(['ok' => false, 'error' => 'Not allowed']);
exit;
}
$written = vv_write_conf_raw($file, $content);
$push = ($written && $file === 'master.conf') ? vv_push_master_conf() : [];
echo json_encode(['ok' => $written, 'push' => $push]);
exit;
}
echo json_encode(['ok' => false, 'error' => 'Method not allowed']);