ip输入更改为手动

This commit is contained in:
wukongdaily
2024-02-27 11:04:04 +08:00
parent 531da67646
commit b754a35d04
4 changed files with 12 additions and 105 deletions

View File

@@ -47,26 +47,9 @@ check_adb_connected() {
# 连接adb
connect_adb() {
# 尝试自动获取网关地址
#gateway_ip=$(ip route show default | grep default | awk '{print $3}')
gateway_ip=$(ip a show br-lan | grep 'inet ' | awk '{print $2}' | cut -d'/' -f1)
if [ -z "$gateway_ip" ]; then
echo -e "${RED}无法自动获取网关IP地址请手动输入电视盒子的完整IP地址${NC}"
read ip
else
# 提取网关IP地址的前缀
gateway_prefix=$(echo $gateway_ip | sed 's/\.[0-9]*$//').
echo -e "${YELLOW}请输入电视盒子的ip地址(${NC}${BLUE}${gateway_prefix}${NC}${YELLOW})的最后一段数字${NC}"
read end_number
if is_integer "$end_number"; then
# 使用动态获取的网关前缀
ip=${gateway_prefix}${end_number}
else
echo -e "${RED}错误: 请输入整数。${NC}"
return 1
fi
fi
echo -e "${BLUE}请手动输入电视盒子的IP地址:${NC}"
read ip
adb disconnect
echo -e "${BLUE}首次使用,盒子上可能会提示授权弹框,给您半分钟时间来操作...【允许】${NC}"
adb connect ${ip}