Storage-mode awareness pass + doc update for System_Essentials through Partnership
All state/data file paths in scripts and PHP now resolve via STATE_DIR / DATA_DIR / PERSISTENT_CONF_CACHE instead of hardcoded /boot/config/ or /tmp/ paths, so the ecosystem works in both internal and appdata storage modes. PHP layer (watchdog.php, partnership.php, fallback.php, monitor.php, snapshot.php, config.php): all state reads switched to STATE_DIR constant; remote state reads use the new vv_remote_state_cmd() helper which resolves the remote's SCRIPTS_DIR via their varaverk.cfg before building the path. conf_sync.sh: fixed SCRIPTS_ROOT → SCRIPTS_DIR bug on MY_CONF path; added _remote_scripts_dir() to resolve partner's SCRIPTS_DIR before SCP pull. fallback.php page: added controls card (PARTNERSHIP_ENABLED, FALLBACK_ENABLED, FALLBACK_RSYNC_ENABLED toggles), status grid, and settings card. README and Manual updated for System_Essentials, Watchdogs, Fallback, Rsync, Media, Monitors, Orchestrators, Partnership: added new scripts (conf_sync, conf_cache_save/restore, conf_cache_watchdog, play_state_sync, start_webhook_listener, upgrade_webhook_handler), corrected all stale /boot/config/ state file paths to $STATE_DIR/$DATA_DIR, noted webgui/php_fpm/mover/user_scripts scripts moved to Plugin/unraid/System_Essentials, fixed start_webhook_listener.sh header (Node.js, not PHP -S).
This commit is contained in:
@@ -18,12 +18,14 @@ function vv_fb_scalar(string $raw, string $varname): string {
|
||||
|
||||
function vv_fb_parse_state(string $text): array {
|
||||
$out = [
|
||||
'state' => 'UNKNOWN',
|
||||
'fallback_start' => 0,
|
||||
'handback_strikes' => 0,
|
||||
'tier2_started' => false,
|
||||
'tier3_started' => false,
|
||||
'tier4_started' => false,
|
||||
'state' => 'UNKNOWN',
|
||||
'fallback_start' => 0,
|
||||
'handback_strikes' => 0,
|
||||
'tier2_started' => false,
|
||||
'tier3_started' => false,
|
||||
'tier4_started' => false,
|
||||
'partnership_suspended' => false,
|
||||
'partner_lost_at' => 0,
|
||||
];
|
||||
foreach (explode("\n", $text) as $line) {
|
||||
$line = trim($line);
|
||||
@@ -31,24 +33,26 @@ function vv_fb_parse_state(string $text): array {
|
||||
[$k, $v] = array_pad(explode('=', $line, 2), 2, '');
|
||||
$k = trim($k); $v = trim($v, '"\'');
|
||||
switch ($k) {
|
||||
case 'state': $out['state'] = $v; break;
|
||||
case 'fallback_start': $out['fallback_start'] = (int)$v; break;
|
||||
case 'handback_strikes': $out['handback_strikes'] = (int)$v; break;
|
||||
case 'tier2_started': $out['tier2_started'] = $v === 'true'; break;
|
||||
case 'tier3_started': $out['tier3_started'] = $v === 'true'; break;
|
||||
case 'tier4_started': $out['tier4_started'] = $v === 'true'; break;
|
||||
case 'state': $out['state'] = $v; break;
|
||||
case 'fallback_start': $out['fallback_start'] = (int)$v; break;
|
||||
case 'handback_strikes': $out['handback_strikes'] = (int)$v; break;
|
||||
case 'tier2_started': $out['tier2_started'] = $v === 'true'; break;
|
||||
case 'tier3_started': $out['tier3_started'] = $v === 'true'; break;
|
||||
case 'tier4_started': $out['tier4_started'] = $v === 'true'; break;
|
||||
case 'partnership_suspended': $out['partnership_suspended'] = $v === 'true'; break;
|
||||
case 'partner_lost_at': $out['partner_lost_at'] = (int)$v; break;
|
||||
}
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
|
||||
function vv_fb_local_state(): array {
|
||||
$path = '/boot/config/fallback_state.db';
|
||||
$path = STATE_DIR . '/fallback_state.db';
|
||||
return vv_fb_parse_state(file_exists($path) ? file_get_contents($path) : '');
|
||||
}
|
||||
|
||||
function vv_fb_remote_state(string $ip, string $sshKey): array {
|
||||
$out = vv_pt_ssh($ip, $sshKey, 'cat /boot/config/fallback_state.db 2>/dev/null');
|
||||
$out = vv_pt_ssh($ip, $sshKey, vv_remote_state_cmd('fallback_state.db'));
|
||||
return vv_fb_parse_state($out);
|
||||
}
|
||||
|
||||
@@ -94,8 +98,13 @@ function vv_fb_all(): array {
|
||||
$currentHost = vv_detect_host();
|
||||
$hosts = vv_fb_known_hosts();
|
||||
$tsPeers = vv_pt_ts_peers();
|
||||
$handbackReq = (int)(vv_fb_scalar(vv_read_conf_raw('master.conf'), 'FALLBACK_HANDBACK_STRIKES') ?: 3);
|
||||
$fbEnabled = vv_fb_scalar(vv_read_conf_raw('master.conf'), 'FALLBACK_ENABLED') === 'true';
|
||||
$masterRaw = vv_read_conf_raw('master.conf');
|
||||
$handbackReq = (int)(vv_fb_scalar($masterRaw, 'FALLBACK_HANDBACK_STRIKES') ?: 3);
|
||||
$fbEnabled = vv_fb_scalar($masterRaw, 'FALLBACK_ENABLED') === 'true';
|
||||
$ptEnabled = vv_fb_scalar($masterRaw, 'PARTNERSHIP_ENABLED') === 'true';
|
||||
$rsyncEnabled = vv_fb_scalar($masterRaw, 'FALLBACK_RSYNC_ENABLED') !== 'false';
|
||||
$checkInterval = (int)(vv_fb_scalar($masterRaw, 'FALLBACK_CHECK_INTERVAL') ?: 30);
|
||||
$suspendAfter = (int)(vv_fb_scalar($masterRaw, 'FALLBACK_PARTNERSHIP_SUSPEND_AFTER') ?: 120);
|
||||
|
||||
// Read all host conf raws upfront
|
||||
$raws = [];
|
||||
@@ -162,9 +171,13 @@ function vv_fb_all(): array {
|
||||
}
|
||||
|
||||
return [
|
||||
'ts' => time(),
|
||||
'fb_enabled' => $fbEnabled,
|
||||
'handback_req' => $handbackReq,
|
||||
'nodes' => $nodes,
|
||||
'ts' => time(),
|
||||
'fb_enabled' => $fbEnabled,
|
||||
'partnership_enabled' => $ptEnabled,
|
||||
'fb_rsync_enabled' => $rsyncEnabled,
|
||||
'handback_req' => $handbackReq,
|
||||
'check_interval' => $checkInterval,
|
||||
'suspend_after' => $suspendAfter,
|
||||
'nodes' => $nodes,
|
||||
];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user