This commit is contained in:
2026-03-08 23:39:25 +01:00
parent 579290044f
commit f31cf972be
2 changed files with 12 additions and 4 deletions

View File

@@ -46,8 +46,12 @@ if (isset($_GET['update_json'])) {
$settings = modules()->settings('pi_control');
$strictHostKey = !empty($settings['terminal_strict_hostkey']);
$updateCmd = "sh -lc 'if ! command -v apt-get >/dev/null 2>&1; then echo \"__ERR__NO_APT\"; exit 2; fi; if sudo apt update -qq >/dev/null 2>&1; then count=$(apt-get -s dist-upgrade | grep -c \"^Inst \"); if [ \"$count\" -gt 0 ]; then echo \"__UPDATE__=1\"; else echo \"__UPDATE__=0\"; fi; echo \"__COUNT__=$count\"; else echo \"__ERR__APT_UPDATE\"; exit 3; fi'";
$upgradeCmd = "sh -lc 'id=\"$(. /etc/os-release 2>/dev/null && echo \"${ID:-}\")\"; current=\"$(. /etc/os-release 2>/dev/null && echo \"${VERSION_CODENAME:-}\")\"; if [ \"$id\" != \"debian\" ] || [ -z \"$current\" ]; then echo \"__ERR__NO_CODENAME\"; exit 2; fi; latest=\"$( (command -v curl >/dev/null 2>&1 && curl -fsSL https://deb.debian.org/debian/dists/stable/Release) || (command -v wget >/dev/null 2>&1 && wget -qO- https://deb.debian.org/debian/dists/stable/Release) )\"; latest=\"$(printf \"%s\" \"$latest\" | awk -F\": \" \"/^Codename:/{print $2}\")\"; if [ -z \"$latest\" ]; then echo \"__ERR__NO_LATEST\"; exit 3; fi; if [ \"$current\" != \"$latest\" ]; then echo \"__UPGRADE__=1\"; else echo \"__UPGRADE__=0\"; fi'";
$updateCmd = <<<'SH'
sh -lc 'if ! command -v apt-get >/dev/null 2>&1; then echo "__ERR__NO_APT"; exit 2; fi; if sudo apt update -qq >/dev/null 2>&1; then count=$(apt-get -s dist-upgrade | grep -c "^Inst "); if [ "$count" -gt 0 ]; then echo "__UPDATE__=1"; else echo "__UPDATE__=0"; fi; echo "__COUNT__=$count"; else echo "__ERR__APT_UPDATE"; exit 3; fi'
SH;
$upgradeCmd = <<<'SH'
sh -lc 'id="$(. /etc/os-release 2>/dev/null && echo "${ID:-}")"; current="$(. /etc/os-release 2>/dev/null && echo "${VERSION_CODENAME:-}")"; if [ "$id" != "debian" ] || [ -z "$current" ]; then echo "__ERR__NO_CODENAME"; exit 2; fi; latest="$( (command -v curl >/dev/null 2>&1 && curl -fsSL https://deb.debian.org/debian/dists/stable/Release) || (command -v wget >/dev/null 2>&1 && wget -qO- https://deb.debian.org/debian/dists/stable/Release) )"; latest="$(printf "%s" "$latest" | awk -F": " "/^Codename:/{print $2}")"; if [ -z "$latest" ]; then echo "__ERR__NO_LATEST"; exit 3; fi; if [ "$current" != "$latest" ]; then echo "__UPGRADE__=1"; else echo "__UPGRADE__=0"; fi'
SH;
[$updExit, $updOut, $updErr] = runSshCommandCapture($host, $updateCmd, $strictHostKey, 20);
$updOutStr = (string)$updOut;

View File

@@ -13,8 +13,12 @@ $table = fn(string $name) => module_fn($module, 'table', $name);
$settings = modules()->settings($module);
$strictHostKey = !empty($settings['terminal_strict_hostkey']);
$updateCmd = "sh -lc 'if ! command -v apt-get >/dev/null 2>&1; then echo \"__ERR__NO_APT\"; exit 2; fi; if sudo apt update -qq >/dev/null 2>&1; then count=$(apt-get -s dist-upgrade | grep -c \"^Inst \"); if [ \"$count\" -gt 0 ]; then echo \"__UPDATE__=1\"; else echo \"__UPDATE__=0\"; fi; echo \"__COUNT__=$count\"; else echo \"__ERR__APT_UPDATE\"; exit 3; fi'";
$upgradeCmd = "sh -lc 'id=\"$(. /etc/os-release 2>/dev/null && echo \"${ID:-}\")\"; current=\"$(. /etc/os-release 2>/dev/null && echo \"${VERSION_CODENAME:-}\")\"; if [ \"$id\" != \"debian\" ] || [ -z \"$current\" ]; then echo \"__ERR__NO_CODENAME\"; exit 2; fi; latest=\"$( (command -v curl >/dev/null 2>&1 && curl -fsSL https://deb.debian.org/debian/dists/stable/Release) || (command -v wget >/dev/null 2>&1 && wget -qO- https://deb.debian.org/debian/dists/stable/Release) )\"; latest=\"$(printf \"%s\" \"$latest\" | awk -F\": \" \"/^Codename:/{print $2}\")\"; if [ -z \"$latest\" ]; then echo \"__ERR__NO_LATEST\"; exit 3; fi; if [ \"$current\" != \"$latest\" ]; then echo \"__UPGRADE__=1\"; else echo \"__UPGRADE__=0\"; fi'";
$updateCmd = <<<'SH'
sh -lc 'if ! command -v apt-get >/dev/null 2>&1; then echo "__ERR__NO_APT"; exit 2; fi; if sudo apt update -qq >/dev/null 2>&1; then count=$(apt-get -s dist-upgrade | grep -c "^Inst "); if [ "$count" -gt 0 ]; then echo "__UPDATE__=1"; else echo "__UPDATE__=0"; fi; echo "__COUNT__=$count"; else echo "__ERR__APT_UPDATE"; exit 3; fi'
SH;
$upgradeCmd = <<<'SH'
sh -lc 'id="$(. /etc/os-release 2>/dev/null && echo "${ID:-}")"; current="$(. /etc/os-release 2>/dev/null && echo "${VERSION_CODENAME:-}")"; if [ "$id" != "debian" ] || [ -z "$current" ]; then echo "__ERR__NO_CODENAME"; exit 2; fi; latest="$( (command -v curl >/dev/null 2>&1 && curl -fsSL https://deb.debian.org/debian/dists/stable/Release) || (command -v wget >/dev/null 2>&1 && wget -qO- https://deb.debian.org/debian/dists/stable/Release) )"; latest="$(printf "%s" "$latest" | awk -F": " "/^Codename:/{print $2}")"; if [ -z "$latest" ]; then echo "__ERR__NO_LATEST"; exit 3; fi; if [ "$current" != "$latest" ]; then echo "__UPGRADE__=1"; else echo "__UPGRADE__=0"; fi'
SH;
$driver = (string)$pdo->getAttribute(PDO::ATTR_DRIVER_NAME);
$nowExpr = $driver === 'pgsql' ? 'NOW()' : "DATETIME('now')";