Files
airborne_CO2/choosescript.sh
2026-01-21 14:44:51 +08:00

24 lines
791 B
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# 定义配置文件路径
CONFIG_FILE="/home/DJI/Settings/HardwareSettings.ini"
# 判断文件是否存在
if [ ! -f "$CONFIG_FILE" ]; then
echo "错误: 找不到配置文件 $CONFIG_FILE"
exit 1
fi
# 提取 AirplaneType 的值
# 1. grep 找到包含 AirplaneType 的行
# 2. cut 以 '=' 为分隔符取第二个字段
# 3. tr -d 去除回车符(\r)和空格,防止空字符导致判断失败
PLANE_TYPE=$(grep "AirplaneType" "$CONFIG_FILE" | cut -d'=' -f2 | tr -d '\r ')
echo "当前的机型是: [$PLANE_TYPE]"
# 进行判断
if [ "$PLANE_TYPE" = "M400" ]; then
echo "执行 bash a.sh"
chmod +x /root/raspusb.sh
bash /root/raspusb.sh
else
echo "机型不是 M400执行 sh b.sh"
chmod +x /root/mountdjirndis.sh
sh /root/mountdjirndis.sh
fi