Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # This script is Quectel-specific (AT+QCFG="usbnet" commands) and must only run
- # against that modem model. Detect it by the presence of its USB by-id path and
- # bail out early — before touching ModemManager — for any other modem.
- MODEM_PORT="${1:-/dev/serial/by-id/usb-Android_Android_0000-if03-port0}"
- if [ ! -e "$MODEM_PORT" ]; then
- echo "Modem not found at $MODEM_PORT" >&2
- echo "This script only supports the Quectel modem; aborting." >&2
- exit 1
- fi
- # Stop ModemManager service
- echo "Stopping ModemManager..."
- sudo systemctl stop ModemManager
- # Disable ModemManager to prevent auto-restart
- echo "Disabling ModemManager..."
- sudo systemctl disable ModemManager
- echo "Connecting to modem on $MODEM_PORT..."
- # Send AT commands via file descriptor
- exec 3<>"$MODEM_PORT"
- send_at() {
- echo ">>> $1"
- printf '%s\r' "$1" >&3
- timeout 3 cat <&3 &
- sleep 2
- kill $! 2>/dev/null
- wait $! 2>/dev/null
- echo
- }
- send_at 'AT+QCFG="usbnet"'
- send_at 'AT+QCFG="usbnet",3'
- send_at 'AT+QCFG="usbnet"'
- send_at 'AT+CFUN=1,1'
- exec 3>&-
- # Prompt user to restart router
- echo ""
- echo "================================"
- echo "Manual Steps Required:"
- echo "1. Power off the Xnergy router"
- echo "================================"
- read -p "Press Enter after completing the above steps..."
- # Re-enable ModemManager
- echo "Enabling ModemManager..."
- sudo systemctl enable ModemManager
- sleep 1
- echo "Done"
- # Restart device
- # echo "Restarting..."
- # sudo shutdown -r now
Advertisement
Add Comment
Please, Sign In to add comment