From f31cf972bedf8d673e3f96f4edcc76f5da345b00 Mon Sep 17 00:00:00 2001 From: Lars Gebhardt-Kusche Date: Sun, 8 Mar 2026 23:39:25 +0100 Subject: [PATCH] SSADS --- modules/pi_control/pages/hosts.php | 8 ++++++-- tools/pi_control/check_updates.php | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/modules/pi_control/pages/hosts.php b/modules/pi_control/pages/hosts.php index cc3b682..5251de2 100644 --- a/modules/pi_control/pages/hosts.php +++ b/modules/pi_control/pages/hosts.php @@ -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; diff --git a/tools/pi_control/check_updates.php b/tools/pi_control/check_updates.php index 7e209dd..6af68ed 100644 --- a/tools/pi_control/check_updates.php +++ b/tools/pi_control/check_updates.php @@ -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')";