From c01c9e88e00af70c20ba7bf70be7c79e99d5072a Mon Sep 17 00:00:00 2001
From: iamromulan <50184035+iamromulan@users.noreply.github.com>
Date: Tue, 26 Mar 2024 01:57:29 -0400
Subject: [PATCH] Sync stable Changes with development
-NSA and SA stats now show correctly
-Entware is now considered out of BETA
-ttyd installation process improved
-Added install option for speedtest and fast CLI commands
Co-Authored-By: Russel Yasol <73575327+dr-dolomite@users.noreply.github.com>
---
RMxxx_rgmii_toolkit.sh | 106 +++++++++++++++++------
installentware.sh | 42 ++++++++-
simpleadmin/scripts/modemstatus_parse.sh | 60 ++++++++-----
simpleadmin/www/atcommander.html | 91 +++++++++++++------
simpleadmin/www/cgi-bin/get_atcommand | 4 +-
simpleadmin/www/index.html | 70 +++++++++++----
simpleadmin/www/speedtest.html | 79 +++++++++++++++++
simpleadmin/www/styles.css | 41 +++++++++
simpleadmin/www/ttl.html | 19 ++--
socat-at-bridge/atcmd | 46 ++++++----
ttyd/scripts/ttyd.bash | 13 +--
11 files changed, 447 insertions(+), 124 deletions(-)
create mode 100644 simpleadmin/www/speedtest.html
create mode 100644 simpleadmin/www/styles.css
diff --git a/RMxxx_rgmii_toolkit.sh b/RMxxx_rgmii_toolkit.sh
index bc8dd53..b93e9de 100644
--- a/RMxxx_rgmii_toolkit.sh
+++ b/RMxxx_rgmii_toolkit.sh
@@ -795,10 +795,9 @@ WantedBy=multi-user.target" > "$cfun_service_path"
fi
}
-# Function for TTYd install
install_ttyd() {
echo -e "\e[1;34mStarting ttyd installation process...\e[0m"
-
+ # Check for existing Entware/opkg installation, install if not installed
if [ ! -f "/opt/bin/opkg" ]; then
echo -e "\e[1;32mInstalling Entware/OPKG\e[0m"
cd /tmp && wget -O installentware.sh "https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/installentware.sh" && chmod +x installentware.sh && ./installentware.sh
@@ -812,43 +811,69 @@ install_ttyd() {
fi
mount -o remount,rw /
- opkg update && opkg install shadow-login shadow-passwd
- if [ "$?" -ne 0 ]; then
- echo -e "\e[1;31mPackage installation failed. Please check your internet connection and try again.\e[0m"
- exit 1
+
+ if [ -d "/usrdata/ttyd" ]; then
+ echo -e "\e[1;34mttyd is already installed. Choose an option:\e[0m"
+ echo -e "\e[1;34m1.) Update to ttyd 1.7.4 (DO NOT UPDATE WHILE USING ttyd! Use ADB or SSH instead)\e[0m"
+ echo -e "\e[1;31m2.) Uninstall ttyd\e[0m"
+ read -p "Enter your choice (1/2): " choice
+ case $choice in
+ 1)
+ echo -e "\e[1;34mUpdating ttyd...\e[0m"
+ systemctl stop ttyd
+ wget -O /usrdata/ttyd/ttyd https://github.com/tsl0922/ttyd/releases/download/1.7.4/ttyd.armhf && chmod +x /usrdata/ttyd/ttyd
+ systemctl start ttyd
+ echo -e "\e[1;32mttyd has been updated.\e[0m"
+ ;;
+ 2)
+ echo -e "\e[1;34mUninstalling ttyd...\e[0m"
+ systemctl stop ttyd
+ rm -rf /usrdata/ttyd
+ rm /lib/systemd/system/ttyd.service
+ rm /lib/systemd/system/multi-user.target.wants/ttyd.service
+ rm /bin/ttyd
+ echo -e "\e[1;32mttyd has been uninstalled.\e[0m"
+ ;;
+ *)
+ echo -e "\e[1;31mInvalid option. Exiting.\e[0m"
+ exit 1
+ ;;
+ esac
+ return
fi
- # Replacing the login and passwd binaries
- rm /opt/etc/shadow
- cp /etc/shadow /opt/etc/
- rm /bin/login /usr/bin/passwd
- ln -sf /opt/bin/login /bin
- ln -sf /opt/bin/passwd /usr/bin/
- echo -e "\e[1;31mPlease set your system login password.\e[0m"
- /usr/bin/passwd
-
- # Setting up ttyd
+ # Continue with installation if ttyd is not already installed.
+ # Check for /usrdata/socat-at-bridge/atcmd, install if not installed
+ if [ ! -f "/usrdata/socat-at-bridge/atcmd" ]; then
+ echo -e "\e[1;34mDependency: atcmd command does not exist. Installing socat-at-bridge...\e[0m"
+ install_update_at_socat
+ if [ "$?" -ne 0 ]; then
+ echo -e "\e[1;31mFailed to install/update atcmd. Please check the process.\e[0m"
+ exit 1
+ fi
+ fi
mkdir -p /usrdata/ttyd/scripts /usrdata/ttyd/systemd
cd /usrdata/ttyd/
- wget -O ttyd "https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/ttyd/ttyd" && chmod +x ttyd
+ wget -O ttyd https://github.com/tsl0922/ttyd/releases/download/1.7.4/ttyd.armhf && chmod +x ttyd
wget -O scripts/ttyd.bash "https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/ttyd/scripts/ttyd.bash" && chmod +x scripts/ttyd.bash
wget -O systemd/ttyd.service "https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/ttyd/systemd/ttyd.service"
cp systemd/ttyd.service /lib/systemd/system/
- ln -sf /lib/systemd/system/ttyd.service /lib/systemd/system/multi-user.target.wants/
+ ln -sf /usrdata/ttyd/ttyd /bin
# Enabling and starting ttyd service
systemctl daemon-reload
- systemctl enable ttyd
+ ln -sf /lib/systemd/system/ttyd.service /lib/systemd/system/multi-user.target.wants/
systemctl start ttyd
if [ "$?" -ne 0 ]; then
echo -e "\e[1;31mFailed to start ttyd service. Please check the systemd service file and ttyd binary.\e[0m"
exit 1
fi
- echo -e "\e[1;32mInstall Complete! ttyd server is up on port 443. Note: No TLS/SSL enabled yet.\e[0m"
+ echo -e "\e[1;32mInstallation Complete! ttyd server is up on port 443. Note: No TLS/SSL enabled yet.\e[0m"
}
+
# Main menu
while true; do
echo " .%+: "
@@ -923,9 +948,11 @@ echo " :+##+. "
echo -e "\e[94m4) Tailscale Management\e[0m" # Light Blue
echo -e "\e[92m5) Install/Change or remove Daily Reboot Timer\e[0m" # Light Green
echo -e "\e[91m6) Install/Uninstall CFUN 0 Fix\e[0m" # Light Red
- echo -e "\e[96m7) Install Entware/OPKG (BETA/Advanced)\e[0m" # Cyan (repeated color for additional options)
- echo -e "\e[96m8) Install TTYd (BETA,443,No TLS/SSL)\e[0m" # Cyan
- echo -e "\e[93m9) Exit\e[0m" # Yellow (repeated color for exit option)
+ echo -e "\e[96m7) Install/Uninstall Entware/OPKG\e[0m" # Cyan (repeated color for additional options)
+ echo -e "\e[96m8) Install/Update/Uninstall TTYd 1.7.4 (Uses port 443, No TLS/SSL)\e[0m" # Cyan
+ echo -e "\e[92m9) Install Speedtest.net CLI app (speedtest command)\e[0m" # Light Green
+ echo -e "\e[92m10) Install Fast.com CLI app (fast command)(tops out at 40Mbps)\e[0m" # Light Green
+ echo -e "\e[93m11) Exit\e[0m" # Yellow (repeated color for exit option)
read -p "Enter your choice: " choice
case $choice in
@@ -963,13 +990,42 @@ echo " :+##+. "
;;
7)
echo -e "\e[1;32mInstalling Entware/OPKG\e[0m"
- cd /tmp && wget -O installentware.sh https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/installentware.sh && chmod +x installentware.sh && ./installentware.sh
- cd /
+ cd /tmp && wget -O installentware.sh https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/installentware.sh && chmod +x installentware.sh && ./installentware.sh && cd /
;;
8)
install_ttyd
;;
9)
+ echo -e "\e[1;32mInstalling Speedtest.net CLI (speedtest command)\e[0m"
+ remount_rw
+ mkdir /usrdata/root
+ mkdir /usrdata/root/bin
+ cd /usrdata/root/bin
+ wget https://install.speedtest.net/app/cli/ookla-speedtest-1.2.0-linux-armhf.tgz
+ tar -xzf ookla-speedtest-1.2.0-linux-armhf.tgz
+ rm ookla-speedtest-1.2.0-linux-armhf.tgz
+ rm speedtest.md
+ cd /
+ ln -sf /usrdata/root/bin/speedtest /bin
+ remount_ro
+ echo -e "\e[1;32mSpeedtest CLI (speedtest command) installed!!\e[0m"
+ echo -e "\e[1;32mTry running the command 'speedtest'\e[0m"
+ ;;
+ 10)
+ echo -e "\e[1;32mInstalling fast.com CLI (fast command)\e[0m"
+ remount_rw
+ mkdir /usrdata/root
+ mkdir /usrdata/root/bin
+ cd /usrdata/root/bin
+ wget -O fast https://github.com/ddo/fast/releases/download/v0.0.4/fast_linux_arm && chmod +x fast
+ cd /
+ ln -sf /usrdata/root/bin/fast /bin
+ remount_ro
+ echo -e "\e[1;32mFast.com CLI (speedtest command) installed!!\e[0m"
+ echo -e "\e[1;32mTry running the command 'fast'\e[0m"
+ echo -e "\e[1;32mThe fast.com test tops out at 40Mbps on the modem\e[0m"
+ ;;
+ 11)
echo -e "\e[1;32mGoodbye!\e[0m"
break
;;
diff --git a/installentware.sh b/installentware.sh
index f1280c4..cc0532a 100644
--- a/installentware.sh
+++ b/installentware.sh
@@ -1,7 +1,8 @@
#!/bin/sh
-
+# Modified by iamromlan to set up a proper entware environment for Quectel RM5xx series m.2 modems
TYPE='generic'
#|---------|-----------------|
+#| TARGET | Quectel Modem |
#| ARCH | armv7sf-k3.2 |
#| LOADER | ld-linux.so.3 |
#| GLIBC | 2.27 |
@@ -41,7 +42,9 @@ uninstall_entware() {
systemctl daemon-reload
# Optionally, clean up any modifications to /etc/profile or other system files
- # This step depends on the specific changes made by the user or the installation script
+ # Restore original link to login binary compiled by Quectel
+ rm /bin/login
+ ln /bin/login.shadow /bin/login
echo -e '\033[32mInfo: Entware/OPKG has been uninstalled successfully.\033[0m'
}
@@ -49,6 +52,7 @@ uninstall_entware() {
# Check if /opt exists
if [ -d /opt ]; then
echo -e "\033[32mDo you want to uninstall Entware/OPKG first? It is already installed.\033[0m"
+ echo -e "\033[32mThis will also resore your login process to Quectel Stock\033[0m"
echo -e "\033[32m1) Yes\033[0m"
echo -e "\033[32m2) No\033[0m"
echo -e "\033[32m3) Cancel\033[0m"
@@ -209,6 +213,38 @@ echo -e '\033[32mInfo: Add /opt/bin & /opt/sbin to $PATH variable\033[0m'
echo -e '\033[32mInfo: Run export PATH=/opt/bin:/opt/sbin:$PATH to do it for this session only\033[0m'
echo -e '\033[32mInfo: opkg at /opt/bin will be linked to /bin but any package you install with opkg will not be automatically.\033[0m'
ln -sf /opt/bin/opkg /bin
-opkg update
+opkg update && opkg install shadow-login shadow-passwd
+ if [ "$?" -ne 0 ]; then
+ echo -e "\e[1;31mPackage installation failed. Please check your internet connection and try again.\e[0m"
+ exit 1
+ fi
+
+ # Replace the login and passwd binaries and set home for root to a writable directory
+ rm /opt/etc/shadow
+ rm /opt/etc/passwd
+ cp /etc/shadow /opt/etc/
+ cp /etc/passwd /opt/etc
+ mkdir /usrdata/root
+ mkdir /usrdata/root/bin
+ touch /usrdata/root/.profile
+ echo "# Set PATH for all shells" > /usrdata/root/.profile
+ echo "export PATH=/bin:/usr/sbin:/usr/bin:/sbin:/opt/sbin:/opt/bin:/usrdata/root/bin" >> /usrdata/root/.profile
+ chmod +x /usrdata/root/.profile
+ sed -i '1s|/home/root:/bin/sh|/usrdata/root:/bin/bash|' /opt/etc/passwd
+ rm /bin/login /usr/bin/passwd
+ ln -sf /opt/bin/login /bin
+ ln -sf /opt/bin/passwd /usr/bin/
+ echo -e "\e[1;31mPlease set your system login password.\e[0m"
+ /usr/bin/passwd
+
+ # Install basic and useful utilites
+ opkg install mc
+ ln -sf /opt/bin/mc /bin
+ opkg install htop
+ ln -sf /opt/bin/htop /bin
+ opkg install dfc
+ ln -sf /opt/bin/dfc /bin
+ opkg install lsof
+ ln -sf /opt/bin/lsof /bin
# Remount filesystem as read-only
mount -o remount,ro /
diff --git a/simpleadmin/scripts/modemstatus_parse.sh b/simpleadmin/scripts/modemstatus_parse.sh
index 234d88f..aaddf90 100644
--- a/simpleadmin/scripts/modemstatus_parse.sh
+++ b/simpleadmin/scripts/modemstatus_parse.sh
@@ -37,23 +37,40 @@ nr_bw() {
}
# Function to get the secondary LTE & NR5G bands
-# Now conditionally calls the functions to get the secondary bands
-# Only apply | sed '1d' to NR_BAND when network mode is SA
-get_secondary_bands() {
- # Extract LTE BANDs from SCC lines
- SCC_BANDS=$(echo "$OX" | grep '+QCAINFO: "SCC"' | grep -o '"LTE BAND [0-9]\+"' | tr -d '"' | sed '1d')
-
- # Extract NR5G BANDs from SCC lines
- NR_BAND=$(echo "$OX" | grep '+QCAINFO: "SCC"' | grep -o '"NR5G BAND [0-9]\+"' | tr -d '"')
-
- # Check if both SCC and NR bands are non-empty
- if [ -n "$SCC_BANDS" ] && [ -n "$NR_BAND" ]; then
- # Concatenate LTE BANDs with NR5G BANDs
- SC_BANDS="$SCC_BANDS
$NR_BAND"
- else
- # Set SC_BANDS to the non-empty variable or empty if both are empty
- SC_BANDS="${SCC_BANDS}${NR_BAND}"
+get_secondary_bands_lte() {
+ # Extract the LTE BANDs from SCC lines from /tmp/modemstatus.txt.
+ # If there are multiple bands, they will be concatenated with
tags.
+ SC_BANDS=$(grep -o '"LTE BAND [0-9]\+"' /tmp/modemstatus.txt | tr -d '"' | sed '1d' | sed ':a;N;$!ba;s/\n/
/g')
+
+ # If there are no LTE bands or NR5G bands, set SC_BANDS to empty
+ if [ -z "$SC_BANDS" ]; then
+ SC_BANDS="-"
fi
+
+}
+
+# Function to get the secondary NR5G bands for NR5G NSA
+get_secondary_bands_nsa() {
+ # Extract the NR5G NSA BANDs from SCC lines from /tmp/modemstatus.txt.
+ # If there are multiple bands, they will be concatenated with
tags.
+ SC_BANDS_NSA=$(grep -o '"NR5G BAND [0-9]\+"' /tmp/modemstatus.txt | tr -d '"' | sed ':a;N;$!ba;s/\n/
/g')
+ echo $SC_BANDS_NSA > /tmp/scbands.txt
+
+ # If there are no NR5G NSA bands, set SC_BANDS_NSA to empty
+ if [ -z "$SC_BANDS_NSA" ]; then
+ SC_BANDS_NSA="-"
+ fi
+}
+
+get_secondary_bands_sa() {
+ # Extract the NR5G SA BANDs from SCC lines from /tmp/modemstatus.txt.
+ # If there are multiple bands, they will be concatenated with
tags.
+ SC_BANDS=$(grep -o '"NR5G BAND [0-9]\+"' /tmp/modemstatus.txt | tr -d '"' | sed '1d' | sed ':a;N;$!ba;s/\n/
/g')
+
+ # If there are no NR5G SA bands, set SC_BANDS to empty
+ if [ -z "$SC_BANDS" ]; then
+ SC_BANDS="-"
+ fi
}
# Get the modem model from /tmp/modemmodel.txt and parse it
@@ -170,7 +187,7 @@ case $RAT in
else
MODE="$RAT"
fi
- get_secondary_bands
+ get_secondary_bands_lte
PCI=$(echo $QENG | cut -d, -f9)
CHANNEL=$(echo $QENG | cut -d, -f10)
LBAND=$(echo $QENG | cut -d, -f11 | grep -o "[0-9]\{1,3\}")
@@ -221,8 +238,9 @@ case $RAT in
echo "0" > /tmp/modnetwork
if [ -n "$QENG5" ]; then
QENG5=$QENG5",,"
- # Append the initial PCI value rather than overwriting it
- get_secondary_bands
+ get_secondary_bands_nsa
+ # Append the SC_BANDS_NSA to SC_BANDS with
tags
+ SC_BANDS=$SC_BANDS"
"$SC_BANDS_NSA
PCI="$PCI, "$(echo $QENG5 | cut -d, -f4)
SCHV=$(echo $QENG5 | cut -d, -f8)
SLBV=$(echo $QENG5 | cut -d, -f9) # Now correctly captures the NR band
@@ -305,9 +323,9 @@ case $RAT in
if [ -n "$QENG5" ]; then
MODE="$RAT $(echo $QENG5 | cut -d, -f4)"
PCI=$(echo $QENG5 | cut -d, -f8)
- get_secondary_bands
+ get_secondary_bands_sa
# Apply | sed '1d' to NR_BAND
- NR_BAND=$(echo $NR_BAND | sed '1d')
+ # Temporarily removed the sed command for testing
CHANNEL=$(echo $QENG5 | cut -d, -f10)
LBAND=$(echo $QENG5 | cut -d, -f11)
PC_BAND="NR5G BAND "$LBAND
diff --git a/simpleadmin/www/atcommander.html b/simpleadmin/www/atcommander.html
index 8bbe4af..401a621 100644
--- a/simpleadmin/www/atcommander.html
+++ b/simpleadmin/www/atcommander.html
@@ -9,6 +9,7 @@
+
Here are some useful commands: