diff --git a/apps/backend/components/collections/agent_new/push_files_to_proxy.py b/apps/backend/components/collections/agent_new/push_files_to_proxy.py index d36115dda..cf08b66b0 100644 --- a/apps/backend/components/collections/agent_new/push_files_to_proxy.py +++ b/apps/backend/components/collections/agent_new/push_files_to_proxy.py @@ -22,6 +22,15 @@ class PushFilesToProxyService(AgentTransferFileService): def get_file_list(self, data, common_data: AgentCommonData, host: models.Host) -> List[str]: file_list = data.get_one_of_inputs("file_list", default=[]) + exclude_map = { + # 后续加入新的架构需要加入到此map + constants.CpuType.x86_64: ("aarch64.tgz",), + constants.CpuType.aarch64: ("x86_64.tgz",), + } + # 获取当前架构对应的排除后缀 + exclude_suffix = exclude_map.get(host.cpu_arch, tuple()) + if exclude_suffix: + file_list = [item for item in file_list if not item.endswith(exclude_suffix)] from_type = data.get_one_of_inputs("from_type") host_ap: Optional[models.AccessPoint] = self.get_host_ap(common_data, host) if not host_ap: diff --git a/apps/node_man/constants.py b/apps/node_man/constants.py index 6d0d31868..bee4b0e2b 100644 --- a/apps/node_man/constants.py +++ b/apps/node_man/constants.py @@ -1107,7 +1107,7 @@ class PolicyRollBackType: ] TOOLS_TO_PUSH_TO_PROXY: List[Dict[str, Union[List[str], Any]]] = [ - {"files": ["py36.tgz"], "name": _("检测 BT 分发策略(下发Py36包)")}, + {"files": ["py36-x86_64.tgz", "py36-aarch64.tgz"], "name": _("检测 BT 分发策略(下发Py36包)")}, { "files": [ "ntrights.exe", @@ -1120,7 +1120,8 @@ class PolicyRollBackType: "handle.exe", "unixdate.exe", "tcping.exe", - "nginx-portable.tgz", + "nginx-portable-x86_64.tgz", + "nginx-portable-aarch64.tgz", ], "name": _("下发安装工具"), }, diff --git a/script_tools/agent_tools/agent2/setup_proxy.sh b/script_tools/agent_tools/agent2/setup_proxy.sh index af72b64d5..8ed7b13c8 100755 --- a/script_tools/agent_tools/agent2/setup_proxy.sh +++ b/script_tools/agent_tools/agent2/setup_proxy.sh @@ -2,6 +2,22 @@ # vim:ft=sh expandtab sts=4 ts=4 sw=4 nu # gse proxy 2.0 安装脚本, 仅在节点管理2.0中使用 +get_cpu_arch () { + local cmd=$1 + CPU_ARCH=$($cmd) + CPU_ARCH=$(echo ${CPU_ARCH} | tr 'A-Z' 'a-z') + if [[ "${CPU_ARCH}" =~ "x86_64" ]]; then + return 0 + elif [[ "${CPU_ARCH}" =~ "x86" || "${CPU_ARCH}" =~ ^i[3456]86 ]]; then + return 1 + elif [[ "${CPU_ARCH}" =~ "aarch" ]]; then + return 0 + else + return 1 + fi +} +get_cpu_arch "uname -p" || get_cpu_arch "uname -m" || fail get_cpu_arch "Failed to get CPU arch or unsupported CPU arch, please contact the developer." + NODE_TYPE=proxy PROC_LIST=(agent data file) GSE_AGENT_RUN_DIR=/var/run/gse @@ -592,6 +608,7 @@ download_pkg () { done log download_pkg DONE "gse_proxy package download succeeded" + log report_cpu_arch DONE "${CPU_ARCH}" } check_deploy_result () { @@ -877,7 +894,7 @@ DEBUG_LOG_FILE=${TMP_DIR}/nm.${0##*/}.${TASK_ID}.debug # 获取包名 PKG_NAME=${NAME}-${VERSION}.tgz -COMPLETE_DOWNLOAD_URL="${DOWNLOAD_URL}/agent/linux/x86_64/" +COMPLETE_DOWNLOAD_URL="${DOWNLOAD_URL}/agent/linux/${CPU_ARCH}/" GSE_AGENT_CONFIG_PATH="${AGENT_SETUP_PATH}/etc/${GSE_AGENT_CONFIG}" # redirect STDOUT & STDERR to DEBUG diff --git a/script_tools/nginx-portable-aarch64.tgz b/script_tools/nginx-portable-aarch64.tgz new file mode 100644 index 000000000..8822d62f7 Binary files /dev/null and b/script_tools/nginx-portable-aarch64.tgz differ diff --git a/script_tools/nginx-portable-x86_64.tgz b/script_tools/nginx-portable-x86_64.tgz new file mode 100644 index 000000000..4ad7a729e Binary files /dev/null and b/script_tools/nginx-portable-x86_64.tgz differ diff --git a/script_tools/py36-aarch64.tgz b/script_tools/py36-aarch64.tgz new file mode 100644 index 000000000..826bc456d Binary files /dev/null and b/script_tools/py36-aarch64.tgz differ diff --git a/script_tools/py36-x86_64.tgz b/script_tools/py36-x86_64.tgz new file mode 100644 index 000000000..390243dd1 Binary files /dev/null and b/script_tools/py36-x86_64.tgz differ diff --git a/script_tools/setup_proxy.sh b/script_tools/setup_proxy.sh index ac217b5f4..1a3ec146e 100755 --- a/script_tools/setup_proxy.sh +++ b/script_tools/setup_proxy.sh @@ -3,9 +3,26 @@ # gse proxy安装脚本, 仅在节点管理2.0中使用 # DEFAULT DEFINITION + +get_cpu_arch () { + local cmd=$1 + CPU_ARCH=$($cmd) + CPU_ARCH=$(echo ${CPU_ARCH} | tr 'A-Z' 'a-z') + if [[ "${CPU_ARCH}" =~ "x86_64" ]]; then + return 0 + elif [[ "${CPU_ARCH}" =~ "x86" || "${CPU_ARCH}" =~ ^i[3456]86 ]]; then + return 1 + elif [[ "${CPU_ARCH}" =~ "aarch" ]]; then + return 0 + else + return 1 + fi +} +get_cpu_arch "uname -p" || get_cpu_arch "uname -m" || fail get_cpu_arch "Failed to get CPU arch or unsupported CPU arch, please contact the developer." + GSE_COMPARE_VERSION="1.7.2" NODE_TYPE=proxy -PKG_NAME=gse_${NODE_TYPE}-linux-x86_64.tgz +PKG_NAME=gse_${NODE_TYPE}-linux-${CPU_ARCH}.tgz BACKUP_CONFIG_FILES=("procinfo.json") GSE_AGENT_RUN_DIR=/var/run/gse diff --git a/script_tools/start_nginx.sh.tpl b/script_tools/start_nginx.sh.tpl index 58f4ee262..bf36307e2 100644 --- a/script_tools/start_nginx.sh.tpl +++ b/script_tools/start_nginx.sh.tpl @@ -1,8 +1,26 @@ +get_cpu_arch () { + local cmd=$1 + CPU_ARCH=$($cmd) + CPU_ARCH=$(echo ${CPU_ARCH} | tr 'A-Z' 'a-z') + if [[ "${CPU_ARCH}" =~ "x86_64" ]]; then + return 0 + elif [[ "${CPU_ARCH}" =~ "x86" || "${CPU_ARCH}" =~ ^i[3456]86 ]]; then + return 1 + elif [[ "${CPU_ARCH}" =~ "aarch" ]]; then + return 0 + else + return 1 + fi +} +get_cpu_arch "uname -p" || get_cpu_arch "uname -m" || fail get_cpu_arch "Failed to get CPU arch or unsupported CPU arch, please contact the developer." + /opt/nginx-portable/nginx-portable stop || :; rm -rf /opt/nginx-portable/; rm -rf /opt/py36/; -tar xvf %(nginx_path)s/py36.tgz -C /opt; -tar xvf %(nginx_path)s/nginx-portable.tgz -C /opt; + +tar xvf %(nginx_path)s/py36-${CPU_ARCH}.tgz -C /opt; +tar xvf %(nginx_path)s/nginx-portable-${CPU_ARCH}.tgz -C /opt; + timeout 120 chmod -R 755 %(nginx_path)s || echo "chmod directory %(nginx_path)s failed" user=root group=root