我有一个 USB GSM 调制解调器,它并不总是正常工作(华为 E367u-2)有时它会被重置(USB 设备在日志中断开/重新连接),当它恢复时,它有不同的 ttyUSB 号码。有时在启动时,usb_modeswitch似乎只是没有被解雇。计算机是运行 Raspbian 的 Raspberry Pi。
我对此有一个简单的解决方案:每分钟cron运行以下脚本(伪代码):
If WVDIAL is not running:
Run WVDIAL
Run Code Online (Sandbox Code Playgroud)
我想将脚本更改为:
If /dev/ttyUSB0 is not present:
If DevicePresent(12d1:1446):
ResetDevice(12d1:1446)
ElseIf DevicePresent(12d1:1506)
ResetUSB(12d1:1506)
If WVDIAL is not running:
Run WVDIAL
Run Code Online (Sandbox Code Playgroud)
显然这是伪代码,但我需要将以下几行串在一起,但我不知道如何:
如果 wvdial 没有运行,这会加载它:
#! /bin/sh
# /etc/init.d/wvdial
### BEGIN INIT INFO
# Provides: TheInternet
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Simple …Run Code Online (Sandbox Code Playgroud)