- 安装依赖
sudo apt update
sudo apt install make gcc git busybox udhcpc
- 获取quectel-CM源码
git clone https://github.com/kmilo17pet/quectel-cm.git
- 编译源码
cd quectel-cm/
make
- 将编译好的程序拷贝到/user/bin目录
sudo cp quectel-CM /usr/bin/
- 添加执行权限
sudo chmod 777 /usr/bin/quectel-CM
- 创建自动拨号脚本
sudo vi /opt/auto_4G.sh
- 自动拨号脚本内容(auto_4G.sh)
// 每隔2秒检查是否识别到网卡
sleep 2
// 以下根据运营商三选一
sudo quectel-CM -s cmnet // 移动卡
sudo quectel-CM -s 3gnet // 联通卡
sudo quectel-CM -s ctnet // 电信卡
- 添加执行权限
sudo chmod 0755 /opt/auto_4G.sh
- 创建自动拨号服务
sudo vi /etc/systemd/system/auto_4G.service
- 拨号服务内容(auto_4G.service)
[Unit]
Description = auto_4G daemon
[Service]
ExecStart = /opt/auto_4G.sh
Restart = always
Type = simple
[Install]
WantedBy = multi-user.target
- 激活拨号服务
sudo systemctl enable auto_4G
sudo systemctl start auto_4G
- 重启即可