Add reproducible build system, native Unraid plugin, and WebUI
- versions.env pins podman, conmon, crun, netavark, aardvark-dns, passt, and fuse-overlayfs to verified upstream source checksums; SlackBuild recipes, scripts/build-packages.sh, checksums.sh, release.sh, and update-versions.sh implement the reproducible pipeline; GitHub Actions workflows build in a Slackware container and publish releases without committing any binaries. - plugin/podman.plg installs/updates/removes all eight packages (the seven components plus the plugin's own unraid-podman scaffolding package) via upgradepkg, using the official Unraid array-event hook mechanism (event/disks_mounted, event/stopping) instead of editing /boot/config/go. rc.podman and the sbin/ helper scripts implement storage creation, config seeding/sync, preflight checks, autostart with per-container Safe-Mode, and package verify/update/rollback. - webui/plugins/podman implements the Dashboard, Containers, Pods, Images, Volumes, Networks, Logs, Terminal, Compose, and Settings panels against the approved mockup (webui/mockups/prototype.html), talking to podman system service exclusively via PodmanClient.php (libpod REST API over the Unix socket), with two documented exceptions: Terminal's one-shot exec model and Compose's use of the podman compose CLI, since libpod has no REST equivalent for either. - docs/ARCHITECTURE.md and docs/ROADMAP.md record the design decisions and honest current status (syntax-checked, unit- and integration-tested against fake sockets/servers; not yet run against a real Unraid/Podman/Slackware system). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
/**
|
||||
* Config.php
|
||||
*
|
||||
* Reads unraid-podman's own settings so the WebUI and the shell-based
|
||||
* plugin scripts under plugin/sbin/ agree on where everything lives —
|
||||
* this file is the PHP-side counterpart of plugin/sbin/podman-common.sh's
|
||||
* podman_load_cfg() function, and intentionally mirrors its defaults and
|
||||
* paths exactly (see that script for the shell equivalent).
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
final class PodmanConfig
|
||||
{
|
||||
public string $storagePath;
|
||||
public int $storageImageSizeGb;
|
||||
public bool $enabled;
|
||||
public int $stopTimeoutSeconds;
|
||||
public string $socketPath;
|
||||
public string $bootDir;
|
||||
public string $autostartFile;
|
||||
public string $autostartDelayFile;
|
||||
|
||||
private function __construct()
|
||||
{
|
||||
// Defaults mirror podman-common.sh's podman_load_cfg() defaults.
|
||||
$this->bootDir = '/boot/config/plugins/podman';
|
||||
$this->storagePath = '/mnt/cache/system/podman';
|
||||
$this->storageImageSizeGb = 20;
|
||||
$this->enabled = true;
|
||||
$this->stopTimeoutSeconds = 10;
|
||||
$this->socketPath = '/var/run/podman/podman.sock';
|
||||
$this->autostartFile = $this->bootDir . '/autostart';
|
||||
$this->autostartDelayFile = $this->bootDir . '/autostart-delay';
|
||||
}
|
||||
|
||||
public static function load(): self
|
||||
{
|
||||
$cfg = new self();
|
||||
|
||||
$cfgFile = $cfg->bootDir . '/podman.cfg';
|
||||
if (is_readable($cfgFile)) {
|
||||
$values = self::parseShellStyleFile($cfgFile);
|
||||
if (isset($values['STORAGE_PATH'])) {
|
||||
$cfg->storagePath = $values['STORAGE_PATH'];
|
||||
}
|
||||
if (isset($values['STORAGE_IMAGE_SIZE_GB'])) {
|
||||
$cfg->storageImageSizeGb = (int) $values['STORAGE_IMAGE_SIZE_GB'];
|
||||
}
|
||||
if (isset($values['PODMAN_ENABLED'])) {
|
||||
$cfg->enabled = strtolower($values['PODMAN_ENABLED']) === 'yes';
|
||||
}
|
||||
if (isset($values['STOP_TIMEOUT'])) {
|
||||
$cfg->stopTimeoutSeconds = (int) $values['STOP_TIMEOUT'];
|
||||
}
|
||||
}
|
||||
|
||||
return $cfg;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the simple `KEY="value"` / `KEY=value` shell-sourceable format
|
||||
* used by podman.cfg (see config/podman.cfg.example) WITHOUT executing
|
||||
* it as shell — this file is read by an unprivileged PHP-FPM worker,
|
||||
* so treating it as data rather than sourcing it is a deliberate
|
||||
* safety boundary, not just a convenience.
|
||||
*
|
||||
* @return array<string,string>
|
||||
*/
|
||||
private static function parseShellStyleFile(string $path): array
|
||||
{
|
||||
$result = [];
|
||||
$lines = file($path, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
|
||||
if ($lines === false) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
foreach ($lines as $line) {
|
||||
$line = trim($line);
|
||||
if ($line === '' || str_starts_with($line, '#')) {
|
||||
continue;
|
||||
}
|
||||
if (!preg_match('/^([A-Z_][A-Z0-9_]*)=(.*)$/', $line, $m)) {
|
||||
continue;
|
||||
}
|
||||
[$_, $key, $value] = $m;
|
||||
$value = trim($value);
|
||||
// Strip one layer of matching quotes, if present.
|
||||
if (strlen($value) >= 2 && (
|
||||
($value[0] === '"' && str_ends_with($value, '"')) ||
|
||||
($value[0] === "'" && str_ends_with($value, "'"))
|
||||
)) {
|
||||
$value = substr($value, 1, -1);
|
||||
}
|
||||
$result[$key] = $value;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function newClient(): PodmanClient
|
||||
{
|
||||
return new PodmanClient($this->socketPath);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user