#!/bin/bash
file=./cardip_info.txt
mun_sum=`cat $file|wc -l`
#mun_sum=
echo 总共卡数: $mun_sum
   for mun in `seq 1 $mun_sum`
		do
               {
			card_net=`sed -n "$mun"p $file |awk '{print $1}'`
                        adb_connect_result=$(timeout 5 adb connect $card_net 2>&1)
			if [[ $adb_connect_result == *"connected to"* ]]; then
				##适用于gt865设备
				adb -s $card_net push /sdb/nginx/IaaS_agent/AC_IaaS_agent /data/bin/
				adb -s $card_net shell  chmod +x /data/bin/AC_IaaS_agent
				adb -s $card_net push iaasMsg.txt /data/conf/iaas/
				adb -s $card_net shell  'ps -ef | grep "AC_IaaS_agent" | grep -v grep | cut -c 9-20 | xargs kill -9' >/dev/null
				adb -s $card_net shell  'ps -ef | grep "AC_IaaS_agent" | grep -v grep | cut -c 9-20 | xargs kill -9' >/dev/null
		        	version_check=$(adb -s $card_net shell /data/bin/AC_IaaS_agent -version)
				if [[ $version_check == *"native.iaas.proxy.mqtt.qs865.20240619.1"* ]]; then
						echo "$card_net 升级成功"
					else
						echo "$card_net 升级失败" >>./gt865更新代理版本检查失败.txt
					fi
				adb disconnect $card_net
			else
				echo "$card_net" >>./gt865更新代理adb连接不上.txt
				adb disconnect $card_net
			fi

                        }
done

