diff --git a/.coderabbit.yaml b/.coderabbit.yaml index 65ac2287..73a03c99 100644 --- a/.coderabbit.yaml +++ b/.coderabbit.yaml @@ -211,9 +211,21 @@ reviews: The Unraid compatibility matrix; CI only, nothing here ships. - install_test.sh puts the .plg through each Unraid version's own plugin installer, hooks included, in a fresh Docker container with - no network; it must refuse to run anywhere else. Only Slackware's - upgradepkg and removepkg are stubbed, keeping their file-list - records: flag any other stand-in for Unraid's code. + no network; it must refuse to run anywhere else (lib.sh's guard). + Only Slackware's upgradepkg and removepkg are stubbed, keeping their + file-list records: flag any other stand-in for Unraid's code. + - fake_unraid.sh serves one Unraid version's real webGUI with php -S + and pages_test.php drives FV3 through it. Stand-ins are what the OS + image adds around the webGUI, nothing of the webGUI itself: + router.php (nginx's locations), prepend.php (php.ini's prepend), + docker.php (dockerd's socket and the docker CLI), libvirt.php (the + php-libvirt extension), rc_service.sh (rc.docker and rc.libvirt), + dmidecode.sh and ip.sh (those commands), connect_state.php (the + Connect plugin), the dockerd and libvirtd + processes, and emhttp's state files (var.ini, network.ini, the + docker and domain cfg). A call a stand-in does not answer fails + the run: flag an answer that hides one, and any stand-in for code + the webGUI repo has. - matrix_check.py keeps ci.yml's Unraid rows at one per minor from the .plg's min to the newest release; Renovate only moves rows. - Each step asserts what the user is left with (live files, the diff --git a/.github/unraid-compat/Dockerfile b/.github/unraid-compat/Dockerfile index 2f8f421f..1fae0965 100644 --- a/.github/unraid-compat/Dockerfile +++ b/.github/unraid-compat/Dockerfile @@ -1,5 +1,7 @@ -# The PHP an Unraid version ships, plus what Unraid has and this image lacks: gawk (the .plg's remove script uses RT), xz -# (the package format) and wget (the installer's downloader, so a download fails on the network, not a missing tool). +# The PHP an Unraid version ships, plus Unraid's gawk (the remove script uses RT), xz (packages), procps (pages call pgrep) +# and wget (the installer's downloader, so a download fails on the network, not a missing tool) ARG PHP FROM php:${PHP}-cli -RUN apt-get update && apt-get install -y --no-install-recommends gawk wget xz-utils && rm -rf /var/lib/apt/lists/* +# Unraid's /bin/sh is bash: its exec() strings use &> +RUN apt-get update && apt-get install -y --no-install-recommends gawk procps wget xz-utils && rm -rf /var/lib/apt/lists/* \ + && ln -sf bash /bin/sh diff --git a/.github/unraid-compat/fake/connect_state.php b/.github/unraid-compat/fake/connect_state.php new file mode 100644 index 00000000..6ed92c36 --- /dev/null +++ b/.github/unraid-compat/fake/connect_state.php @@ -0,0 +1,3 @@ +> /var/log/fv3-fakes.log; exit 1 ;; +esac diff --git a/.github/unraid-compat/fake/docker.php b/.github/unraid-compat/fake/docker.php new file mode 100644 index 00000000..108a1514 --- /dev/null +++ b/.github/unraid-compat/fake/docker.php @@ -0,0 +1,91 @@ +` is the docker CLI. A request it does not know is logged as UNKNOWN and refused. +$d = json_decode((string)@file_get_contents(__DIR__ . '/../fixtures/docker.json'), true); +if (!is_array($d)) { fwrite(STDERR, "fixtures/docker.json is unreadable\n"); exit(2); } + +function fv3d_log(string $line): void { file_put_contents('/var/log/fv3-fakes.log', "docker $line\n", FILE_APPEND | LOCK_EX); } + +function fv3d_container(array $d, string $ref): ?array { + foreach ($d['inspect'] as $ct) { + if (ltrim($ct['Name'], '/') === ltrim($ref, '/') || (strlen($ref) >= 12 && str_starts_with($ct['Id'], $ref))) return $ct; + } + return null; +} + +function fv3d_running(array $d): array { return array_values(array_filter($d['containers'], fn($c) => $c['State'] === 'running')); } + +function fv3d_answer(array $d, string $method, string $target): array { + $path = (string)parse_url($target, PHP_URL_PATH); + parse_str((string)parse_url($target, PHP_URL_QUERY), $query); + // Only `all` on the two lists is answered; a filter, any other parameter or all[] (Docker's key `all[]`, not `all`) is a + // request this fake does not know + $lists = in_array($path, ['/containers/json', '/images/json'], true); + if ($method !== 'GET' || array_diff(array_keys($query), $lists ? ['all'] : []) || array_filter($query, 'is_array')) return [null, null]; + // Docker's httputils.BoolValue: empty, 0, no, false and none are false, any other value true + $all = !in_array(strtolower(trim($query['all'] ?? '')), ['', '0', 'no', 'false', 'none'], true); + if ($path === '/containers/json') return [200, $all ? $d['containers'] : fv3d_running($d)]; + if (preg_match('#^/containers/([^/]+)/json$#', $path, $m)) { + $ct = fv3d_container($d, $m[1]); + return $ct ? [200, $ct] : [404, ['message' => "No such container: {$m[1]}"]]; + } + if ($path === '/images/json') return [200, $d['images']]; + if (preg_match('#^/images/(.+)/json$#', $path, $m)) { + foreach ($d['image_inspect'] as $id => $img) { + if ($m[1] === $id || in_array($m[1], $img['RepoTags'] ?? [], true)) return [200, $img]; + } + return [404, ['message' => "No such image: {$m[1]}"]]; + } + return [null, null]; +} + +// The docker CLI lines Unraid and FV3 run, matched argument by argument as the shell split them (--format too), and answered +// in the CLI's own output format +function fv3d_cli(array $d, array $args): ?array { + if ($args === ['network', 'ls', '--format={{.Name}}={{.Driver}}']) return array_map(fn($n) => "{$n['Name']}={$n['Driver']}", $d['networks']); + if ($args === ['ps', '-q', '--no-trunc']) return array_column(fv3d_running($d), 'Id'); + // A label's presence only, as Unraid filters: label=key=value is a form this fake does not answer + if (count($args) === 5 && [$args[0], $args[1], $args[3], $args[4]] === ['ps', '--filter', '--format', '{{.Names}}'] && preg_match('/^label=([^\s=]+)$/', $args[2], $m)) { + return array_map(fn($c) => ltrim($c['Names'][0], '/'), array_values(array_filter(fv3d_running($d), fn($c) => isset($c['Labels'][$m[1]])))); + } + if ($args === ['stats', '--no-stream', '--format={{.ID}};{{.CPUPerc}};{{.MemUsage}}']) { + return array_map(fn($c) => substr($c['Id'], 0, 12) . ';0.50%;12.5MiB / 7.7GiB', fv3d_running($d)); + } + return null; +} + +if (($argv[1] ?? '') === 'cli') { + $args = array_slice($argv, 2); + $out = fv3d_cli($d, $args); + fv3d_log(($out === null ? 'UNKNOWN ' : '') . 'cli ' . implode(' ', $args) . ($out === null ? ' (' . count($args) . ' arguments)' : '')); + if ($out === null) exit(1); + echo $out ? implode("\n", $out) . "\n" : ''; + exit(0); +} + +if (($argv[1] ?? '') === 'serve') { + // It replaces the host's Docker socket: only inside fake_unraid.sh's container + if (!is_file('/.dockerenv') || !is_file('/var/run/fv3-fake-unraid')) { fwrite(STDERR, "docker.php serve runs only under fake_unraid.sh\n"); exit(2); } + $sock = '/var/run/docker.sock'; + @unlink($sock); + $server = stream_socket_server("unix://$sock", $errno, $errstr); + if (!$server) { fwrite(STDERR, "docker.sock: $errstr\n"); exit(2); } + chmod($sock, 0666); + file_put_contents('/var/run/dockerd.pid', getmypid()); + while (true) { + $conn = @stream_socket_accept($server, -1); + if (!$conn) continue; + $request = (string)fgets($conn); + while (($line = fgets($conn)) !== false && rtrim($line) !== ''); + [$method, $target] = array_pad(explode(' ', trim($request)), 2, ''); + [$status, $body] = fv3d_answer($d, $method, $target); + fv3d_log(($status === null ? 'UNKNOWN ' : '') . "socket $method $target"); + if ($status === null) [$status, $body] = [404, ['message' => 'page not found']]; + // One line of JSON with a length: DockerClient decodes the body line by line + $json = json_encode($body, JSON_UNESCAPED_SLASHES) . "\n"; + fwrite($conn, "HTTP/1.1 $status " . ($status === 200 ? 'OK' : 'Not Found') . "\r\nContent-Type: application/json\r\nContent-Length: " . strlen($json) . "\r\nConnection: close\r\n\r\n$json"); + fclose($conn); + } +} +fwrite(STDERR, "usage: docker.php serve | cli \n"); +exit(2); diff --git a/.github/unraid-compat/fake/ip.sh b/.github/unraid-compat/fake/ip.sh new file mode 100644 index 00000000..38682d6c --- /dev/null +++ b/.github/unraid-compat/fake/ip.sh @@ -0,0 +1,9 @@ +#!/bin/bash +# Stand-in for the OS image's ip: eth0's IPv4 address from network.ini, the one form Unraid's ipaddr() asks from 7.1 +addr=$(sed -n 's/^IPADDR:0="\(.*\)"$/\1/p' /var/local/emhttp/network.ini 2>/dev/null) +# Matched on the argument count as well as the words, so the same words split another way are not answered +case "$#:$*" in +'7:-4 -br addr show eth0 scope global') [ -n "$addr" ] && echo "eth0 UP $addr/24 " && exit 0 ;; +esac +echo "ip UNKNOWN $* ($# arguments; network.ini address: ${addr:-none})" >> /var/log/fv3-fakes.log +exit 1 diff --git a/.github/unraid-compat/fake/libvirt.php b/.github/unraid-compat/fake/libvirt.php new file mode 100644 index 00000000..41f15ba5 --- /dev/null +++ b/.github/unraid-compat/fake/libvirt.php @@ -0,0 +1,154 @@ + $d) if (is_resource($dom) && fv3l_handle('domain', $name) === $dom) return $d; + $GLOBALS['fv3l_error'] = 'invalid domain handle'; + return null; +} + +function fv3l_lookup(string $field, $value) { + foreach (fv3l_domains() as $name => $d) if ($d[$field] === $value) return fv3l_handle('domain', $name); + $GLOBALS['fv3l_error'] = "Domain not found: no domain with matching $field '$value'"; + return false; +} + +// Unraid's Libvirt class connects read-write to qemu:///system; another URI or a read-only connection is not this fake +function libvirt_connect($uri = null, $readonly = true, $credentials = []) { + if ($uri !== 'qemu:///system' || $readonly !== false) { fv3l_log('UNKNOWN libvirt_connect to ' . var_export($uri, true) . ($readonly === false ? '' : ' read-only')); return false; } + return fv3l_handle('connection', 'qemu:///system'); +} +function libvirt_get_last_error() { return $GLOBALS['fv3l_error'] ?? null; } +function libvirt_logfile_set($filename, $maxsize = 0) { return true; } +function libvirt_connect_get_uri($conn) { return 'qemu:///system'; } +function libvirt_connect_get_hostname($conn) { return 'Tower'; } +function libvirt_list_domains($conn) { return array_keys(fv3l_domains()); } +function libvirt_list_active_domain_ids($conn) { return array_values(array_map(fn($d) => $d['id'], array_filter(fv3l_domains(), fn($d) => $d['id'] > 0))); } +function libvirt_domain_lookup_by_name($conn, $name) { return fv3l_lookup('name', (string)$name); } +function libvirt_domain_lookup_by_uuid_string($conn, $uuid) { return fv3l_lookup('uuid', (string)$uuid); } +function libvirt_domain_get_name($dom) { return fv3l_domain($dom)['name'] ?? false; } +function libvirt_domain_get_uuid_string($dom) { return fv3l_domain($dom)['uuid'] ?? false; } +function libvirt_domain_get_id($dom) { $d = fv3l_domain($dom); return $d ? $d['id'] : false; } +function libvirt_domain_is_active($dom) { $d = fv3l_domain($dom); return $d ? $d['id'] > 0 : false; } +function libvirt_domain_get_autostart($dom) { $d = fv3l_domain($dom); return $d ? (int)$d['autostart'] : false; } +// The live XML only, as Unraid asks for it ($dom, 0): an xpath or flags would be a form this fake does not answer +function libvirt_domain_get_xml_desc($dom, $xpath = null, $flags = 0) { + if (!in_array($xpath, [null, 0, '0', ''], true) || $flags !== 0) { fv3l_log('UNKNOWN libvirt_domain_get_xml_desc with an xpath or flags'); return false; } + return fv3l_domain($dom)['xml'] ?? false; +} +function libvirt_list_domain_snapshots($dom) { return fv3l_domain($dom) ? [] : false; } + +function libvirt_domain_get_info($dom) { + $d = fv3l_domain($dom); + if (!$d) return false; + $xml = simplexml_load_string($d['xml']); + return ['maxMem' => (int)$xml->memory, 'memory' => (int)$xml->currentMemory, 'state' => $d['state'], 'nrVirtCpu' => (int)$xml->vcpu, 'cpuUsed' => $d['id'] > 0 ? 12.5 : 0]; +} + +function libvirt_node_get_info($conn) { + return ['model' => 'x86_64', 'memory' => 16777216, 'cpus' => 8, 'nodes' => 1, 'sockets' => 1, 'cores' => 4, 'threads' => 2, 'mhz' => 3600]; +} + +// Each disk is a 20 GiB image at the path its XML names +function libvirt_domain_get_block_info($dom, $dev) { + $d = fv3l_domain($dom); + if (!$d) return false; + foreach (simplexml_load_string($d['xml'])->devices->disk as $disk) { + if ((string)$disk->target['dev'] !== (string)$dev) continue; + $size = 21474836480; + return ['device' => (string)$dev, 'file' => (string)$disk->source['file'], 'type' => (string)$disk->driver['type'], 'capacity' => $size, 'allocation' => $size, 'physical' => $size]; + } + $GLOBALS['fv3l_error'] = "invalid argument: no disk with target $dev"; + return false; +} + +// Unraid's VM usage poller asks for every stat of every domain ($conn alone) and reads these keys; a stats or flags selection is +// a form this fake does not answer. An active domain (running or paused) has used some CPU time and holds all its memory +// (balloon.rss, which libvirt reports only for an active domain) +function libvirt_connect_get_all_domain_stats($conn, $stats = 0, $flags = 0) { + if ($stats !== 0 || $flags !== 0) { fv3l_log('UNKNOWN libvirt_connect_get_all_domain_stats with a stats or flags selection'); return false; } + $all = []; + foreach (fv3l_domains() as $name => $d) { + $info = libvirt_domain_get_info(fv3l_handle('domain', $name)); + $all[$name] = ['state.state' => $d['state'], 'state.reason' => 1, 'cpu.time' => $d['id'] > 0 ? 125000000000 : 0, + 'vcpu.current' => $info['nrVirtCpu'], 'vcpu.maximum' => $info['nrVirtCpu'], 'balloon.current' => $info['memory'], + 'balloon.maximum' => $info['maxMem'], 'net.count' => 0, 'block.count' => 0] + ($d['id'] > 0 ? ['balloon.rss' => $info['memory']] : []); + } + return $all; +} + +function libvirt_domain_get_counts($conn) { + $active = count(array_filter(fv3l_domains(), fn($d) => $d['id'] > 0)); + return ['total' => count(fv3l_domains()), 'active' => $active, 'inactive' => count(fv3l_domains()) - $active]; +} + +// php-libvirt's answer: the matches' text in order, their count under 'num', and false when nothing matches +function libvirt_domain_xml_xpath($dom, $xpath, $flags = 0) { + if ($flags !== 0) { fv3l_log('UNKNOWN libvirt_domain_xml_xpath on the inactive XML'); return false; } + $d = fv3l_domain($dom); + if (!$d) return false; + $doc = new DOMDocument(); + $doc->loadXML($d['xml']); + $nodes = @(new DOMXPath($doc))->query($xpath); + if ($nodes === false) { $GLOBALS['fv3l_error'] = "invalid xpath $xpath"; return false; } + if ($nodes->length === 0) return false; + $out = ['xpath' => $xpath, 'num' => $nodes->length]; + foreach ($nodes as $i => $node) $out[$i] = $node->nodeValue; + return $out; +} + +// Every other libvirt_* function in the webGUI's code at 7.0.1-7.4.0: none has an answer here yet +foreach (['libvirt_connect_get_information', 'libvirt_connect_get_capabilities', 'libvirt_connect_get_machine_types', + 'libvirt_connect_get_domain_capabilities', 'libvirt_has_feature', + 'libvirt_list_nodedevs', 'libvirt_nodedev_get', 'libvirt_nodedev_get_xml_desc', 'libvirt_nodedev_get_information', + 'libvirt_nodedev_capabilities', 'libvirt_list_networks', 'libvirt_network_get', 'libvirt_network_get_xml_desc', 'libvirt_get_net_res', + 'libvirt_get_net_list', 'libvirt_get_net_xml', 'libvirt_domain_interface_addresses', + 'libvirt_domain_interface_stats', 'libvirt_domain_get_interface_devices', 'libvirt_domain_memory_stats', + 'libvirt_domain_get_screen_dimensions', 'libvirt_domain_qemu_agent_command', 'libvirt_domain_define_xml', 'libvirt_domain_create_xml', + 'libvirt_domain_undefine', 'libvirt_domain_update_device', 'libvirt_domain_create', 'libvirt_domain_destroy', 'libvirt_domain_shutdown', + 'libvirt_domain_reboot', 'libvirt_domain_suspend', 'libvirt_domain_resume', 'libvirt_domain_managedsave', 'libvirt_domain_set_autostart', + 'libvirt_domain_change_boot_devices', 'libvirt_domain_disk_remove', 'libvirt_domain_send_keys', 'libvirt_domain_send_pointer_event', + 'libvirt_domain_snapshot_create', 'libvirt_domain_snapshot_delete', 'libvirt_domain_snapshot_get_xml', 'libvirt_domain_snapshot_lookup_by_name', + 'libvirt_domain_snapshot_revert', 'libvirt_storagevolume_create_xml', 'libvirt_version'] as $fv3lName) { + eval("function $fv3lName(...\$args) { fv3l_log('UNKNOWN $fv3lName'); \$GLOBALS['fv3l_error'] = 'not in the fake'; return false; }"); +} +unset($fv3lName); diff --git a/.github/unraid-compat/fake/prepend.php b/.github/unraid-compat/fake/prepend.php new file mode 100644 index 00000000..785ca16f --- /dev/null +++ b/.github/unraid-compat/fake/prepend.php @@ -0,0 +1,5 @@ +> /var/log/fv3-fakes.log +exit 1 diff --git a/.github/unraid-compat/fake/router.php b/.github/unraid-compat/fake/router.php new file mode 100644 index 00000000..63fd04fa --- /dev/null +++ b/.github/unraid-compat/fake/router.php @@ -0,0 +1,19 @@ + +set -u +version=$2; repo=$(pwd); here=$repo/.github/unraid-compat +. "$here/lib.sh" +# Past lib.sh's guard: fake/docker.php and pages_test.php refuse to run without this +mkdir -p /var/run && touch /var/run/fv3-fake-unraid || fail 'no marker' +fv3_docroot "$1" || fail "no Unraid webGUI under $1" + +# FV3 as upgradepkg leaves it, and the config folder its .plg makes +fv3_build "$repo" 2099.01.01 beta || fail 'package build' +tar -xJf "$work/2099.01.01/dist/$name-2099.01.01-x86_64-1.txz" -C / || fail 'package unpack' +mkdir -p "$flash/styles" "$flash/scripts" && printf '2099.01.01' > "$flash/version" + +# Unraid's own state in emhttp's files, the array started: a synthetic licence and flash, root alone, and no devices, disks +# or user shares +printf 'version="%s"\n' "$version" > /etc/unraid-version +cat >> /var/local/emhttp/var.ini < /var/local/emhttp/$ini.ini; done +printf '["root"]\nidx="0"\nname="root"\ndesc="Console and webGui login account"\npasswd="yes"\n' > /var/local/emhttp/users.ini +printf '[eth0]\nBONDING="no"\nBRIDGING="no"\nIPADDR:0="192.0.2.10"\nNETMASK:0="255.255.255.0"\nUSE_DHCP:0="no"\n' > /var/local/emhttp/network.ini +printf 'DOCKER_ENABLED="yes"\n' > /boot/config/docker.cfg +# DEBUG keeps PHP warnings on: without it Unraid's libvirt_helpers.php, which FV3 loads, turns error reporting off +printf 'SERVICE="enable"\nDEBUG="yes"\n' > /boot/config/domain.cfg +# Unraid's own writers add every other key with its default +for cfg in dynamix.docker.manager/scripts/dockerconfig dynamix.vm.manager/scripts/libvirtconfig; do + php -d short_open_tag=On $docroot/plugins/$cfg || fail "$cfg" +done +# The OS image adds the Connect plugin, which the webGUI repo lacks from 7.2 on: the header includes its myservers files, and +# from 7.4 requires its state class +if [ ! -f $docroot/plugins/dynamix.my.servers/include/state.php ]; then + mkdir -p $docroot/plugins/dynamix.my.servers/include + cp "$here/fake/connect_state.php" $docroot/plugins/dynamix.my.servers/include/state.php + : > $docroot/plugins/dynamix.my.servers/include/myservers1.php + : > $docroot/plugins/dynamix.my.servers/include/myservers2.php +fi +ln -sf $docroot/plugins/dynamix.plugin.manager/scripts/plugin /usr/local/sbin/plugin + +# A saved setup: Media holds app-a by hand and app-b by its label, Tools takes tool-c by regex, app-d is loose; Lab holds a VM +mkdir -p /boot/config/plugins/dockerMan/templates-user /boot/config/plugins/dynamix.vm.manager /var/lib/docker +cat > "$flash/docker.json" <<'EOF' +{"MediaAbCdEfGhIjKlMnO":{"name":"Media","icon":"","regex":"","containers":["app-a"],"settings":{"preview":1},"actions":[]},"ToolsPqRsTuVwXyZaBcD":{"name":"Tools","icon":"","regex":"^tool-","containers":[],"settings":{"preview":1},"actions":[]}} +EOF +cat > "$flash/vm.json" <<'EOF' +{"LabFoldAbCdEfGhIjKlM":{"name":"Lab","icon":"","regex":"","containers":["Debian 12"],"settings":{"preview":1},"actions":[]}} +EOF +printf '0="folder-MediaAbCdEfGhIjKlMnO"\n1="app-a"\n2="app-b"\n3="folder-ToolsPqRsTuVwXyZaBcD"\n4="tool-c"\n5="app-d"\n' > /boot/config/plugins/dockerMan/userprefs.cfg +printf '0="folder-LabFoldAbCdEfGhIjKlM"\n1="Debian 12"\n2="Home Assistant"\n3="Windows 11"\n' > /boot/config/plugins/dynamix.vm.manager/userprefs.cfg +printf 'app-a\napp-d 10\n' > /var/lib/docker/unraid-autostart +cat > /boot/config/plugins/dockerMan/templates-user/my-app-a.xml <<'EOF' + + + app-a + alpine:3.20 + bridge + sh + http://[IP]:[PORT:8080]/ + 18080 + +EOF + +# PHP as Unraid's php.ini sets it: short tags, the prepend, errors to a log and never into a page +cat > "$PHP_INI_DIR/conf.d/zz-fake-unraid.ini" < /var/log/phplog; : > /var/log/fv3-fakes.log + +# Docker and libvirtd under their own names and rc scripts, so Unraid's pgrep(), /proc/ and status checks find them running +mkdir -p /etc/rc.d && for rc in rc.docker rc.libvirt; do cp "$here/fake/rc_service.sh" /etc/rc.d/$rc && chmod +x /etc/rc.d/$rc; done +# The OS image's dmidecode and ip: the forms Unraid's Dashboard and ipaddr() run, anything else UNKNOWN +for cmd in dmidecode ip; do cp "$here/fake/$cmd.sh" /usr/sbin/$cmd && chmod +x /usr/sbin/$cmd; done +printf '#!/bin/sh\nexec php %s/fake/docker.php cli "$@"\n' "$here" > /usr/local/bin/docker && chmod +x /usr/local/bin/docker +ln -sf "$(command -v php)" /usr/local/sbin/dockerd; ln -sf "$(command -v sleep)" /usr/local/sbin/libvirtd +dockerd "$here/fake/docker.php" serve > /var/log/dockerd.log 2>&1 & +mkdir -p /var/run/libvirt; libvirtd infinity & echo $! > /var/run/libvirt/libvirtd.pid +php -S 127.0.0.1:80 -t $docroot "$here/fake/router.php" > /var/log/php-server.log 2>&1 & +for _ in $(seq 300); do + [ -S /var/run/docker.sock ] && [ -s /var/run/dockerd.pid ] && curl -sf -o /dev/null http://127.0.0.1/robots.txt && exit 0 + sleep 0.1 +done +fail "the fake Unraid did not start: $(cat /var/log/dockerd.log /var/log/php-server.log)" diff --git a/.github/unraid-compat/fixtures/docker.json b/.github/unraid-compat/fixtures/docker.json new file mode 100644 index 00000000..b10c3b1b --- /dev/null +++ b/.github/unraid-compat/fixtures/docker.json @@ -0,0 +1,25 @@ +{ + "containers": [ + {"Id":"c02cabde5b2bae8bbe0ed4a53597fc7f6a95317322f9df9f415d49837824bb6f","Names":["/app-d"],"Image":"alpine:3.20","ImageID":"sha256:1ff3b73d4cc7e7dcaff2ff9071a710eabe41b5da61ebd2dabc9febe5d974b615","ImageManifestDescriptor":{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"sha256:704f8823e322c9ae8c92aa3a330e9df3a626ca80158f016ed3d12903a28d9e39","size":1026,"annotations":{"com.docker.official-images.bashbrew.arch":"amd64","org.opencontainers.image.base.name":"scratch","org.opencontainers.image.created":"2026-04-16T23:53:21Z","org.opencontainers.image.revision":"0db70ae354ee747109ce0b9a0cfbcd3c907bc822","org.opencontainers.image.source":"https://github.com/alpinelinux/docker-alpine.git#0db70ae354ee747109ce0b9a0cfbcd3c907bc822:x86_64","org.opencontainers.image.url":"https://hub.docker.com/_/alpine","org.opencontainers.image.version":"3.20.10"},"platform":{"architecture":"amd64","os":"linux"}},"Command":"sleep 3600","Created":1794654654,"Ports":[],"Labels":{"net.unraid.docker.managed":"dockerman"},"State":"running","Status":"Up Less than a second","HostConfig":{"NetworkMode":"host"},"Health":{"Status":"none","FailingStreak":0},"NetworkSettings":{"Networks":{"host":{"IPAMConfig":null,"Links":null,"Aliases":null,"DriverOpts":null,"GwPriority":0,"NetworkID":"d76277a5b0783027956af1e58f401a4a9018b9e63f2c0bde7babe8c8bdc23378","EndpointID":"51578f75b98400841232ddda91450f8b4bd6fc805fea58ba6f0b864e27b3d39a","Gateway":"","IPAddress":"","MacAddress":"","IPPrefixLen":0,"IPv6Gateway":"","GlobalIPv6Address":"","GlobalIPv6PrefixLen":0,"DNSNames":null}}},"Mounts":[]}, + {"Id":"6f0a162e593d88facb5c669bb52959572ca3571de86575e7fcc2a69f1eddd4d8","Names":["/tool-c"],"Image":"alpine:3.20","ImageID":"sha256:1ff3b73d4cc7e7dcaff2ff9071a710eabe41b5da61ebd2dabc9febe5d974b615","ImageManifestDescriptor":{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"sha256:704f8823e322c9ae8c92aa3a330e9df3a626ca80158f016ed3d12903a28d9e39","size":1026,"annotations":{"com.docker.official-images.bashbrew.arch":"amd64","org.opencontainers.image.base.name":"scratch","org.opencontainers.image.created":"2026-04-16T23:53:21Z","org.opencontainers.image.revision":"0db70ae354ee747109ce0b9a0cfbcd3c907bc822","org.opencontainers.image.source":"https://github.com/alpinelinux/docker-alpine.git#0db70ae354ee747109ce0b9a0cfbcd3c907bc822:x86_64","org.opencontainers.image.url":"https://hub.docker.com/_/alpine","org.opencontainers.image.version":"3.20.10"},"platform":{"architecture":"amd64","os":"linux"}},"Command":"sleep 3600","Created":1794654654,"Ports":[],"Labels":{"net.unraid.docker.managed":"dockerman"},"State":"created","Status":"Created","HostConfig":{"NetworkMode":"bridge"},"Health":{"Status":"none","FailingStreak":0},"NetworkSettings":{"Networks":{"bridge":{"IPAMConfig":null,"Links":null,"Aliases":null,"DriverOpts":null,"GwPriority":0,"NetworkID":"","EndpointID":"","Gateway":"","IPAddress":"","MacAddress":"","IPPrefixLen":0,"IPv6Gateway":"","GlobalIPv6Address":"","GlobalIPv6PrefixLen":0,"DNSNames":null}}},"Mounts":[]}, + {"Id":"74f3b261653ad172efc0f1f7cc23c596605e85fafe84cbcb9f39a17480935df7","Names":["/app-b"],"Image":"alpine:3.20","ImageID":"sha256:1ff3b73d4cc7e7dcaff2ff9071a710eabe41b5da61ebd2dabc9febe5d974b615","ImageManifestDescriptor":{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"sha256:704f8823e322c9ae8c92aa3a330e9df3a626ca80158f016ed3d12903a28d9e39","size":1026,"annotations":{"com.docker.official-images.bashbrew.arch":"amd64","org.opencontainers.image.base.name":"scratch","org.opencontainers.image.created":"2026-04-16T23:53:21Z","org.opencontainers.image.revision":"0db70ae354ee747109ce0b9a0cfbcd3c907bc822","org.opencontainers.image.source":"https://github.com/alpinelinux/docker-alpine.git#0db70ae354ee747109ce0b9a0cfbcd3c907bc822:x86_64","org.opencontainers.image.url":"https://hub.docker.com/_/alpine","org.opencontainers.image.version":"3.20.10"},"platform":{"architecture":"amd64","os":"linux"}},"Command":"sleep 3600","Created":1794654654,"Ports":[],"Labels":{"folder.view3":"Media","net.unraid.docker.managed":"dockerman"},"State":"running","Status":"Up Less than a second","HostConfig":{"NetworkMode":"bridge"},"Health":{"Status":"none","FailingStreak":0},"NetworkSettings":{"Networks":{"bridge":{"IPAMConfig":null,"Links":null,"Aliases":null,"DriverOpts":null,"GwPriority":0,"NetworkID":"9a33407be38f647fe4c00b47444159cf8cb2484ea0e716778a059c23c62cfcf4","EndpointID":"997b20e28c8074ea75a32f93fe786be4221aa760c27900338354945b216b6794","Gateway":"172.17.0.1","IPAddress":"172.17.0.3","MacAddress":"02:42:ac:11:00:02","IPPrefixLen":16,"IPv6Gateway":"","GlobalIPv6Address":"","GlobalIPv6PrefixLen":0,"DNSNames":null}}},"Mounts":[]}, + {"Id":"7da32cf55ebd070122ced08ab094712770b1d5e3f0a2ba68e84809e6a0e67104","Names":["/app-a"],"Image":"alpine:3.20","ImageID":"sha256:1ff3b73d4cc7e7dcaff2ff9071a710eabe41b5da61ebd2dabc9febe5d974b615","ImageManifestDescriptor":{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"sha256:704f8823e322c9ae8c92aa3a330e9df3a626ca80158f016ed3d12903a28d9e39","size":1026,"annotations":{"com.docker.official-images.bashbrew.arch":"amd64","org.opencontainers.image.base.name":"scratch","org.opencontainers.image.created":"2026-04-16T23:53:21Z","org.opencontainers.image.revision":"0db70ae354ee747109ce0b9a0cfbcd3c907bc822","org.opencontainers.image.source":"https://github.com/alpinelinux/docker-alpine.git#0db70ae354ee747109ce0b9a0cfbcd3c907bc822:x86_64","org.opencontainers.image.url":"https://hub.docker.com/_/alpine","org.opencontainers.image.version":"3.20.10"},"platform":{"architecture":"amd64","os":"linux"}},"Command":"sleep 3600","Created":1794654653,"Ports":[{"IP":"0.0.0.0","PrivatePort":8080,"PublicPort":18080,"Type":"tcp"},{"IP":"::","PrivatePort":8080,"PublicPort":18080,"Type":"tcp"}],"Labels":{"net.unraid.docker.icon":"/plugins/dynamix.docker.manager/images/question.png","net.unraid.docker.managed":"dockerman","net.unraid.docker.webui":"http://[IP]:[PORT:8080]/"},"State":"running","Status":"Up Less than a second","HostConfig":{"NetworkMode":"bridge"},"Health":{"Status":"none","FailingStreak":0},"NetworkSettings":{"Networks":{"bridge":{"IPAMConfig":null,"Links":null,"Aliases":null,"DriverOpts":null,"GwPriority":0,"NetworkID":"9a33407be38f647fe4c00b47444159cf8cb2484ea0e716778a059c23c62cfcf4","EndpointID":"b659ee595f07b05268a63cb7b00a429891b16b62726c04320af96a0ad14c2fab","Gateway":"172.17.0.1","IPAddress":"172.17.0.2","MacAddress":"02:42:ac:11:00:03","IPPrefixLen":16,"IPv6Gateway":"","GlobalIPv6Address":"","GlobalIPv6PrefixLen":0,"DNSNames":null}}},"Mounts":[]} + ], + "inspect": { + "app-a": {"Id":"7da32cf55ebd070122ced08ab094712770b1d5e3f0a2ba68e84809e6a0e67104","Created":"2026-11-14T11:10:53.865989285Z","Path":"sleep","Args":["3600"],"State":{"Status":"running","Running":true,"Paused":false,"Restarting":false,"OOMKilled":false,"Dead":false,"Pid":1001,"ExitCode":0,"Error":"","StartedAt":"2026-11-14T11:10:53.881644066Z","FinishedAt":"0001-01-01T00:00:00Z"},"Image":"sha256:1ff3b73d4cc7e7dcaff2ff9071a710eabe41b5da61ebd2dabc9febe5d974b615","ResolvConfPath":"/var/lib/docker/containers/7da32cf55ebd070122ced08ab094712770b1d5e3f0a2ba68e84809e6a0e67104/resolv.conf","HostnamePath":"/var/lib/docker/containers/7da32cf55ebd070122ced08ab094712770b1d5e3f0a2ba68e84809e6a0e67104/hostname","HostsPath":"/var/lib/docker/containers/7da32cf55ebd070122ced08ab094712770b1d5e3f0a2ba68e84809e6a0e67104/hosts","LogPath":"/var/lib/docker/containers/7da32cf55ebd070122ced08ab094712770b1d5e3f0a2ba68e84809e6a0e67104/7da32cf55ebd070122ced08ab094712770b1d5e3f0a2ba68e84809e6a0e67104-json.log","Name":"/app-a","RestartCount":0,"Driver":"overlayfs","Platform":"linux","MountLabel":"","ProcessLabel":"","AppArmorProfile":"docker-default","ExecIDs":null,"HostConfig":{"Binds":null,"ContainerIDFile":"","LogConfig":{"Type":"json-file","Config":{}},"NetworkMode":"bridge","PortBindings":{"8080/tcp":[{"HostIp":"","HostPort":"18080"}]},"RestartPolicy":{"Name":"no","MaximumRetryCount":0},"AutoRemove":false,"VolumeDriver":"","VolumesFrom":null,"ConsoleSize":[0,0],"CapAdd":null,"CapDrop":null,"CgroupnsMode":"private","Dns":null,"DnsOptions":[],"DnsSearch":[],"ExtraHosts":null,"GroupAdd":null,"IpcMode":"private","Cgroup":"","Links":null,"OomScoreAdj":0,"PidMode":"","Privileged":false,"PublishAllPorts":false,"ReadonlyRootfs":false,"SecurityOpt":null,"UTSMode":"","UsernsMode":"","ShmSize":67108864,"Runtime":"runc","Isolation":"","CpuShares":0,"Memory":0,"NanoCpus":0,"CgroupParent":"","BlkioWeight":0,"BlkioWeightDevice":[],"BlkioDeviceReadBps":[],"BlkioDeviceWriteBps":[],"BlkioDeviceReadIOps":[],"BlkioDeviceWriteIOps":[],"CpuPeriod":0,"CpuQuota":0,"CpuRealtimePeriod":0,"CpuRealtimeRuntime":0,"CpusetCpus":"","CpusetMems":"","Devices":[],"DeviceCgroupRules":null,"DeviceRequests":null,"MemoryReservation":0,"MemorySwap":0,"MemorySwappiness":null,"OomKillDisable":null,"PidsLimit":null,"Ulimits":null,"CpuCount":0,"CpuPercent":0,"IOMaximumIOps":0,"IOMaximumBandwidth":0,"MaskedPaths":["/proc/acpi","/proc/asound","/proc/interrupts","/proc/kcore","/proc/keys","/proc/latency_stats","/proc/sched_debug","/proc/scsi","/proc/timer_list","/proc/timer_stats","/sys/devices/virtual/powercap","/sys/firmware"],"ReadonlyPaths":["/proc/bus","/proc/fs","/proc/irq","/proc/sys","/proc/sysrq-trigger"]},"Storage":{"RootFS":{"Snapshot":{"Name":"overlayfs"}}},"Mounts":[],"Config":{"Hostname":"7da32cf55ebd","Domainname":"","User":"","AttachStdin":false,"AttachStdout":false,"AttachStderr":false,"ExposedPorts":{"8080/tcp":{}},"Tty":false,"OpenStdin":false,"StdinOnce":false,"Env":["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"],"Cmd":["sleep","3600"],"Image":"alpine:3.20","Volumes":null,"WorkingDir":"/","Entrypoint":null,"Labels":{"net.unraid.docker.icon":"/plugins/dynamix.docker.manager/images/question.png","net.unraid.docker.managed":"dockerman","net.unraid.docker.webui":"http://[IP]:[PORT:8080]/"}},"NetworkSettings":{"SandboxID":"427490050ddf210917ec5cf9bdb658d51e340d522578968f45f2c54f637961c7","SandboxKey":"/var/run/docker/netns/0123456789ab","Ports":{"8080/tcp":[{"HostIp":"0.0.0.0","HostPort":"18080"},{"HostIp":"::","HostPort":"18080"}]},"Networks":{"bridge":{"IPAMConfig":null,"Links":null,"Aliases":null,"DriverOpts":null,"GwPriority":0,"NetworkID":"9a33407be38f647fe4c00b47444159cf8cb2484ea0e716778a059c23c62cfcf4","EndpointID":"b659ee595f07b05268a63cb7b00a429891b16b62726c04320af96a0ad14c2fab","Gateway":"172.17.0.1","IPAddress":"172.17.0.2","MacAddress":"02:42:ac:11:00:03","IPPrefixLen":16,"IPv6Gateway":"","GlobalIPv6Address":"","GlobalIPv6PrefixLen":0,"DNSNames":null}}},"ImageManifestDescriptor":{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"sha256:704f8823e322c9ae8c92aa3a330e9df3a626ca80158f016ed3d12903a28d9e39","size":1026,"annotations":{"com.docker.official-images.bashbrew.arch":"amd64","org.opencontainers.image.base.name":"scratch","org.opencontainers.image.created":"2026-04-16T23:53:21Z","org.opencontainers.image.revision":"0db70ae354ee747109ce0b9a0cfbcd3c907bc822","org.opencontainers.image.source":"https://github.com/alpinelinux/docker-alpine.git#0db70ae354ee747109ce0b9a0cfbcd3c907bc822:x86_64","org.opencontainers.image.url":"https://hub.docker.com/_/alpine","org.opencontainers.image.version":"3.20.10"},"platform":{"architecture":"amd64","os":"linux"}}}, + "app-b": {"Id":"74f3b261653ad172efc0f1f7cc23c596605e85fafe84cbcb9f39a17480935df7","Created":"2026-11-14T11:10:54.013835226Z","Path":"sleep","Args":["3600"],"State":{"Status":"running","Running":true,"Paused":false,"Restarting":false,"OOMKilled":false,"Dead":false,"Pid":1002,"ExitCode":0,"Error":"","StartedAt":"2026-11-14T11:10:54.04418883Z","FinishedAt":"0001-01-01T00:00:00Z"},"Image":"sha256:1ff3b73d4cc7e7dcaff2ff9071a710eabe41b5da61ebd2dabc9febe5d974b615","ResolvConfPath":"/var/lib/docker/containers/74f3b261653ad172efc0f1f7cc23c596605e85fafe84cbcb9f39a17480935df7/resolv.conf","HostnamePath":"/var/lib/docker/containers/74f3b261653ad172efc0f1f7cc23c596605e85fafe84cbcb9f39a17480935df7/hostname","HostsPath":"/var/lib/docker/containers/74f3b261653ad172efc0f1f7cc23c596605e85fafe84cbcb9f39a17480935df7/hosts","LogPath":"/var/lib/docker/containers/74f3b261653ad172efc0f1f7cc23c596605e85fafe84cbcb9f39a17480935df7/74f3b261653ad172efc0f1f7cc23c596605e85fafe84cbcb9f39a17480935df7-json.log","Name":"/app-b","RestartCount":0,"Driver":"overlayfs","Platform":"linux","MountLabel":"","ProcessLabel":"","AppArmorProfile":"docker-default","ExecIDs":null,"HostConfig":{"Binds":null,"ContainerIDFile":"","LogConfig":{"Type":"json-file","Config":{}},"NetworkMode":"bridge","PortBindings":{},"RestartPolicy":{"Name":"no","MaximumRetryCount":0},"AutoRemove":false,"VolumeDriver":"","VolumesFrom":null,"ConsoleSize":[0,0],"CapAdd":null,"CapDrop":null,"CgroupnsMode":"private","Dns":null,"DnsOptions":[],"DnsSearch":[],"ExtraHosts":null,"GroupAdd":null,"IpcMode":"private","Cgroup":"","Links":null,"OomScoreAdj":0,"PidMode":"","Privileged":false,"PublishAllPorts":false,"ReadonlyRootfs":false,"SecurityOpt":null,"UTSMode":"","UsernsMode":"","ShmSize":67108864,"Runtime":"runc","Isolation":"","CpuShares":0,"Memory":0,"NanoCpus":0,"CgroupParent":"","BlkioWeight":0,"BlkioWeightDevice":[],"BlkioDeviceReadBps":[],"BlkioDeviceWriteBps":[],"BlkioDeviceReadIOps":[],"BlkioDeviceWriteIOps":[],"CpuPeriod":0,"CpuQuota":0,"CpuRealtimePeriod":0,"CpuRealtimeRuntime":0,"CpusetCpus":"","CpusetMems":"","Devices":[],"DeviceCgroupRules":null,"DeviceRequests":null,"MemoryReservation":0,"MemorySwap":0,"MemorySwappiness":null,"OomKillDisable":null,"PidsLimit":null,"Ulimits":null,"CpuCount":0,"CpuPercent":0,"IOMaximumIOps":0,"IOMaximumBandwidth":0,"MaskedPaths":["/proc/acpi","/proc/asound","/proc/interrupts","/proc/kcore","/proc/keys","/proc/latency_stats","/proc/sched_debug","/proc/scsi","/proc/timer_list","/proc/timer_stats","/sys/devices/virtual/powercap","/sys/firmware"],"ReadonlyPaths":["/proc/bus","/proc/fs","/proc/irq","/proc/sys","/proc/sysrq-trigger"]},"Storage":{"RootFS":{"Snapshot":{"Name":"overlayfs"}}},"Mounts":[],"Config":{"Hostname":"74f3b261653a","Domainname":"","User":"","AttachStdin":false,"AttachStdout":false,"AttachStderr":false,"Tty":false,"OpenStdin":false,"StdinOnce":false,"Env":["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"],"Cmd":["sleep","3600"],"Image":"alpine:3.20","Volumes":null,"WorkingDir":"/","Entrypoint":null,"Labels":{"folder.view3":"Media","net.unraid.docker.managed":"dockerman"}},"NetworkSettings":{"SandboxID":"32bdb90ab4c38d97d285fc4330f4d1c810e095b1f6a0e77c1e2fe8e654ead58c","SandboxKey":"/var/run/docker/netns/0123456789ab","Ports":{},"Networks":{"bridge":{"IPAMConfig":null,"Links":null,"Aliases":null,"DriverOpts":null,"GwPriority":0,"NetworkID":"9a33407be38f647fe4c00b47444159cf8cb2484ea0e716778a059c23c62cfcf4","EndpointID":"997b20e28c8074ea75a32f93fe786be4221aa760c27900338354945b216b6794","Gateway":"172.17.0.1","IPAddress":"172.17.0.3","MacAddress":"02:42:ac:11:00:02","IPPrefixLen":16,"IPv6Gateway":"","GlobalIPv6Address":"","GlobalIPv6PrefixLen":0,"DNSNames":null}}},"ImageManifestDescriptor":{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"sha256:704f8823e322c9ae8c92aa3a330e9df3a626ca80158f016ed3d12903a28d9e39","size":1026,"annotations":{"com.docker.official-images.bashbrew.arch":"amd64","org.opencontainers.image.base.name":"scratch","org.opencontainers.image.created":"2026-04-16T23:53:21Z","org.opencontainers.image.revision":"0db70ae354ee747109ce0b9a0cfbcd3c907bc822","org.opencontainers.image.source":"https://github.com/alpinelinux/docker-alpine.git#0db70ae354ee747109ce0b9a0cfbcd3c907bc822:x86_64","org.opencontainers.image.url":"https://hub.docker.com/_/alpine","org.opencontainers.image.version":"3.20.10"},"platform":{"architecture":"amd64","os":"linux"}}}, + "tool-c": {"Id":"6f0a162e593d88facb5c669bb52959572ca3571de86575e7fcc2a69f1eddd4d8","Created":"2026-11-14T11:10:54.108306911Z","Path":"sleep","Args":["3600"],"State":{"Status":"created","Running":false,"Paused":false,"Restarting":false,"OOMKilled":false,"Dead":false,"Pid":0,"ExitCode":0,"Error":"","StartedAt":"0001-01-01T00:00:00Z","FinishedAt":"0001-01-01T00:00:00Z"},"Image":"sha256:1ff3b73d4cc7e7dcaff2ff9071a710eabe41b5da61ebd2dabc9febe5d974b615","ResolvConfPath":"","HostnamePath":"","HostsPath":"","LogPath":"","Name":"/tool-c","RestartCount":0,"Driver":"overlayfs","Platform":"linux","MountLabel":"","ProcessLabel":"","AppArmorProfile":"","ExecIDs":null,"HostConfig":{"Binds":null,"ContainerIDFile":"","LogConfig":{"Type":"json-file","Config":{}},"NetworkMode":"bridge","PortBindings":{},"RestartPolicy":{"Name":"no","MaximumRetryCount":0},"AutoRemove":false,"VolumeDriver":"","VolumesFrom":null,"ConsoleSize":[0,0],"CapAdd":null,"CapDrop":null,"CgroupnsMode":"private","Dns":null,"DnsOptions":[],"DnsSearch":[],"ExtraHosts":null,"GroupAdd":null,"IpcMode":"private","Cgroup":"","Links":null,"OomScoreAdj":0,"PidMode":"","Privileged":false,"PublishAllPorts":false,"ReadonlyRootfs":false,"SecurityOpt":null,"UTSMode":"","UsernsMode":"","ShmSize":67108864,"Runtime":"runc","Isolation":"","CpuShares":0,"Memory":0,"NanoCpus":0,"CgroupParent":"","BlkioWeight":0,"BlkioWeightDevice":[],"BlkioDeviceReadBps":[],"BlkioDeviceWriteBps":[],"BlkioDeviceReadIOps":[],"BlkioDeviceWriteIOps":[],"CpuPeriod":0,"CpuQuota":0,"CpuRealtimePeriod":0,"CpuRealtimeRuntime":0,"CpusetCpus":"","CpusetMems":"","Devices":[],"DeviceCgroupRules":null,"DeviceRequests":null,"MemoryReservation":0,"MemorySwap":0,"MemorySwappiness":null,"OomKillDisable":false,"PidsLimit":null,"Ulimits":null,"CpuCount":0,"CpuPercent":0,"IOMaximumIOps":0,"IOMaximumBandwidth":0,"MaskedPaths":["/proc/acpi","/proc/asound","/proc/interrupts","/proc/kcore","/proc/keys","/proc/latency_stats","/proc/sched_debug","/proc/scsi","/proc/timer_list","/proc/timer_stats","/sys/devices/virtual/powercap","/sys/firmware"],"ReadonlyPaths":["/proc/bus","/proc/fs","/proc/irq","/proc/sys","/proc/sysrq-trigger"]},"Storage":{"RootFS":{"Snapshot":{"Name":"overlayfs"}}},"Mounts":[],"Config":{"Hostname":"6f0a162e593d","Domainname":"","User":"","AttachStdin":false,"AttachStdout":true,"AttachStderr":true,"Tty":false,"OpenStdin":false,"StdinOnce":false,"Env":["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"],"Cmd":["sleep","3600"],"Image":"alpine:3.20","Volumes":null,"WorkingDir":"/","Entrypoint":null,"Labels":{"net.unraid.docker.managed":"dockerman"}},"NetworkSettings":{"SandboxID":"","SandboxKey":"","Ports":{},"Networks":{"bridge":{"IPAMConfig":null,"Links":null,"Aliases":null,"DriverOpts":null,"GwPriority":0,"NetworkID":"","EndpointID":"","Gateway":"","IPAddress":"","MacAddress":"","IPPrefixLen":0,"IPv6Gateway":"","GlobalIPv6Address":"","GlobalIPv6PrefixLen":0,"DNSNames":null}}},"ImageManifestDescriptor":{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"sha256:704f8823e322c9ae8c92aa3a330e9df3a626ca80158f016ed3d12903a28d9e39","size":1026,"annotations":{"com.docker.official-images.bashbrew.arch":"amd64","org.opencontainers.image.base.name":"scratch","org.opencontainers.image.created":"2026-04-16T23:53:21Z","org.opencontainers.image.revision":"0db70ae354ee747109ce0b9a0cfbcd3c907bc822","org.opencontainers.image.source":"https://github.com/alpinelinux/docker-alpine.git#0db70ae354ee747109ce0b9a0cfbcd3c907bc822:x86_64","org.opencontainers.image.url":"https://hub.docker.com/_/alpine","org.opencontainers.image.version":"3.20.10"},"platform":{"architecture":"amd64","os":"linux"}}}, + "app-d": {"Id":"c02cabde5b2bae8bbe0ed4a53597fc7f6a95317322f9df9f415d49837824bb6f","Created":"2026-11-14T11:10:54.137826016Z","Path":"sleep","Args":["3600"],"State":{"Status":"running","Running":true,"Paused":false,"Restarting":false,"OOMKilled":false,"Dead":false,"Pid":1003,"ExitCode":0,"Error":"","StartedAt":"2026-11-14T11:10:54.155919462Z","FinishedAt":"0001-01-01T00:00:00Z"},"Image":"sha256:1ff3b73d4cc7e7dcaff2ff9071a710eabe41b5da61ebd2dabc9febe5d974b615","ResolvConfPath":"/var/lib/docker/containers/c02cabde5b2bae8bbe0ed4a53597fc7f6a95317322f9df9f415d49837824bb6f/resolv.conf","HostnamePath":"/var/lib/docker/containers/c02cabde5b2bae8bbe0ed4a53597fc7f6a95317322f9df9f415d49837824bb6f/hostname","HostsPath":"/var/lib/docker/containers/c02cabde5b2bae8bbe0ed4a53597fc7f6a95317322f9df9f415d49837824bb6f/hosts","LogPath":"/var/lib/docker/containers/c02cabde5b2bae8bbe0ed4a53597fc7f6a95317322f9df9f415d49837824bb6f/c02cabde5b2bae8bbe0ed4a53597fc7f6a95317322f9df9f415d49837824bb6f-json.log","Name":"/app-d","RestartCount":0,"Driver":"overlayfs","Platform":"linux","MountLabel":"","ProcessLabel":"","AppArmorProfile":"docker-default","ExecIDs":null,"HostConfig":{"Binds":null,"ContainerIDFile":"","LogConfig":{"Type":"json-file","Config":{}},"NetworkMode":"host","PortBindings":{},"RestartPolicy":{"Name":"no","MaximumRetryCount":0},"AutoRemove":false,"VolumeDriver":"","VolumesFrom":null,"ConsoleSize":[0,0],"CapAdd":null,"CapDrop":null,"CgroupnsMode":"private","Dns":null,"DnsOptions":[],"DnsSearch":[],"ExtraHosts":null,"GroupAdd":null,"IpcMode":"private","Cgroup":"","Links":null,"OomScoreAdj":0,"PidMode":"","Privileged":false,"PublishAllPorts":false,"ReadonlyRootfs":false,"SecurityOpt":null,"UTSMode":"","UsernsMode":"","ShmSize":67108864,"Runtime":"runc","Isolation":"","CpuShares":0,"Memory":0,"NanoCpus":0,"CgroupParent":"","BlkioWeight":0,"BlkioWeightDevice":[],"BlkioDeviceReadBps":[],"BlkioDeviceWriteBps":[],"BlkioDeviceReadIOps":[],"BlkioDeviceWriteIOps":[],"CpuPeriod":0,"CpuQuota":0,"CpuRealtimePeriod":0,"CpuRealtimeRuntime":0,"CpusetCpus":"","CpusetMems":"","Devices":[],"DeviceCgroupRules":null,"DeviceRequests":null,"MemoryReservation":0,"MemorySwap":0,"MemorySwappiness":null,"OomKillDisable":null,"PidsLimit":null,"Ulimits":null,"CpuCount":0,"CpuPercent":0,"IOMaximumIOps":0,"IOMaximumBandwidth":0,"MaskedPaths":["/proc/acpi","/proc/asound","/proc/interrupts","/proc/kcore","/proc/keys","/proc/latency_stats","/proc/sched_debug","/proc/scsi","/proc/timer_list","/proc/timer_stats","/sys/devices/virtual/powercap","/sys/firmware"],"ReadonlyPaths":["/proc/bus","/proc/fs","/proc/irq","/proc/sys","/proc/sysrq-trigger"]},"Storage":{"RootFS":{"Snapshot":{"Name":"overlayfs"}}},"Mounts":[],"Config":{"Hostname":"Tower","Domainname":"","User":"","AttachStdin":false,"AttachStdout":false,"AttachStderr":false,"Tty":false,"OpenStdin":false,"StdinOnce":false,"Env":["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"],"Cmd":["sleep","3600"],"Image":"alpine:3.20","Volumes":null,"WorkingDir":"/","Entrypoint":null,"Labels":{"net.unraid.docker.managed":"dockerman"}},"NetworkSettings":{"SandboxID":"7352ddb38c6519326c97324ee5da104c419573030e2111f1a3422e0f5b45eae8","SandboxKey":"/var/run/docker/netns/default","Ports":{},"Networks":{"host":{"IPAMConfig":null,"Links":null,"Aliases":null,"DriverOpts":null,"GwPriority":0,"NetworkID":"d76277a5b0783027956af1e58f401a4a9018b9e63f2c0bde7babe8c8bdc23378","EndpointID":"51578f75b98400841232ddda91450f8b4bd6fc805fea58ba6f0b864e27b3d39a","Gateway":"","IPAddress":"","MacAddress":"","IPPrefixLen":0,"IPv6Gateway":"","GlobalIPv6Address":"","GlobalIPv6PrefixLen":0,"DNSNames":null}}},"ImageManifestDescriptor":{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"sha256:704f8823e322c9ae8c92aa3a330e9df3a626ca80158f016ed3d12903a28d9e39","size":1026,"annotations":{"com.docker.official-images.bashbrew.arch":"amd64","org.opencontainers.image.base.name":"scratch","org.opencontainers.image.created":"2026-04-16T23:53:21Z","org.opencontainers.image.revision":"0db70ae354ee747109ce0b9a0cfbcd3c907bc822","org.opencontainers.image.source":"https://github.com/alpinelinux/docker-alpine.git#0db70ae354ee747109ce0b9a0cfbcd3c907bc822:x86_64","org.opencontainers.image.url":"https://hub.docker.com/_/alpine","org.opencontainers.image.version":"3.20.10"},"platform":{"architecture":"amd64","os":"linux"}}} + }, + "images": [ + {"Containers":4,"Created":1776383604,"Id":"sha256:1ff3b73d4cc7e7dcaff2ff9071a710eabe41b5da61ebd2dabc9febe5d974b615","Labels":{},"ParentId":"","Descriptor":{"mediaType":"application/vnd.oci.image.index.v1+json","digest":"sha256:1ff3b73d4cc7e7dcaff2ff9071a710eabe41b5da61ebd2dabc9febe5d974b615","size":9226},"RepoDigests":["alpine@sha256:1ff3b73d4cc7e7dcaff2ff9071a710eabe41b5da61ebd2dabc9febe5d974b615"],"RepoTags":["alpine:3.20"],"SharedSize":-1,"Size":13660215} + ], + "image_inspect": { + "sha256:1ff3b73d4cc7e7dcaff2ff9071a710eabe41b5da61ebd2dabc9febe5d974b615": {"Id":"sha256:1ff3b73d4cc7e7dcaff2ff9071a710eabe41b5da61ebd2dabc9febe5d974b615","RepoTags":["alpine:3.20"],"RepoDigests":["alpine@sha256:1ff3b73d4cc7e7dcaff2ff9071a710eabe41b5da61ebd2dabc9febe5d974b615"],"Comment":"buildkit.dockerfile.v0","Created":"2026-04-16T23:53:24.896953537Z","Config":{"Env":["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"],"Cmd":["/bin/sh"],"WorkingDir":"/"},"Architecture":"amd64","Os":"linux","Size":4103199,"RootFS":{"Type":"layers","Layers":["sha256:17fde15de9bf75f013a6219775fcb946f09ebb3c5f19ef7305ad8599b1cee239"]},"Metadata":{"LastTagTime":"2026-10-30T23:32:14.282085809Z"},"Descriptor":{"mediaType":"application/vnd.oci.image.index.v1+json","digest":"sha256:1ff3b73d4cc7e7dcaff2ff9071a710eabe41b5da61ebd2dabc9febe5d974b615","size":9226},"Identity":{"Pull":[{"Repository":"docker.io/library/alpine"}]}} + }, + "networks": [ + {"Name":"host","Driver":"host"}, + {"Name":"none","Driver":"null"}, + {"Name":"bridge","Driver":"bridge"} + ] +} diff --git a/.github/unraid-compat/fixtures/vms.json b/.github/unraid-compat/fixtures/vms.json new file mode 100644 index 00000000..f6be4c74 --- /dev/null +++ b/.github/unraid-compat/fixtures/vms.json @@ -0,0 +1,28 @@ +{ + "domains": [ + { + "name": "Debian 12", + "uuid": "803bd917-84b0-490f-ba3c-5e21b4cd6f07", + "state": 1, + "id": 1, + "autostart": true, + "xml": "\n Debian 12\n 803bd917-84b0-490f-ba3c-5e21b4cd6f07\n Debian 12 lab server\n \n \n \n 2097152\n 2097152\n \n \n \n 2\n \n hvm\n \n \n \n \n \n \n \n /usr/local/sbin/qemu\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n" + }, + { + "name": "Windows 11", + "uuid": "9fd1c657-7f2b-41b4-9ff3-5b42706315d5", + "state": 5, + "id": -1, + "autostart": false, + "xml": "\n Windows 11\n 9fd1c657-7f2b-41b4-9ff3-5b42706315d5\n \n \n \n \n 8388608\n 8388608\n \n \n \n 4\n \n hvm\n \n \n \n \n \n \n /usr/local/sbin/qemu\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n" + }, + { + "name": "Home Assistant", + "uuid": "39ec878e-ce44-4414-8dd1-b8fb3e57f9b2", + "state": 3, + "id": 2, + "autostart": true, + "xml": "\n Home Assistant\n 39ec878e-ce44-4414-8dd1-b8fb3e57f9b2\n \n \n \n \n 4194304\n 4194304\n \n \n \n 3\n \n hvm\n \n \n \n \n \n \n \n /usr/local/sbin/qemu\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n" + } + ] +} diff --git a/.github/unraid-compat/install_test.sh b/.github/unraid-compat/install_test.sh index 2612bb54..64281244 100755 --- a/.github/unraid-compat/install_test.sh +++ b/.github/unraid-compat/install_test.sh @@ -2,26 +2,17 @@ # FolderView3 through a real Unraid webGUI's plugin installer: install, upgrade over the last stable, remove, failures, min. # Disposable container only, as root, with no network. Usage: install_test.sh set -u -# This replaces /usr/bin/php, package tools and plugin files, so it runs only in a fresh Docker container, never on a host. -if [ ! -f /.dockerenv ] || [ -e /etc/unraid-version ] || [ -d /boot/config ]; then echo 'Refusing to run outside a fresh Docker container' >&2; exit 2; fi version=$2; repo=$(pwd) -fail() { echo "FAILED [Unraid $version]: $*"; exit 1; } -web=$(cd "$1" 2>/dev/null && pwd) && [ -f "$web/emhttp/plugins/dynamix.plugin.manager/scripts/plugin" ] || fail "no Unraid plugin installer under $1" +. "$repo/.github/unraid-compat/lib.sh" stable=$(cd "$3" 2>/dev/null && pwd) && [ -f "$stable/pkg_build.sh" ] || fail "no last-stable checkout with pkg_build.sh at $3" awk --version 2>/dev/null | grep -q 'GNU Awk' || fail 'awk is not gawk, as it is on Unraid: the remove script needs RT' +fv3_docroot "$1" || fail "no Unraid plugin installer under $1" -name=folder.view3 -docroot=/usr/local/emhttp -flash=/boot/config/plugins/$name live=$docroot/plugins/$name manifest=/boot/config/plugins/$name.plg -mkdir -p "$docroot/plugins" /boot/config/plugins-error /var/log/plugins /var/log/packages /var/local/emhttp -cp -R "$web/emhttp/plugins/dynamix" "$web/emhttp/plugins/dynamix.plugin.manager" "$docroot/plugins/" -ln -sfn "$docroot/plugins/dynamix" "$docroot/webGui" -printf 'csrf_token="compat-test-token"\n' > /var/local/emhttp/var.ini -# Unraid's pre- and post-install hooks run as #!/usr/bin/php and keep their state under /tmp/plugins +mkdir -p /boot/config/plugins-error /var/log/plugins /var/log/packages +# Unraid's pre- and post-install hooks keep their state under /tmp/plugins mkdir -p /tmp/plugins -ln -sf "$(command -v php)" /usr/bin/php plugin() { php "$docroot/plugins/dynamix.plugin.manager/scripts/plugin" "$@"; } # Slackware's package tools, as they work: the record lists the package's files, and removepkg takes those and the folders @@ -42,11 +33,7 @@ rm -f "$record" STUB chmod +x /sbin/upgradepkg /sbin/removepkg -work=$(mktemp -d) -build() { # build : the .plg and package as the release workflow makes them - local dir="$work/$2"; mkdir -p "$dir"; cp -R "$1/src" "$1/$name.plg" "$1/pkg_build.sh" "$dir/" - (cd "$dir" && bash pkg_build.sh --version "$2" --branch "$3" --out "$dir/dist" >/dev/null) || fail "package build of $2" -} +build() { fv3_build "$@" || fail "package build of $2"; } old=2026.01.01; new=2099.01.01 build "$stable" $old main; build "$repo" $new beta min=$(grep -o ']*min="[^"]*"' "$work/$new/$name.plg" | sed 's/.*min="//; s/"$//') diff --git a/.github/unraid-compat/lib.sh b/.github/unraid-compat/lib.sh new file mode 100644 index 00000000..ad48d599 --- /dev/null +++ b/.github/unraid-compat/lib.sh @@ -0,0 +1,24 @@ +#!/bin/bash +# Shared by install_test.sh and fake_unraid.sh: source it from the repo root with $version set. These replace system files and +# a download must fail, so they run only in a fresh Docker container with no network (loopback alone), never on a host. +if [ ! -f /.dockerenv ] || [ -e /etc/unraid-version ] || [ -d /boot/config ] || [ "$(ls /sys/class/net 2>/dev/null)" != lo ]; then + echo 'Refusing to run outside a fresh Docker container with no network' >&2; exit 2 +fi +name=folder.view3 +docroot=/usr/local/emhttp +flash=/boot/config/plugins/$name +work=$(mktemp -d) +fail() { echo "FAILED [Unraid $version]: $*"; exit 1; } + +fv3_docroot() { # fv3_docroot : Unraid's /usr/local/emhttp from that webGUI checkout, its symlinks included + [ -f "$1/emhttp/plugins/dynamix.plugin.manager/scripts/plugin" ] || return 1 + mkdir -p $docroot /var/local/emhttp /boot/config/plugins && cp -a "$1/emhttp/." $docroot/ || return 1 + printf 'csrf_token="compat-test-token"\n' > /var/local/emhttp/var.ini || return 1 + # Unraid's hooks and scripts run as #!/usr/bin/php + ln -sf "$(command -v php)" /usr/bin/php +} + +fv3_build() { # fv3_build : the .plg and package as the release workflow makes them, in $work/ + local dir="$work/$2"; mkdir -p "$dir"; cp -R "$1/src" "$1/$name.plg" "$1/pkg_build.sh" "$dir/" + (cd "$dir" && bash pkg_build.sh --version "$2" --branch "$3" --out "$dir/dist" >/dev/null) +} diff --git a/.github/unraid-compat/pages_test.php b/.github/unraid-compat/pages_test.php new file mode 100644 index 00000000..d350dc1a --- /dev/null +++ b/.github/unraid-compat/pages_test.php @@ -0,0 +1,266 @@ + true, CURLOPT_TIMEOUT => 60, CURLOPT_CUSTOMREQUEST => $method, + CURLOPT_HEADERFUNCTION => function ($ch, $line) use (&$headers) { + if (str_contains($line, ':')) { [$k, $v] = explode(':', $line, 2); $headers[strtolower(trim($k))] = trim($v); } + return strlen($line); + }]); + if ($method === 'POST') curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($fields + ($token === null ? [] : ['csrf_token' => $token]))); + $body = curl_exec($ch); + $status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE); + curl_close($ch); + return [$status, (string)$body, $headers]; +} + +// What one .page file put on the page: Unraid opens each file's part, in the head and again in the body, with a comment naming +// it; a part ends at the next one, at or at the footer +function fv3t_page_part(string $html, string $file): string { + preg_match_all('//', $html, $marks, PREG_OFFSET_CAPTURE); + preg_match_all('#|id="footer"#', $html, $ends, PREG_OFFSET_CAPTURE); + $bounds = array_merge(array_column($marks[0], 1), array_column($ends[0], 1), [strlen($html)]); + sort($bounds); + $part = ''; + foreach ($marks[0] as $i => [$mark, $at]) { + if ($marks[1][$i][0] !== $file) continue; + $from = $at + strlen($mark); + $to = current(array_filter($bounds, fn($b) => $b >= $from)); + $part .= substr($html, $from, $to - $from); + } + return $part; +} + +function get_json(string $path, ?int &$status = null) { + [$status, $body] = req('GET', "/plugins/folder.view3/server/$path"); + return json_decode($body, true); +} + +$flash = '/boot/config/plugins/folder.view3'; +$media = 'MediaAbCdEfGhIjKlMnO'; +$tools = 'ToolsPqRsTuVwXyZaBcD'; +$lab = 'LabFoldAbCdEfGhIjKlM'; +$containers = ['app-a', 'app-b', 'app-d', 'tool-c']; +$vms = ['Debian 12', 'Home Assistant', 'Windows 11']; +$fixture = json_decode(file_get_contents(__DIR__ . '/fixtures/docker.json'), true); +$shortId = fn(string $name) => substr($fixture['inspect'][$name]['Id'], 0, 12); +$sorted = function (array $a): array { sort($a); return $a; }; +// The saved setup fake_unraid.sh writes, as FV3 stores a folder +$folder = fn(string $name, array $members, string $regex = '') => ['name' => $name, 'icon' => '', 'regex' => $regex, 'containers' => $members, 'settings' => ['preview' => 1], 'actions' => []]; +$mediaFolder = $folder('Media', ['app-a']); +$toolsFolder = $folder('Tools', [], '^tool-'); +$labFolder = $folder('Lab', ['Debian 12']); +// read.php adds the fields every reader dereferences (fv3_normalize_folders), without writing them +$read = fn(array $f) => $f + ['hidden_preview' => []]; + +// FV3's saved folders and settings and Unraid's orders, as fake_unraid.sh wrote them: FV3's reads, its pages and each write below +// leave them exactly so, bar what the write is meant to change; $leaves checks all six after the reads, the pages and each write +$dockerPrefs = '/boot/config/plugins/dockerMan/userprefs.cfg'; +$vmPrefs = '/boot/config/plugins/dynamix.vm.manager/userprefs.cfg'; +$autostartFile = '/var/lib/docker/unraid-autostart'; +$saved = fn(string $type) => is_file("$flash/$type.json") ? json_decode(file_get_contents("$flash/$type.json"), true) ?? 'not JSON' : 'absent'; +$state = fn() => ['docker' => $saved('docker'), 'vm' => $saved('vm'), 'settings' => $saved('settings'), 'Docker order' => (string)@file_get_contents($dockerPrefs), + 'VM order' => (string)@file_get_contents($vmPrefs), 'autostart' => (string)@file_get_contents($autostartFile)]; +$seeded = ['docker' => [$media => $mediaFolder, $tools => $toolsFolder], 'vm' => [$lab => $labFolder], 'settings' => 'absent', + 'Docker order' => "0=\"folder-$media\"\n1=\"app-a\"\n2=\"app-b\"\n3=\"folder-$tools\"\n4=\"tool-c\"\n5=\"app-d\"\n", + 'VM order' => "0=\"folder-$lab\"\n1=\"Debian 12\"\n2=\"Home Assistant\"\n3=\"Windows 11\"\n", 'autostart' => "app-a\napp-d 10\n"]; +$leaves = function (string $step, array $changed = []) use ($seeded, $state): void { + static $want = null; + $want = array_replace($want ?? $seeded, $changed); + foreach ($state() as $what => $now) check($now === $want[$what], "$step left $what as " . json_encode($now)); +}; + +// Unraid's own lists, which FV3's pages fold into folders +[$status, $body] = req('GET', '/plugins/dynamix.docker.manager/include/DockerContainers.php'); +check($status === 200 && substr_count($body, "") === 4, "Docker list: status $status, " . substr_count($body, "") . ' container rows, not 4'); +foreach ($containers as $ct) check(str_contains($body, $ct), "Docker list has no row for $ct"); +[$status, $body] = req('GET', '/plugins/dynamix.vm.manager/include/VMMachines.php'); +check($status === 200 && preg_match_all("//", $body) === 3, "VM list: status $status, not 3 VM rows"); +foreach ($vms as $vm) check(str_contains($body, $vm), "VM list has no row for $vm"); +[$status, $body] = req('POST', '/webGui/include/DashboardApps.php', ['docker' => 1, 'vms' => 1, 'vmusage' => 'N']); +foreach (array_merge($containers, $vms) as $name) check($status === 200 && str_contains($body, $name), "Dashboard tiles: status $status, no tile for $name"); + +// FV3's reads; the Docker and VM ones answer from what Unraid's own code got from the fakes +$info = get_json('read_info.php?type=docker', $status); +check($status === 200 && is_array($info) && $sorted(array_keys($info)) === $containers, "read_info docker: status $status, containers " . json_encode(is_array($info) ? array_keys($info) : $info)); +if (is_array($info) && $sorted(array_keys($info)) === $containers) { + $seen = array_map(fn($c) => [$c['info']['State']['Autostart'], $c['info']['State']['Running'], $c['info']['State']['WebUi'], $c['info']['template']['path'] ?? null, $c['shortId']], $info); + ksort($seen); + // [IP] is ipaddr() on 7.0 (network.ini's address); from 7.1 DockerUtil::host() needs a LAN port, which a container with no network lacks + $webui = version_compare($version, '7.1', '<') ? 'http://192.0.2.10:18080/' : 'http://:18080/'; + check($seen === [ + 'app-a' => [true, true, $webui, '/boot/config/plugins/dockerMan/templates-user/my-app-a.xml', $shortId('app-a')], + 'app-b' => [false, true, '', null, $shortId('app-b')], + 'app-d' => [true, true, '', null, $shortId('app-d')], + 'tool-c' => [false, false, '', null, $shortId('tool-c')], + ], 'read_info docker: autostart, running, WebUI, template or short id wrong: ' . json_encode($seen)); +} +$info = get_json('read_info.php?type=vm', $status); +check($status === 200 && is_array($info) && $sorted(array_keys($info)) === $vms, "read_info vm: status $status, VMs " . json_encode(is_array($info) ? array_keys($info) : $info)); +if (is_array($info) && $sorted(array_keys($info)) === $vms) { + $seen = array_map(fn($v) => [$v['state'], $v['autostart'], $v['icon'], $v['vnc_port']], $info); + check($seen === [ + 'Debian 12' => ['running', 1, '/plugins/dynamix.vm.manager/templates/images/debian.png', '5700'], + 'Windows 11' => ['shutoff', false, '/plugins/dynamix.vm.manager/templates/images/windows11.png', ''], + 'Home Assistant' => ['paused', 1, '/plugins/dynamix.vm.manager/templates/images/linux.png', '5701'], + ], 'read_info vm: state, autostart, icon or VNC port wrong: ' . json_encode($seen)); + check($info['Debian 12']['description'] === 'Debian 12 lab server', 'read_info vm: description lost'); +} +check(get_json('read_unraid_order.php?type=docker', $status) === ['app-a', 'app-b', 'tool-c', 'app-d'] && $status === 200, 'read_unraid_order docker: not the saved order'); +check(get_json('read_unraid_order.php?type=vm', $status) === ['Debian 12', 'Home Assistant', 'Windows 11'] && $status === 200, 'read_unraid_order vm: not the saved order'); +$membership = get_json('read_membership.php?type=docker', $status); +check($status === 200 && ($membership['membership'] ?? null) === ['app-a' => 'Media', 'app-b' => 'Media', 'tool-c' => 'Tools'], + "read_membership: status $status, " . json_encode($membership)); +[$status, $body] = req('GET', '/plugins/folder.view3/server/docker_load.php'); +$load = explode("\n", trim($body)); +sort($load); +$want = array_map(fn($n) => $shortId($n) . ';0.50%;12.5MiB / 7.7GiB', ['app-a', 'app-b', 'app-d']); +sort($want); +check($status === 200 && $load === $want, "docker_load: status $status, " . json_encode($load)); +$image = array_key_first($fixture['image_inspect']); +$env = get_json('read_image_env.php?image=' . urlencode($image), $status); +check($status === 200 && $env === ['env' => ['PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin']], "read_image_env: status $status, " . json_encode($env)); +$folders = get_json('read.php?type=docker', $status); +check($status === 200 && $folders === [$media => $read($mediaFolder), $tools => $read($toolsFolder)], 'read docker: ' . json_encode($folders)); +$folders = get_json('read.php?type=vm', $status); +check($status === 200 && $folders === [$lab => $read($labFolder)], 'read vm: ' . json_encode($folders)); +$autostart = get_json('read_autostart.php', $status); +check($status === 200 && ($autostart['autostart'] ?? null) === [['name' => 'app-a', 'wait' => 0], ['name' => 'app-d', 'wait' => 10]], 'read_autostart: ' . json_encode($autostart)); +// Unraid's saved orders, and no FV3 settings, themes, styles or organizer folders yet; re-encoded, so {} and [] stay apart +$exact = [ + 'read_order.php?type=docker' => json_encode(["folder-$media", 'app-a', 'app-b', "folder-$tools", 'tool-c', 'app-d']), + 'read_order.php?type=vm' => json_encode(["folder-$lab", 'Debian 12', 'Home Assistant', 'Windows 11']), + 'read_settings.php' => '{}', 'list_themes.php' => '[]', 'read_css_config.php' => '{}', 'read_organizer_registry.php' => '{"folders":[]}', +]; +foreach ($exact as $path => $want) { + [$status, $body] = req('GET', "/plugins/folder.view3/server/$path"); + check($status === 200 && json_encode(json_decode($body)) === $want, "$path: status $status, " . substr($body, 0, 200)); +} +// All 49 of the CSS tool's defaults, two of them by value +$defaults = get_json('read_css_defaults.php', $status); +check($status === 200 && is_array($defaults) && count($defaults) === 49 && ($defaults['folder-view3-graph-cpu'] ?? null) === '#2b8da3' + && ($defaults['fv3-folder-name-min-width'] ?? null) === '220px', "read_css_defaults: status $status, " . substr(json_encode($defaults), 0, 200)); +// The backup: the seeded folders and nothing else of FV3's yet, stamped with this Unraid, this FV3 and the time +$export = get_json('export_all.php', $status); +$stamp = strtotime((string)($export['exported'] ?? '')); +unset($export['exported']); +check($status === 200 && $export === ['fv3_export_version' => 1, 'plugin_version' => '2099.01.01', 'unraid_version' => $version, + 'docker' => [$media => $mediaFolder, $tools => $toolsFolder], 'vm' => [$lab => $labFolder], 'settings' => [], 'autostart' => [], + 'css_config' => [], 'custom_styles' => [], 'order_docker' => [], 'order_vm' => []], "export_all: status $status, " . json_encode($export)); +check($stamp !== false && abs($stamp - time()) < 300, 'export_all: not stamped with the time'); +// FV3's debug panel shows the error log's last 200 lines; what those lines may hold is checked with the logs below +$raw = trim((string)@file_get_contents("$flash/error.log")); +$log = get_json('read_error_log.php', $status); +check($status === 200 && $log === ['log' => implode("\n", array_slice($raw === '' ? [] : explode("\n", $raw), -200))], "read_error_log: status $status, not the log's tail"); +[$status, $body] = req('GET', '/plugins/folder.view3/server/version.php'); +check($status === 200 && $body === '2099.01.01', "version: status $status, $body"); +// Logical CPUs, as this container's /proc/cpuinfo lists them +$cpus = count(preg_grep('/^processor\s*:/', file('/proc/cpuinfo'))); +[$status, $body] = req('GET', '/plugins/folder.view3/server/cpu.php'); +check($status === 200 && trim($body) === (string)$cpus, "cpu: status $status, $body, not $cpus"); +$leaves("FV3's reads"); + +// FV3's pages in every theme: rendered whole, Unraid's lists that FV3's scripts fold present, FV3's own part present, and every +// file that part links served by this Unraid +$pages = [ + 'Docker' => ['folder.view3.Docker.page', ['/plugins/folder.view3/scripts/docker.js', '/plugins/folder.view3/styles/docker.css'], ['docker_list', 'loadlist()']], + 'VMs' => ['folder.view3.VMs.page', ['/plugins/folder.view3/scripts/vm.js', '/plugins/folder.view3/styles/vm.css'], ['kvm_table', 'kvm_list', 'loadlist()']], + 'Dashboard' => ['folder.view3.Dashboard.page', ['/plugins/folder.view3/scripts/dashboard.js', '/plugins/folder.view3/styles/dashboard.css'], ['docker_view', 'vm_view', 'loadlist()']], + 'Settings/FolderView3' => ['FolderView3.page', ['/plugins/folder.view3/scripts/folderview3.js', '/plugins/folder.view3/styles/folderview3.css'], []], + "Folder?type=docker&id=$media" => ['Folder.page', ['/plugins/folder.view3/scripts/folder.js', '/plugins/folder.view3/styles/folder.css'], []], +]; +$served = []; +@mkdir('/boot/config/plugins/dynamix', 0777, true); +foreach (['black', 'white', 'azure', 'gray'] as $theme) { + file_put_contents('/boot/config/plugins/dynamix/dynamix.cfg', "[display]\ntheme=\"$theme\"\n"); + foreach ($pages as $page => [$file, $needs, $unraid]) { + [$status, $html] = req('GET', "/$page"); + $where = "$page ($theme)"; + check($status === 200 && str_contains($html, ''), "$where: status $status, page cut short"); + // An element id, or a function FV3's script wraps when written as name() + foreach ($unraid as $hook) { + $found = str_ends_with($hook, '()') ? preg_match('/function\s+' . substr($hook, 0, -2) . '\s*\(/', $html) : preg_match("/id=[\"']{$hook}[\"']/", $html); + check($found === 1, "$where: Unraid's page has no $hook for FV3's script"); + } + check(!preg_match('#Error evaluating content in plugins\\\\?/folder\.view3#', $html), "$where: Unraid caught an error in FV3's page"); + $part = fv3t_page_part($html, "plugins/folder.view3/$file"); + if ($part === '') { + check(false, "$where: no part from $file"); + continue; + } + check(!str_contains($part, '{"error":"Internal error"}'), "$where: FV3's error answer inside the page"); + check(preg_match("#/webGui/styles/(?:themes/|default-)$theme\.css#", $html) === 1, "$where: Unraid's $theme stylesheet missing, so the theme was not applied"); + preg_match_all('#(?:src|href)="(/[^"?]+\.(?:js|css))(?:\?[^"]*)?"#', $part, $links); + foreach ($needs as $need) check(in_array($need, $links[1], true), "$where: does not load $need"); + foreach (array_unique($links[1]) as $link) { + $served[$link] ??= req('GET', $link)[0]; + check($served[$link] === 200, "$where: links $link, which this Unraid answers {$served[$link]}"); + } + } +} +@unlink('/boot/config/plugins/dynamix/dynamix.cfg'); +$leaves("FV3's pages"); + +// Writes go through Unraid's CSRF check: a create without the right token saves nothing and FV3 never answers +$create = ['type' => 'docker', 'content' => json_encode($folder('New', ['app-d']))]; +foreach (['missing' => null, 'wrong' => 'not-the-token'] as $case => $token) { + [$status, $body, $headers] = req('POST', '/plugins/folder.view3/server/create.php', $create, $token); + check(!isset($headers['x-fv3-answer']), "create with the token $case: answered by FV3 (status $status)"); + $leaves("create with the token $case"); +} +[$status, $body, $headers] = req('POST', '/plugins/folder.view3/server/create.php', $create); +$new = (string)(json_decode($body, true)['id'] ?? ''); +check($status === 200 && isset($headers['x-fv3-answer']) && $new !== '', "create: status $status, $body"); +$leaves('create', ['docker' => [$media => $mediaFolder, $tools => $toolsFolder, $new => $folder('New', ['app-d'])]]); +[$status] = req('POST', '/plugins/folder.view3/server/update.php', ['type' => 'docker', 'id' => $media, 'content' => json_encode($folder('Media 2', ['app-a']))]); +check($status === 200, "update: status $status"); +$leaves('update', ['docker' => [$media => $folder('Media 2', ['app-a']), $tools => $toolsFolder, $new => $folder('New', ['app-d'])]]); +[$status] = req('POST', '/plugins/folder.view3/server/update.php', ['type' => 'vm', 'id' => $lab, 'content' => json_encode($folder('Lab 2', ['Debian 12']))]); +check($status === 200, "update vm: status $status"); +$leaves('update vm', ['vm' => [$lab => $folder('Lab 2', ['Debian 12'])]]); +[$status] = req('POST', '/plugins/folder.view3/server/delete.php', ['type' => 'docker', 'id' => $new]); +check($status === 200, "delete: status $status"); +$leaves('delete', ['docker' => [$media => $folder('Media 2', ['app-a']), $tools => $toolsFolder]]); +[$status] = req('POST', '/plugins/folder.view3/server/update_settings.php', ['key' => 'dashboard_docker_layout', 'value' => 'classic']); +check($status === 200, "update_settings: status $status"); +$leaves('update_settings', ['settings' => ['dashboard_docker_layout' => 'classic']]); +// Autostart out of the saved order: the sync puts it back in folder order with app-d's wait kept, and changes nothing else +file_put_contents($autostartFile, "app-d 10\napp-a\n"); +[$status, $body] = req('POST', '/plugins/folder.view3/server/sync_order.php', ['type' => 'docker']); +check($status === 200 && json_decode($body) !== null, "sync_order: status $status, $body"); +$leaves('sync_order', ['autostart' => "app-a\napp-d 10\n"]); + +// What the runs left in the logs: FV3's files must log nothing, no stand-in was asked anything it does not answer, and no +// command the webGUI ran was missing where the shell's error reached php -S's log (one run with 2>/dev/null fails unseen) +// From 7.2 Unraid logs a .page's inline PHP as "in plugins/folder.view3/.page", with no leading slash +$phplog = file('/var/log/phplog', FILE_IGNORE_NEW_LINES); +$fv3Lines = preg_grep('#plugins/folder\.view3/#', $phplog); +check(!$fv3Lines, "PHP logged from FV3's files:\n " . implode("\n ", array_slice($fv3Lines, 0, 20))); +// No script died or failed an include: in Unraid's own code, a sign of state the fakes lack +$broken = preg_grep('/PHP Fatal error|Failed opening .* for inclusion/', $phplog); +check(!$broken, "PHP died or missed a file:\n " . implode("\n ", array_slice(array_unique($broken), 0, 20))); +// FV3's error log copies every warning raised in its requests, Unraid's too, by basename. With VM debug on, a real Unraid's +// libvirt.php adds one when it keys an array by a domain handle; any other line fails +$errorLog = is_file("$flash/error.log") ? file("$flash/error.log", FILE_IGNORE_NEW_LINES) : []; +$handleWarning = '/^\[[^]]+\] php-error: Resource ID#\d+ used as offset, casting to integer \(\d+\) at libvirt\.php:\d+$/'; +$reported = $errorLog === false ? ['error.log could not be read'] : preg_grep($handleWarning, $errorLog, PREG_GREP_INVERT); +check(!$reported, "FV3's error.log:\n " . implode("\n ", $reported)); +$unknown = preg_grep('/UNKNOWN/', file('/var/log/fv3-fakes.log', FILE_IGNORE_NEW_LINES)); +check(!$unknown, "the fakes were asked what they do not answer:\n " . implode("\n ", array_unique($unknown))); +$missing = preg_grep('/command not found/', file('/var/log/php-server.log', FILE_IGNORE_NEW_LINES)); +check(!$missing, "the webGUI ran commands this image lacks:\n " . implode("\n ", array_unique($missing))); + +if ($failures) { + echo "FAILED [Unraid $version]: " . count($failures) . " of $checks checks\n- " . implode("\n- ", $failures) . "\n"; + exit(1); +} +echo "Unraid $version: Unraid's lists, FV3's reads and writes, and its pages in 4 themes passed ($checks checks)\n"; diff --git a/.github/unraid-compat/pages_test.sh b/.github/unraid-compat/pages_test.sh new file mode 100644 index 00000000..3306f716 --- /dev/null +++ b/.github/unraid-compat/pages_test.sh @@ -0,0 +1,6 @@ +#!/bin/bash +# FV3's endpoints and pages through a real Unraid webGUI. Disposable container only, as root, with no network; run from the +# repo root. Usage: pages_test.sh +set -u +bash .github/unraid-compat/fake_unraid.sh "$1" "$2" || exit 1 +php -d auto_prepend_file= -d display_errors=stderr .github/unraid-compat/pages_test.php "$2" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1199e8eb..2c5905cb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -203,9 +203,7 @@ jobs: repository: unraid/webgui ref: ${{ matrix.unraid }} path: .webgui - sparse-checkout: | - emhttp/plugins/dynamix - emhttp/plugins/dynamix.plugin.manager + sparse-checkout: emhttp - name: Install, upgrade, remove and failures through Unraid's own plugin installer if: env.RUNS == 'true' @@ -216,6 +214,13 @@ jobs: docker build -q -t fv3-unraid --build-arg PHP="$PHP_VERSION" .github/unraid-compat docker run --rm --network none -v "$PWD:/repo" -w /repo fv3-unraid bash .github/unraid-compat/install_test.sh .webgui "$UNRAID_VERSION" .stable + # Runs after a failed install test too: the two report on different things + - name: FV3's endpoints and pages through this Unraid's webGUI, Docker and libvirt faked + if: ${{ (success() || failure()) && env.RUNS == 'true' }} + env: + UNRAID_VERSION: ${{ matrix.unraid }} + run: docker run --rm --network none -v "$PWD:/repo" -w /repo fv3-unraid bash .github/unraid-compat/pages_test.sh .webgui "$UNRAID_VERSION" + # One check per matrix for beta's branch protection: the version rows rename themselves as Renovate moves them php-compat: name: PHP compatibility