在shell脚本中,使用openssl version判断openssl安装情况可能有问题
zouxyan opened this issue · 3 comments
zouxyan commented
BUG描述
在使用bash ./WeCross/build_wecross.sh -n payment -o routers-payment -f ipfile
的时候,报错:
[ERROR] Please install openssl!
[INFO] Use "openssl version" command to check.
重现方式
我的环境是MacOS,openssl版本是3.0.0(brew install openssl 安装的)。
运行bash ./WeCross/build_wecross.sh -n payment -o routers-payment -f ipfile
,即可报错。
预期结果
报错
环境
- 操作系统: MACOS
- 运行库 openssl 3.0.0
原因
在3.0版本的openssl运行一下命令:
$ /usr/local/opt/openssl/bin/openssl version
OpenSSL 3.0.0 7 sep 2021 (Library: OpenSSL 3.0.0 7 sep 2021)
返回的信息和2.x的openssl有所不同:
$ openssl version
LibreSSL 2.8.3
所以以下判断逻辑需要优化:
check_env() {
# shellcheck disable=SC2143
# shellcheck disable=SC2236
# 就是这里使用openssl version 去做判断有问题。
[ ! -z "$(openssl version | grep 1.0.2)" ] || [ ! -z "$(openssl version | grep 1.1)" ] || [ ! -z "$(openssl version | grep reSSL)" ] || {
LOG_ERROR "Please install openssl!"
#echo "download openssl from https://www.openssl.org."
LOG_INFO "Use \"openssl version\" command to check."
exit 1
}
if [ ! -z "$(openssl version | grep reSSL)" ]; then
export PATH="/usr/local/opt/openssl/bin:$PATH"
fi
if [ "$(uname)" == "Darwin" ]; then
macOS="macOS"
fi
if [ "$(uname -m)" != "x86_64" ]; then
x86_64_arch="false"
fi
}
JimmyShi22 commented
get
UserWang commented
我的openssl版本是3.0,目前还是这个问题,所以是一直没改?需要把openssl改为1.1?
kyonRay commented
我的openssl版本是3.0,目前还是这个问题,所以是一直没改?需要把openssl改为1.1?
会在下个版本修复,可以先使用openssl@1.1版本,或者修改脚本:
[ ! -z "$(openssl version | grep 1.0.2)" ] || [ ! -z "$(openssl version | grep 1.1)" ] || [ ! -z "$(openssl version | grep reSSL)" ] || [ ! -z "$(openssl version | grep 3.)" ] {
LOG_ERROR "Please install openssl!"
#echo "download openssl from https://www.openssl.org."
LOG_INFO "Use \"openssl version\" command to check."
exit 1
}