Last active
March 3, 2021 15:33
-
-
Save superboum/ec90458a009db72abdfb4fbfc42073ed to your computer and use it in GitHub Desktop.
OpenWRT custom scripts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh /etc/rc.common | |
USE_PROCD=1 | |
START=99 | |
STOP=01 | |
start_service() { | |
procd_open_instance | |
procd_set_param command /usr/sbin/wwan0_loop.sh | |
procd_set_param stdout 1 | |
procd_set_param stderr 1 | |
procd_close_instance | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/lua | |
local filesize = require "filesize" | |
local rxfile = io.open("/sys/class/net/wwan0/statistics/rx_bytes", "r") | |
local txfile = io.open("/sys/class/net/wwan0/statistics/tx_bytes", "r") | |
local rx = filesize(tonumber(rxfile:read("*all"))) | |
local tx = filesize(tonumber(txfile:read("*all"))) | |
print("RX:", rx, "TX:",tx) | |
rxfile:close() | |
txfile:close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
rm -f /tmp/logread.txt | |
logread -f > /tmp/logread.txt & | |
LOGREAD_PID=$! | |
mmcli -m 0 --command="AT+CREG?" > /dev/null | |
kill -9 ${LOGREAD_PID} | |
ATRES=$(grep -Eo '\+CREG: [0-9],[0-9],"[0-9A-F]+","[0-9A-F]+"' /tmp/logread.txt) | |
rm -f /tmp/logread.txt | |
echo $ATRES | cut -d, -f4 | grep -Eo '[0-9A-F]+' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Global Configuration | |
mmcli -m 0 --signal-setup=10 2>&1 1>/dev/null | |
# Fetch & parse signal from MM | |
RES=$(mmcli -m 0 --signal-get -K) | |
RSRQ=$(echo -en "$RES" | grep modem.signal.lte.rsrq | grep -Eo "\-?[0-9]*.[0-9]*$") | |
RSRP=$(echo -en "$RES" | grep modem.signal.lte.rsrp | grep -Eo "\-?[0-9]*.[0-9]*$") | |
SNR=$(echo -en "$RES" | grep modem.signal.lte.snr | grep -Eo "\-?[0-9]*.[0-9]*$") | |
# Run AT Command to get LCID not reported by MM | |
rm -f /tmp/logread.txt | |
logread -f > /tmp/logread.txt & | |
LOGREAD_PID=$! | |
mmcli -m 0 --command="AT+CREG?" > /dev/null | |
kill -9 ${LOGREAD_PID} | |
ATRES=$(grep -Eo '\+CREG: [0-9],[0-9],"[0-9A-F]+","[0-9A-F]+"' /tmp/logread.txt) | |
rm -f /tmp/logread.txt | |
LCID=$(echo $ATRES | cut -d, -f4 | grep -Eo '[0-9A-F]+') | |
# Display parsed data | |
echo "rsrq=$RSRQ, rsrp=$RSRP, snr=$SNR, lcid=$LCID" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
mmcli --modem 0 --monitor-state | while read r ; do /usr/sbin/wwan0_reconnect.sh ; done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
MODEM_STATE=$(mmcli --modem 0 --output-keyvalue|grep "modem.generic.state"|grep -o "\w*$") | |
BEARER=$(mmcli --modem 0 --output-keyvalue|grep 'modem.generic.bearers.value\[1\]'|grep -o '\d*$') | |
BEARER_CONNECTED=$(mmcli -b $BEARER --output-keyvalue|grep bearer.status.connected|grep -o "\w*$") | |
echo "(modem state: $MODEM_STATE, bearer connected: $BEARER_CONNECTED, bearer id: $BEARER)" | |
if [[ $MODEM_STATE == 'registered' ]] ; then | |
echo "trigger simple-connect" | |
ifup broadband | |
sleep 600 # prevent loops | |
else | |
echo "do nothing" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment