rename: appdata/varaverk → appdata/Varaverk (capital V throughout)

This commit is contained in:
Gmer4Lfe
2026-05-30 10:22:51 -04:00
parent 2d5a084d2b
commit 0fe99cf2a9
24 changed files with 641 additions and 385 deletions
+54 -10
View File
@@ -1,16 +1,60 @@
#!/bin/bash
# dev_install.sh — symlinks the OS-appropriate plugin into the web server for local development.
# Run once after cloning. Re-run if the repo is moved.
# Safe to re-run: removes stale symlink before recreating.
# ==============================================================================================
# ============================= dev_install.sh =================================================
# ==============================================================================================
#
# Plugin layout:
# Plugin/unraid/ ← Unraid plugin (PHP, served by emhttp at /usr/local/emhttp/plugins/)
# Plugin/debian/ ← future
# Plugin/<os>/ ← future
# PURPOSE
# ─────────────────────────────────────────────────────────────────────────────
# Symlinks the OS-appropriate plugin directory into the web server on first
# install or after the repo is moved. Run once by hand — never by a scheduler.
#
# Adding a new OS:
# 1. Create Plugin/<os>/ with the OS-appropriate web app files
# 2. Add detection + TARGET path below
# Detects the running OS from /etc/*-version markers, picks the matching
# Plugin/<os>/ source directory, and creates a symlink at the web server's
# plugin location. All subsequent file changes under Plugin/<os>/ take effect
# immediately without re-running this script.
#
# ==============================================================================================
# OPERATIONAL SAFEGUARDS
# ==============================================================================================
#
# Idempotent Symlink
# Removes any existing symlink at the target before recreating it. Safe to
# re-run after a repo move without leaving stale paths.
#
# Real Directory Guard
# If the target exists as a real directory (not a symlink), the script refuses
# to proceed. Manual cleanup is required to avoid silently discarding an
# existing installation.
#
# Missing Source Guard
# Exits early if Plugin/<os>/ does not exist — catches a missing OS directory
# before any filesystem changes are made.
#
# ==============================================================================================
# CONFIGURATION
# ==============================================================================================
#
# No config vars. All paths are derived from $BASH_SOURCE and the detected OS.
#
# PLUGIN_NAME varaverk (hardcoded — must match the plugin's registered name)
#
# OS detection markers:
# /etc/unraid-version → unraid → /usr/local/emhttp/plugins/varaverk
# /etc/debian_version → debian → (target path not yet defined)
# /etc/arch-release → arch → (target path not yet defined)
#
# ==============================================================================================
# RUNTIME MODES
# ==============================================================================================
#
# ./dev_install.sh
# Auto-detects the running OS and installs.
#
# ./dev_install.sh <os>
# Overrides OS detection. Valid values: unraid, debian, arch.
# Useful when testing on a machine where the marker files differ.
#
# ==============================================================================================
set -euo pipefail
+6
View File
@@ -4,6 +4,9 @@ require_once dirname(__DIR__) . '/include/monitor.php';
require_once dirname(__DIR__) . '/include/vms.php';
require_once dirname(__DIR__) . '/include/docker_folders.php';
// Pre-warm the API cache with one request (shared by all API-first functions below).
vv_api_data();
echo json_encode([
'system' => vv_system_info(),
'fallback' => vv_fallback_state(),
@@ -22,9 +25,12 @@ echo json_encode([
'parity' => vv_parity_status(),
'storage' => vv_storage_pools(),
'array_disks' => vv_array_disks(),
'watchdog' => vv_watchdog_summary(),
'scripts' => vv_scripts_status(),
'thresholds' => vv_disk_thresholds(),
'vms' => vv_get_vms(),
'docker_folders' => vv_get_docker_folders(),
'remote_hosts' => vv_remote_hosts_stats(),
'_api_status' => vv_api_get_status(),
'ts' => time(),
]);
+3
View File
@@ -16,5 +16,8 @@ $cmd = match($action) {
'restart' => '/sbin/shutdown -r now',
};
$logLine = date('Y-m-d H:i:s') . " action={$action} ip=" . ($_SERVER['REMOTE_ADDR'] ?? 'unknown') . "\n";
@file_put_contents('/boot/config/plugins/varaverk/actions.log', $logLine, FILE_APPEND | LOCK_EX);
exec($cmd . ' > /dev/null 2>&1 &');
echo json_encode(['ok' => true]);
@@ -6,4 +6,4 @@ php -r "
require_once '/usr/local/emhttp/plugins/varaverk/include/scheduler.php';
\$schedule = vv_schedule_load();
if (\$schedule) vv_cron_rebuild(\$schedule);
" 2>/dev/null
" 2>>/var/log/varaverk/rebuild_cron.log
Binary file not shown.

Before

Width:  |  Height:  |  Size: 103 B

After

Width:  |  Height:  |  Size: 1.4 MiB

+1 -1
View File
@@ -5,7 +5,7 @@
define('PLUGIN_CFG', '/boot/config/plugins/varaverk/varaverk.cfg');
$_vv_cfg = @parse_ini_file(PLUGIN_CFG) ?: [];
define('SCRIPTS_DIR', $_vv_cfg['SCRIPTS_DIR'] ?? '/mnt/user/appdata/varaverk');
define('SCRIPTS_DIR', $_vv_cfg['SCRIPTS_DIR'] ?? '/mnt/user/appdata/Varaverk');
define('CONF_DIR', SCRIPTS_DIR . '/Configurations');
define('LOG_DIR', '/var/log/varaverk');
unset($_vv_cfg);
+1 -1
View File
@@ -131,7 +131,7 @@ function vv_watchdog_summary(): array {
}
// Recent restarts (24 h)
$restartLog = '/mnt/user/appdata/varaverk/data/container_restart_history.db';
$restartLog = '/mnt/user/appdata/Varaverk/data/container_restart_history.db';
$restartRaw = @file_get_contents($restartLog) ?: '';
$cutoff = time() - 86400;
$restarts = [];
+31 -6
View File
@@ -1,5 +1,31 @@
<?php
require_once __DIR__ . '/unraid_api.php';
function vv_get_vms(): array {
// ── API path ──────────────────────────────────────────────────────────────
$api = vv_api_data();
if ($api && isset($api['vms']['domains'])) {
$vms = [];
foreach ($api['vms']['domains'] as $d) {
$name = $d['name'] ?? '';
// VmState enum values are RUNNING, PAUSED, SHUT_OFF, etc. — normalise to lowercase
$state = strtolower(str_replace('_', ' ', $d['state'] ?? 'unknown'));
$nl = strtolower($name);
$os = 'linux';
if (str_contains($nl, 'win')) $os = 'windows';
elseif (str_contains($nl, 'mac') || str_contains($nl, 'osx')) $os = 'macos';
elseif (str_contains($nl, 'bsd') || str_contains($nl, 'freebsd')) $os = 'bsd';
// vcpus/mem_mb not available via API — will show null (virsh fallback provides them)
$vms[] = ['name' => $name, 'state' => $state, 'os' => $os, 'vcpus' => null, 'mem_mb' => null];
}
return ['available' => true, 'vms' => $vms];
}
// ── Local fallback ────────────────────────────────────────────────────────
vv_api_record_fallback('vms');
if (!file_exists('/usr/bin/virsh')) return ['available' => false, 'vms' => []];
exec('virsh list --all --name 2>/dev/null', $names, $rc);
@@ -12,16 +38,15 @@ function vv_get_vms(): array {
$state = trim(shell_exec('virsh domstate ' . escapeshellarg($name) . ' 2>/dev/null') ?? 'unknown');
$vcpus = null;
$memMb = null;
$vcpus = null;
$memMb = null;
if ($state === 'running') {
$info = shell_exec('virsh dominfo ' . escapeshellarg($name) . ' 2>/dev/null') ?? '';
if (preg_match('/CPU\(s\)\s*:\s*(\d+)/i', $info, $m)) $vcpus = (int)$m[1];
if (preg_match('/Used memory\s*:\s*(\d+)/i', $info, $m)) $memMb = (int)round((int)$m[1] / 1024);
if (preg_match('/CPU\(s\)\s*:\s*(\d+)/i', $info, $m)) $vcpus = (int)$m[1];
if (preg_match('/Used memory\s*:\s*(\d+)/i', $info, $m)) $memMb = (int)round((int)$m[1] / 1024);
}
// OS detection from libvirt XML
$os = 'linux';
$os = 'linux';
$xmlPath = '/etc/libvirt/qemu/' . $name . '.xml';
if (file_exists($xmlPath)) {
$xml = @file_get_contents($xmlPath) ?: '';
+1 -1
View File
@@ -313,7 +313,7 @@ function vv_wd_all(): array {
$currentHost = vv_detect_host();
$tsPeers = vv_pt_ts_peers();
$masterRaw = vv_read_conf_raw('master.conf');
$restartLog = '/mnt/user/appdata/varaverk/data/container_restart_history.db';
$restartLog = '/mnt/user/appdata/Varaverk/data/container_restart_history.db';
// Config thresholds from master.conf
$cfg = [