添加SHA256检测,去除对XP的支持

This commit is contained in:
2019-08-31 22:04:15 +08:00
parent 14faab4894
commit 8a392690fa
4 changed files with 59 additions and 59 deletions

View File

@ -66,7 +66,7 @@ download() {
fi
}
getLatestVersion() {
Install() {
local platformValue=`platform`
local archValue=`arch`
@ -83,25 +83,33 @@ getLatestVersion() {
if [[ "${status}" == "1" ]]; then
local downloadURL=$(echo "${res}" | grepCross '"downloadURL":".*?[^\\]",' | sed 's/"downloadURL":"//g' | sed 's/",//g')
echo ${downloadURL}
else
echo "no"
fi
}
local fileSha256=$(echo "${res}" | grepCross '"sha256":".*?[^\\]",' | sed 's/"sha256":"//g' | sed 's/",//g')
Install() {
downloadURL=`getLatestVersion`
if [[ "${downloadURL}" != "no" ]]; then
mkdir -p /usr/local/dc-agent/bin
mkdir -p /usr/local/dc-agent/log
download "${downloadURL}" -o "/usr/local/dc-agent/bin/dc-agent"
if cmdhas "sha256sum"; then
checkSha256=$(sha256sum /usr/local/dc-agent/bin/dc-agent | awk '{ print $1 }' | tr '[A-Z]' '[a-z]')
if [[ "${checkSha256}" != "${fileSha256}" ]]; then
echo -e "${checkSha256}\n"
echo -e "${fileSha256}\n"
echo -e "\nError: File sha256 check failed.\n"
exit 1
fi
else
echo -e "\nError: sha256sum command not found.\n"
exit 1
fi
echo -e "\n"
sudo chmod 755 /usr/local/dc-agent/bin/dc-agent
sudo /usr/local/dc-agent/bin/dc-agent install
sudo /usr/local/dc-agent/bin/dc-agent start
echo -e "\nInstall success!\n"
else
echo -e "\nServer connection failed, please check your network connection.\n"
fi