Skip to content

Commit

Permalink
feat: arm架构安装proxy优化 (closed #2472)
Browse files Browse the repository at this point in the history
  • Loading branch information
chalice-1831 authored and jpyoung3 committed Nov 1, 2024
1 parent 7f47072 commit 2482a35
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 3 additions & 2 deletions apps/node_man/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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": _("下发安装工具"),
},
Expand Down
19 changes: 18 additions & 1 deletion script_tools/agent_tools/agent2/setup_proxy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 () {
Expand Down Expand Up @@ -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
Expand Down
Binary file added script_tools/nginx-portable-aarch64.tgz
Binary file not shown.
Binary file added script_tools/nginx-portable-x86_64.tgz
Binary file not shown.
Binary file added script_tools/py36-aarch64.tgz
Binary file not shown.
Binary file added script_tools/py36-x86_64.tgz
Binary file not shown.
19 changes: 18 additions & 1 deletion script_tools/setup_proxy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 20 additions & 2 deletions script_tools/start_nginx.sh.tpl
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 2482a35

Please sign in to comment.