#!/bin/bash #reset modem first APN="Wholesale" #set your APN name here for network manager. #power-off the modem in case it's already on. uconsole-4g-cm4 disable #power-on modem. uconsole-4g-cm4 enable echo "sudo: restart modemmanager" sudo systemctl restart ModemManager.service echo "waiting 10s for modem detection" sleep 10 #todo: check 'mmcli -m any | grep "primary port"' # save the ttyUSB port value, inject it into socat and nmcli commands. echo "attempting startup" echo -en "AT+CUSBPIDSWITCH?\r\n" | sudo socat - /dev/ttyUSB2,crnl echo "sudo: reset & re-add modem to network manager" sudo nmcli c del 4gnet sudo nmcli c add type gsm ifname ttyUSB3 con-name 4gnet apn $APN