From ee3e6430edd0dbacefefc04c496ce6c176f91ad7 Mon Sep 17 00:00:00 2001 From: vapao Date: Thu, 30 Sep 2021 18:11:36 +0800 Subject: [PATCH] improve compatibility --- spug_api/apps/host/utils.py | 2 ++ spug_api/libs/ssh.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/spug_api/apps/host/utils.py b/spug_api/apps/host/utils.py index 68aa087..ad08440 100644 --- a/spug_api/apps/host/utils.py +++ b/spug_api/apps/host/utils.py @@ -194,6 +194,8 @@ def fetch_host_extend(ssh): response['cpu'] = int(out.strip()) code, out = ssh.exec_command_raw("cat /etc/os-release | grep PRETTY_NAME | awk -F \\\" '{print $2}'") + if '/etc/os-release' in out: + code, out = ssh.exec_command_raw("cat /etc/issue | head -1 | awk '{print $1,$2,$3}'") if code == 0: response['os_name'] = out.strip() diff --git a/spug_api/libs/ssh.py b/spug_api/libs/ssh.py index 97fca37..13a8920 100644 --- a/spug_api/libs/ssh.py +++ b/spug_api/libs/ssh.py @@ -188,7 +188,7 @@ class SSH: b64_command = base64.standard_b64encode(new_command.encode()) commands = 'export SPUG_EXEC_FILE=$(mktemp)\n' - commands += f'echo {b64_command.decode()} | base64 -d > $SPUG_EXEC_FILE\n' + commands += f'echo {b64_command.decode()} | base64 -di > $SPUG_EXEC_FILE\n' commands += 'bash $SPUG_EXEC_FILE\n' return commands