diff --git a/portal/offline/install/main.sh b/portal/offline/install/main.sh index c597c33b05a59d981445a64ed5445f590a4185c3..ad5219fbeb5d9b5da0b12fada7f12761132fcb69 100644 --- a/portal/offline/install/main.sh +++ b/portal/offline/install/main.sh @@ -145,6 +145,9 @@ EOF cat << EOF > "${dependencies_path}/install_dependencies.sh" #!/bin/bash +# 支持的系统架构 +support_system="$1" + # portal依赖的rpm包 portal_packages=(${portal_packages}) @@ -154,6 +157,28 @@ chameleon_packages=(${chameleon_packages}) # 需要安装的rpm包 packages=("\${portal_packages[@]}") +# 将字符串转为小写的方法 +to_lower() { + echo "\$1" | tr '[:upper:]' '[:lower:]' +} + +# 检查系统架构是否匹配的方法 +check_system() { + current_os=\$(cat /etc/os-release | grep ID= | head -n 1 | awk -F '=' '{print \$2}' | sed 's/\"//g') + current_os_version=\$(cat /etc/os-release | grep VERSION_ID= | head -n 1|awk -F '=' '{print \$2}' | sed 's/\"//g') + current_cpu_arch=\$(uname -m) + current_system="\${current_os}\${current_os_version}_\${current_cpu_arch}" + lower_current_system=\$(to_lower "\${current_system//.}") + lower_support_system=\$(to_lower "\${support_system}") + + if [ "\$lower_current_system" = "\$lower_support_system" ]; then + echo "System and architecture match" + else + echo "System and architecture do not match, current dependencies is used for \$support_system" + exit 1 + fi +} + # 安装依赖的方法 install() { for package in "\${packages[@]}" @@ -170,6 +195,8 @@ install() { done } +check_system + case \$1 in "portal") echo "Start install the portal dependencies." @@ -203,7 +230,7 @@ main() { generate_usage check_parameters $@ read_properties $@ - write_shell + write_shell $@ download_rpms echo "main shell end" }