small-package/luci-app-sms-tool/root/etc/uci-defaults/set_sms_ports.sh

75 lines
2.2 KiB
Bash
Raw Normal View History

2021-09-24 23:37:27 +08:00
#!/bin/sh
2023-05-01 16:22:51 +08:00
# Copyright 2020-2023 Rafał Wabik (IceG) - From eko.one.pl forum
2021-09-24 23:37:27 +08:00
# Licensed to the GNU General Public License v3.0.
2023-05-01 16:22:51 +08:00
chmod +x /etc/init.d/smsled 2>&1 &
chmod +x /sbin/smsled-init.sh 2>&1 &
chmod +x /sbin/cronsync.sh 2>&1 &
chmod +x /sbin/set_sms_ports.sh 2>&1 &
chmod +x /sbin/smsled.sh 2>&1 &
rm -rf /tmp/luci-indexcache 2>&1 &
rm -rf /tmp/luci-modulecache/ 2>&1 &
2022-08-17 20:21:51 +08:00
2021-09-24 23:37:27 +08:00
work=false
for port in /dev/ttyUSB*
do
[[ -e $port ]] || continue
gcom -d $port info &> /tmp/testusb
testUSB=`cat /tmp/testusb | grep "Error\|Can't"`
if [ -z "$testUSB" ]; then
work=$port
break
fi
done
rm -rf /tmp/testusb
if [ $work != false ]; then
2023-05-01 16:22:51 +08:00
uci set sms_tool.@sms_tool[0].readport=$work 2>&1 &
uci set sms_tool.@sms_tool[0].sendport=$work 2>&1 &
uci set sms_tool.@sms_tool[0].ussdport=$work 2>&1 &
uci set sms_tool.@sms_tool[0].atport=$work 2>&1 &
uci commit sms_tool 2>&1 &
2021-09-24 23:37:27 +08:00
fi
2022-11-22 08:57:39 +08:00
DEVICE=$(cat /tmp/sysinfo/board_name)
if [[ "$DEVICE" == *"mf289f"* ]]; then
2023-05-01 16:22:51 +08:00
uci set sms_tool.@sms_tool[0].readport="/dev/ttyUSB1" 2>&1 &
uci set sms_tool.@sms_tool[0].sendport="/dev/ttyUSB1" 2>&1 &
uci set sms_tool.@sms_tool[0].ussdport="/dev/ttyUSB1" 2>&1 &
uci set sms_tool.@sms_tool[0].atport="/dev/ttyUSB1" 2>&1 &
uci commit sms_tool 2>&1 &
2022-11-22 08:57:39 +08:00
fi
if [[ "$DEVICE" == *"mf286r"* ]]; then
2023-05-01 16:22:51 +08:00
uci set sms_tool.@sms_tool[0].readport="/dev/ttyACM0" 2>&1 &
uci set sms_tool.@sms_tool[0].sendport="/dev/ttyACM0" 2>&1 &
uci set sms_tool.@sms_tool[0].ussdport="/dev/ttyACM0" 2>&1 &
uci set sms_tool.@sms_tool[0].atport="/dev/ttyACM0" 2>&1 &
uci commit sms_tool 2>&1 &
2022-11-22 08:57:39 +08:00
fi
if [[ "$DEVICE" == *"mf286d"* ]]; then
2023-05-01 16:22:51 +08:00
uci set sms_tool.@sms_tool[0].readport="/dev/ttyUSB1" 2>&1 &
uci set sms_tool.@sms_tool[0].sendport="/dev/ttyUSB1" 2>&1 &
uci set sms_tool.@sms_tool[0].ussdport="/dev/ttyUSB1" 2>&1 &
uci set sms_tool.@sms_tool[0].atport="/dev/ttyUSB1" 2>&1 &
uci commit sms_tool 2>&1 &
2022-11-22 08:57:39 +08:00
fi
if [[ "$DEVICE" == *"mf286"* ]]; then
2023-05-01 16:22:51 +08:00
uci set sms_tool.@sms_tool[0].readport="/dev/ttyUSB1" 2>&1 &
uci set sms_tool.@sms_tool[0].sendport="/dev/ttyUSB1" 2>&1 &
uci set sms_tool.@sms_tool[0].ussdport="/dev/ttyUSB1" 2>&1 &
uci set sms_tool.@sms_tool[0].atport="/dev/ttyUSB1" 2>&1 &
uci commit sms_tool 2>&1 &
2022-11-22 08:57:39 +08:00
fi