Varaverk.page: also shows wizard when local host.conf is missing
(handles master.conf pushed by HOST1 before HOST2 installs plugin).
pages/setup.php: three wizard flows
- Standard: blank master.conf, fill hostnames, redirect to scheduler
- Host2/state file: state file detected, pull master.conf from HOST1 via SSH
- Conf-only: master.conf already filled (was pushed), just create local host.conf
api/setup.php:
- save action: writes master.conf + host.conf, creates varaverk_setup.db state file,
redirects to ?tab=scheduler&vv_setup=master.conf
- pull action: resolves HOST1 Tailscale IP, queries HOST1 SCRIPTS_DIR, SCPs
master.conf, creates local host.conf, redirects to ?tab=scheduler&vv_setup=hostN.conf
include/config.php: vv_setup_state_read/write/push helpers.
vv_push_setup_state() pushes varaverk_setup.db to /boot/config/ on all known
remotes — no plugin-readiness probe needed (flash is always accessible).
api/rawconf.php: calls vv_push_setup_state() alongside master.conf push.
pages/scheduler.php: setup mode via ?vv_setup=<conf> URL param.
Auto-opens the specified conf file on page load (DOMContentLoaded).
vvSaveRawConf: in setup mode, skips confirm dialog and forces sequence:
master.conf save → auto-open hostN.conf
hostN.conf save → redirect to Monitor (setup complete)
36 lines
1.2 KiB
PHP
36 lines
1.2 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 = [];
|
|
if ($written && $file === 'master.conf') {
|
|
$push = vv_push_master_conf();
|
|
vv_push_setup_state();
|
|
}
|
|
echo json_encode(['ok' => $written, 'push' => $push]);
|
|
exit;
|
|
}
|
|
|
|
echo json_encode(['ok' => false, 'error' => 'Method not allowed']);
|