Docker tab: own config file, folder.view3 becomes optional sync target

- Primary store moved to /boot/config/plugins/varaverk/docker_folders.json
- No dependency on folder.view3 plugin being installed
- Auto-imports folder.view3 JSON on first run if it exists (one-time bootstrap)
- Mirrors writes to folder.view3 JSON only if that plugin's directory is present
- Toolbar shows '⇄ folder.view3' badge when sync is active
This commit is contained in:
Gmer4Lfe
2026-05-28 22:41:10 -04:00
parent e95fd30e13
commit 00a8a64c4e
2 changed files with 26 additions and 5 deletions
+22 -5
View File
@@ -1,24 +1,41 @@
<?php
// Docker tab — folder management and container inventory
// Reads/writes /boot/config/plugins/folder.view3/docker.json (shared with folder.view3 plugin)
// Primary store: /boot/config/plugins/varaverk/docker_folders.json (Varaverk-owned, no external deps)
// Optional sync: /boot/config/plugins/folder.view3/docker.json (only if folder.view3 is installed)
// Reads/writes HOST*_DOCKER_FOLDER_MAP in host*.conf (used by onboard scripts)
require_once __DIR__ . '/config.php';
define('VV_DOCKER_JSON', '/boot/config/plugins/folder.view3/docker.json');
define('VV_DOCKER_JSON', '/boot/config/plugins/varaverk/docker_folders.json');
define('VV_FV3_JSON', '/boot/config/plugins/folder.view3/docker.json');
// ── JSON helpers ──────────────────────────────────────────────────────────────
function vv_dk_read_json(): array {
// Bootstrap: if our file doesn't exist yet but folder.view3's does, import it once
if (!file_exists(VV_DOCKER_JSON) && file_exists(VV_FV3_JSON)) {
$imported = json_decode(file_get_contents(VV_FV3_JSON), true) ?: [];
vv_dk_write_json($imported);
return $imported;
}
if (!file_exists(VV_DOCKER_JSON)) return [];
return json_decode(file_get_contents(VV_DOCKER_JSON), true) ?: [];
}
function vv_dk_write_json(array $data): bool {
$path = VV_DOCKER_JSON;
$tmp = $path . '.vv.tmp';
@mkdir(dirname($path), 0755, true);
$tmp = $path . '.vv.tmp';
if (file_put_contents($tmp, json_encode($data, JSON_UNESCAPED_SLASHES)) === false) return false;
return rename($tmp, $path);
if (!rename($tmp, $path)) return false;
// Mirror to folder.view3 if installed — keeps both in sync for users who want both UIs
if (file_exists(dirname(VV_FV3_JSON))) {
$t = VV_FV3_JSON . '.vv.tmp';
@file_put_contents($t, json_encode($data, JSON_UNESCAPED_SLASHES));
@rename($t, VV_FV3_JSON);
}
return true;
}
function vv_dk_gen_id(): string {
@@ -157,7 +174,7 @@ function vv_dk_all(): array {
'ungrouped' => $ungrouped,
'conf_map' => $confMap,
'drift' => $drift,
'json_path' => VV_DOCKER_JSON,
'fv3_synced'=> file_exists(dirname(VV_FV3_JSON)),
];
}