YX
This commit is contained in:
@@ -47,10 +47,19 @@ if (isset($_GET['update_json'])) {
|
|||||||
$strictHostKey = !empty($settings['terminal_strict_hostkey']);
|
$strictHostKey = !empty($settings['terminal_strict_hostkey']);
|
||||||
|
|
||||||
$updateCmd = <<<'SH'
|
$updateCmd = <<<'SH'
|
||||||
sh -lc 'if ! command -v apt-get >/dev/null 2>&1; then echo "__ERR__NO_APT"; exit 2; fi; if sudo -n apt update -qq >/dev/null 2>&1; then echo "__APT_UPDATE__=1"; else echo "__APT_UPDATE__=0"; fi; count=$(apt-get -s dist-upgrade 2>/dev/null | grep -c "^Inst "); echo "__COUNT__=$count"'
|
if ! command -v apt-get >/dev/null 2>&1; then echo "__ERR__NO_APT"; exit 2; fi;
|
||||||
|
if sudo -n apt update -qq >/dev/null 2>&1; then echo "__APT_UPDATE__=1"; else echo "__APT_UPDATE__=0"; fi;
|
||||||
|
count=$(apt-get -s dist-upgrade 2>/dev/null | grep -c "^Inst ");
|
||||||
|
echo "__COUNT__=$count"
|
||||||
SH;
|
SH;
|
||||||
$upgradeCmd = <<<'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 "__UPGRADE__=0"; exit 0; 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 "__UPGRADE__=0"; echo "__RAW__=NO_FETCH"; exit 0; fi; if [ "$current" != "$latest" ]; then echo "__UPGRADE__=1"; else echo "__UPGRADE__=0"; fi'
|
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 "__UPGRADE__=0"; exit 0; 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 "__UPGRADE__=0"; echo "__RAW__=NO_FETCH"; exit 0; fi;
|
||||||
|
if [ "$current" != "$latest" ]; then echo "__UPGRADE__=1"; else echo "__UPGRADE__=0"; fi
|
||||||
SH;
|
SH;
|
||||||
|
|
||||||
[$updExit, $updOut, $updErr] = runSshCommandCapture($host, $updateCmd, $strictHostKey, 20);
|
[$updExit, $updOut, $updErr] = runSshCommandCapture($host, $updateCmd, $strictHostKey, 20);
|
||||||
@@ -243,11 +252,11 @@ function runSshCommandCapture(array $host, string $command, bool $strictHostKey,
|
|||||||
$opts = $strictHostKey
|
$opts = $strictHostKey
|
||||||
? '-o StrictHostKeyChecking=accept-new -o UserKnownHostsFile=/root/.ssh/known_hosts'
|
? '-o StrictHostKeyChecking=accept-new -o UserKnownHostsFile=/root/.ssh/known_hosts'
|
||||||
: '-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null';
|
: '-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null';
|
||||||
$opts .= ' -o ConnectTimeout=6 -o NumberOfPasswordPrompts=1';
|
$opts .= ' -o ConnectTimeout=6 -o NumberOfPasswordPrompts=1 -o LogLevel=ERROR -o RequestTTY=no';
|
||||||
|
|
||||||
$target = escapeshellarg($user . '@' . $hostAddr);
|
$target = escapeshellarg($user . '@' . $hostAddr);
|
||||||
$remote = '/bin/bash -lc ' . escapeshellarg($command);
|
$remote = '/bin/sh -c ' . escapeshellarg($command);
|
||||||
$cmd = 'ssh ' . $opts . ' -p ' . (int)$port . ' ';
|
$cmd = 'ssh -T ' . $opts . ' -p ' . (int)$port . ' ';
|
||||||
if ($authType === 'key' && $keyPath !== '') {
|
if ($authType === 'key' && $keyPath !== '') {
|
||||||
$cmd .= '-i ' . escapeshellarg($keyPath) . ' -o BatchMode=yes ';
|
$cmd .= '-i ' . escapeshellarg($keyPath) . ' -o BatchMode=yes ';
|
||||||
} elseif ($authType === 'key') {
|
} elseif ($authType === 'key') {
|
||||||
|
|||||||
@@ -14,10 +14,19 @@ $settings = modules()->settings($module);
|
|||||||
$strictHostKey = !empty($settings['terminal_strict_hostkey']);
|
$strictHostKey = !empty($settings['terminal_strict_hostkey']);
|
||||||
|
|
||||||
$updateCmd = <<<'SH'
|
$updateCmd = <<<'SH'
|
||||||
sh -lc 'if ! command -v apt-get >/dev/null 2>&1; then echo "__ERR__NO_APT"; exit 2; fi; if sudo -n apt update -qq >/dev/null 2>&1; then echo "__APT_UPDATE__=1"; else echo "__APT_UPDATE__=0"; fi; count=$(apt-get -s dist-upgrade 2>/dev/null | grep -c "^Inst "); echo "__COUNT__=$count"'
|
if ! command -v apt-get >/dev/null 2>&1; then echo "__ERR__NO_APT"; exit 2; fi;
|
||||||
|
if sudo -n apt update -qq >/dev/null 2>&1; then echo "__APT_UPDATE__=1"; else echo "__APT_UPDATE__=0"; fi;
|
||||||
|
count=$(apt-get -s dist-upgrade 2>/dev/null | grep -c "^Inst ");
|
||||||
|
echo "__COUNT__=$count"
|
||||||
SH;
|
SH;
|
||||||
$upgradeCmd = <<<'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 "__UPGRADE__=0"; exit 0; 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 "__UPGRADE__=0"; echo "__RAW__=NO_FETCH"; exit 0; fi; if [ "$current" != "$latest" ]; then echo "__UPGRADE__=1"; else echo "__UPGRADE__=0"; fi'
|
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 "__UPGRADE__=0"; exit 0; 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 "__UPGRADE__=0"; echo "__RAW__=NO_FETCH"; exit 0; fi;
|
||||||
|
if [ "$current" != "$latest" ]; then echo "__UPGRADE__=1"; else echo "__UPGRADE__=0"; fi
|
||||||
SH;
|
SH;
|
||||||
|
|
||||||
$driver = (string)$pdo->getAttribute(PDO::ATTR_DRIVER_NAME);
|
$driver = (string)$pdo->getAttribute(PDO::ATTR_DRIVER_NAME);
|
||||||
@@ -94,11 +103,11 @@ function runSshCommandCapture(array $host, string $command, bool $strictHostKey,
|
|||||||
$opts = $strictHostKey
|
$opts = $strictHostKey
|
||||||
? '-o StrictHostKeyChecking=accept-new -o UserKnownHostsFile=/root/.ssh/known_hosts'
|
? '-o StrictHostKeyChecking=accept-new -o UserKnownHostsFile=/root/.ssh/known_hosts'
|
||||||
: '-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null';
|
: '-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null';
|
||||||
$opts .= ' -o ConnectTimeout=6 -o NumberOfPasswordPrompts=1';
|
$opts .= ' -o ConnectTimeout=6 -o NumberOfPasswordPrompts=1 -o LogLevel=ERROR -o RequestTTY=no';
|
||||||
|
|
||||||
$target = escapeshellarg($user . '@' . $hostAddr);
|
$target = escapeshellarg($user . '@' . $hostAddr);
|
||||||
$remote = '/bin/bash -lc ' . escapeshellarg($command);
|
$remote = '/bin/sh -c ' . escapeshellarg($command);
|
||||||
$cmd = 'ssh ' . $opts . ' -p ' . (int)$port . ' ';
|
$cmd = 'ssh -T ' . $opts . ' -p ' . (int)$port . ' ';
|
||||||
if ($authType === 'key' && $keyPath !== '') {
|
if ($authType === 'key' && $keyPath !== '') {
|
||||||
$cmd .= '-i ' . escapeshellarg($keyPath) . ' -o BatchMode=yes ';
|
$cmd .= '-i ' . escapeshellarg($keyPath) . ' -o BatchMode=yes ';
|
||||||
} elseif ($authType === 'key') {
|
} elseif ($authType === 'key') {
|
||||||
|
|||||||
Reference in New Issue
Block a user