What's new

tmo.sh - A T-Mobile/Sagemcom Gateway Utility AddOn

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

JGrana

Very Senior Member
Background

I have been spending time working on a script to do some light management of my T-Mobile Sagemcom Gateway.
The main goal was to be able to turn the WiFi radios off/on (since I have an AX88U Pro in front of the gateway) and also be able to reboot the Sagemcom based on spdMerlins reported download speed.

I found that when the Sagemcom/T-Mobile Gateway starts to slow down (less than 12 MBits/sec) a reboot generally gets me back to 150 Mbits/sec+. I added a small hook to spdMerlin that called a script (background so non-blocking) at the end of the speedtest and passes the download and upload speedtest results (arg1 and arg2). Based on the download speed, I would then call tmo with the reboot command.

Its worked fine. I had some time and wanted to learn more about the Linux dialog menuing system. The original Slackware used this (dialog was created by them) and is still in use in many Linux distributions for installing.

So, here is what I have so far!

It can run in menu mode or called as a script. More details in the info below. For the most part, I tried to follow typical AddOn structure. The script (tmo.sh) resides in /jffs/scripts and it's configuration file and data files reside in /jffs/addons. It also creates a symbolic link in /opt/bin for easier use.
Its has an "install" and "uninstall" command that takes care of the above. It does not have an update command, at least at this point.

It is hosted on github https://github.com/JGrana01/tmo

It does require Entware installed since it does some json manipulation, dialog for the menus and a few formatting tools like column. These will be installed during tmo.sh install if they are not present.

Here is the Readme:

Linux shell script to access and change some settings on T-Mobile Sagemcom Fast 5688W Gateway

About​

Tmo.sh is a Linux shell script (tested on an Asuswrt-Merlin AX88U Pro) based on a MS PowerShell scripts on Nate Taters YouTube channel. I converted it to a Linux shell scripts (with help from ChatGPT!) and added some additional commands to display the 5G/LTE radio information and overall gateway information. Added thanks to @thelonelycoder on snbforums for the password encryption code!

It supports a menuing system based on Linux dialog or can be run with arguemnts as a script.

This script will allow you to enable/disable the WiFi radios (2.4 and 5Ghz). Helpful when running as just a modem in front of an Asus router. I also added a reboot command.

I found that when my download speeds got low (less than 12 Mbits/sec.) a reboot of the Sagemcom ($ tmo reboot) usually got it back to 100Mbit+.

Installation​

For Asuswrt-merlin based routers, using your preferred SSH client/terminal, copy and paste the following command, then press Enter:

/usr/sbin/curl --retry 3 "https://raw.githubusercontent.com/JGrana01/tmo/master/tmo.sh" -o "/jffs/scripts/tmo.sh" && chmod 0755 /jffs/scripts/tmo.sh && /jffs/scripts/tmo.sh install

Using​

The script runs either in a dialog based menu mode or in a script mode.To run in menu mode, just invoke without any command line argument:

$ tmo


image

To run in script mode, pass an argument. I.e.:

$ tmo status

It can also be called from another shell script in script mode. In script mode, after install, you will need to set the password for the Gateway. tmo.sh will encrypt the password and store in the file /jffs/addons/tmo/tmopw.enc for use. You should only need to do this once, unless to change the default admin password on the Gateway itself.

In script mode, you pass it any of these arguments:

config - displays the present configuration of the gateway
status - show the state of the two WiFi bands (enabled or disabled)
signal - show the present state of both the LTE and the 5G radios. Bands, levels etc.
signals - retrieve signal status and store (silently) in /jffs/addons/tmo/config.txt
all - show all the gateway information - both WiFi and Radios
radio [2.4|5] [off|on] - turn the 2.4Ghz or 5Ghz WiFi radios off or on
reboot - reboot the Sagemcom Fast Gateway
password - input the TMO Gateway admin password - needed for most commands
install - create the directory /jffs/addons/tmo, create a conf file and initial encrypted password file and then create a link in /opt/bin to tmo.sh
uninstall - remove everything related to tmo.sh
 
I had mentioned a script to insert a "hook" into spdMerlin.

This is what I use. Install spdMerlin then run this script. After any update to spdMerlin you will need to run the script again.


Code:
#!/bin/sh

#
# spdmerlinpatch - insert a hook into spdmerlin to call an external script
# when the speedtest is done. It will pass the download speed (arg1) and upload speed
# (arg2) to the script /jffs/scripts/spdmerlinhook
#
# at some point, this could be rolled into spdMerlin
#

if [ ! /jffs/scripts/spdmerlin ]; then
     echo "spdmerlin not found in /jffs/scripts"
     echo "You need spdmerlin installed"
     exit
fi


if [ ! -x /jffs/scripts/spdmerlinhook ]; then
        echo "spdmerlinhook doesn't exist in /jffs/scripts"
        echo -n "Create it now? "
        read answer
        case $answer in
                y|Y)
                        printf "#!/bin/sh\n" > /jffs/scripts/spdmerlinhook
                        printf "# spdmerlinhook - called after spdMerlin has run a speedtest\n" >> /jffs/scripts/spdmerlinhook
                        printf "# passes Download as arg1 and Upload as arg2\n" >> /jffs/scripts/spdmerlinhook
                        chmod +x /jffs/scripts/spdmerlinhook
                        echo "Done, created"
                ;;
                *)
                        echo "Ok, needed for the hook...exiting"
                        exit
                ;;
        esac
fi


if ! $(grep spdmerlinhook /jffs/scripts/spdmerlin > /dev/null); then
        if [ ! -f /jffs/scripts/spdmerlin.orig ]; then
                cp /jffs/scripts/spdmerlin /jffs/scripts/spdmerlin.orig
        fi
        sed -i '/var spdteststatus = "Done"/a # Speedtest hook patch\n\t\t\tif [ -x /jffs/scripts/spdmerlinhook ]; then\n\t\t\t\t/jffs/scripts/spdmerlinhook $download $upload &\n\t\t\tfi\n# End of patch\n' /jffs/scripts/spdmerlin
        echo "spdmerlin patched"
else
        echo "spdmerlin not patched, spdmerlinhook already installed"
fi
 
Can you still use the script even if you don't use spdMerlin?
 

Latest threads

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top