#/bin/sh export CDNPLUS_VERSION="2.7.3" export NGINX_VERSION="1.21.4.1" OS="6" if [ -f /usr/bin/systemctl ] ; then OS="7" if [ -f /usr/bin/dnf ] ; then OS="8" fi fi if test `arch` != "x86_64"; then echo "Only support arch x86_64..." exit 1 fi if [ $OS != "7" ] ; then echo "Only support linux distribution: CentOS 7" exit 1 fi ARCH="el$OS.x86_64" test_file="test_download_file" down_file="cdnplus.el7.x86_64.rpm" dst_file="cdnplus.el7.x86_64.rpm" VER=$3 if [ $VER ]; then down_file=cdnplus-$VER.el7.x86_64.rpm fi download() { local prefix1=$1 local prefix2=$2 local test_url1=$prefix1/$test_file local test_url2=$prefix2/$test_file local filename=$3 echo "Test download node speed..." speed1=`curl -m 3 -L -s -k -w '%{speed_download}' "$test_url1" -o /dev/null || true` speed1=${speed1%%.*} speed2=`curl -m 3 -L -s -k -w '%{speed_download}' "$test_url2" -o /dev/null || true` speed2=${speed2%%.*} echo "Node 1 speed: "$speed1 echo "Node 2 speed: "$speed2 url="$prefix1/$down_file\n$prefix2/$down_file" if [[ $speed2 -gt $speed1 ]]; then url="$prefix2/$down_file\n$prefix1/$down_file" fi flag=0 echo -e $url | while read _url;do echo "Using url:"$_url wget --dns-timeout=5 --connect-timeout=5 --read-timeout=10 --tries=2 --no-check-certificate "$_url" -O $filename ret=$? if [ $ret == 0 ] ; then flag=1 break fi if [ $flag != 1 ] ; then echo "Download Failed" exit -1 fi done } cd /tmp/ rm $dst_file -rf download "https://download-us.cdnplus.cn" "https://download-cn.cdnplus.cn" $dst_file if [ -f $dst_file ];then echo "" else echo "Install package not exist." exit -1 fi yum localinstall $dst_file -y CP_ID=$1 CP_TOKEN=$2 ret=$? if [ $ret == 0 ] ; then if [ $CP_ID ]; then FILE="/opt/CDNPlus/Bin/Config.ini" echo "[auth]" > $FILE 2>&1 echo "api_id = "$CP_ID >> $FILE 2>&1 echo "api_token = "$CP_TOKEN >> $FILE 2>&1 fi echo "Installation Success" else echo "Installation Failed" fi