Major Toolkit Update: socat and TTYd

-Both SMD11 and SMD7 are now used to create 2 separate AT command flows/streams
   -SMD11 is linked to ttyOUT
   -SMD7 is linked to ttyOUT2
-ttyOUT is intended for use with automated AT commands like the modem status parse script
-ttyOUT2 is intended for user initiated AT commands like the AT Commands page in simpleadmin or the new atcmd shell command

-Entware installation has been improved for better compatibility and smoother install.

-Added the option to try out TTYd
   -This is a web based shell console you can access via http on port 443
   -More improvements to come
This commit is contained in:
iamromulan
2024-03-17 00:10:18 -04:00
parent a2d3bc2d87
commit 7d5d9fe74f
12 changed files with 563 additions and 228 deletions

View File

@@ -1,7 +1,22 @@
# RGMII Toolkit
**ORIGINALLY FOR THE QUECTEL RM520N-GL, However, People are saying this will work on all M.2 RMxxx modems**
Software deployment Toolkit for Quectel RM5xxx series 5G modems utilizing an m.2 to RJ45 adapter (RGMII)
#### [JUMP TO HOW TO USE](#how-to-use)
**Currently:** This will install or if already installed, update or remove a Combination of [AT Telnet Daemon](https://github.com/natecarlson/quectel-rgmii-at-command-client/tree/main/at_telnet_daemon) and; [Simpleadmin](https://github.com/iamromulan/quectel-rgmii-simpleadmin). This will also allow you to set a daily reboot timer and send AT commands easily.
**Currently:** This will allow you to install or if already installed, update, remove, or modify:
- Simple Admin: A simple web interface for managing your Quectel m.2 modem through it's gateway address
- It will install socat-at-bridge: sets up ttyOUT and ttyOUT2 for AT commands. You'll be able to use the `atcmd` command as well for an interactive at command session from adb, ssh, or ttyd
- It will install simplefirewall: A simple firewall that blocks definable incoming ports and a TTL mangle option/modifier. As of now only the TTL is controllable through Simple Admin. You can edit port block options and TTL from the 3rd option in the toolkit
- Tailscale: A magic VPN for accessing Simple Admin, SSH, and ttyd on the go. The Toolkit installs the Tailscale client directly to the modem and allows you to login and configure other settings. Head over to tailscale.com to sign up for a free account and learn more.
- Schedule a Daily Reboot at a specified time
- A fix for certain modems that don't start in CFUN=1 mode
- Entware/OPKG: A package installer/manager/repo
- Run `opkg help` to see how to use it
- These packages are installable: https://bin.entware.net/armv7sf-k3.2/Packages.html
- TTYd: A shell session right from your browser
- Currently this uses port 443 but SSL/TLS is not in use (http only for now)
- Entware/OPKG is required so it will install it if it isn't installed
- This will replace the stock Quectel login and passwd binaries with ones from entware
**My goal** is for this to also include any new useful scripts or software for this modem and others that support RGMII mode.
## Screenshots
@@ -40,26 +55,25 @@ cd /tmp && wget -O RMxxx_rgmii_toolkit.sh https://raw.githubusercontent.com/iamr
> :warning: Your modem must already be connected to the internet for this to install
### Installation:
Open up the toolkit main menu and press 4 to enter the Tailscale menu
Open up the toolkit main menu and **press 4** to enter the Tailscale menu
![Toolkit](https://github.com/iamromulan/quectel-rgmii-configuration-notes/blob/main/images/tailscalemenu.png?raw=true)
**Press 1, wait for it to install. This is a very large file for the system so give it some time. Once done and it says tailscaled is started press 2 to configure it.**
**Press 1, wait for it to install. This is a very large file for the system so give it some time.**
**Once done and it says Tailscale installed successfully press 2/enter to configure it.**
![Toolkit](https://github.com/iamromulan/quectel-rgmii-configuration-notes/blob/main/images/tailscaleconfig.png?raw=true)
If you want to, enable the Tailscale Web UI on port 8088 for configuration from the browser later by **pressing 1/enter**.
To do it in the toolkit:
First time connecting you'll be given a link to login with
- Press 1 to just connect only.
- Press 2 to connect and enable SSH access (remote command line) over tailscale.
- Press 3 to reconnect with SSH off while connected with SSH on
- Press 4 to disconnect
- Press 5 to Logout
**Important**
**You will want to go to your Tailscale DNS settings at https://login.tailscale.com/admin/dns and turn on Override local DNS and add a DNS provider to avoid loosing internet connectivity on your modem.**
This happens because the Tailscale binary creates `/etc/reslov.conf` to override the modems DNS to use the one from your Tailnet instead. If you don't have a public DNS you won't be able to use the internet. I use Cloudflare and Google. I will add an option to the Toolkit to connect with DNS off later, its on the hit list.
- Press 3 to just connect only.
- Press 4 to connect and enable SSH access (remote command line) over tailscale.
- Press 5 to reconnect with SSH off while connected with SSH on
- Press 6 to disconnect
- Press 7 to Logout
That's it! From another device running tailscale you should be able to access your modem through the IP assigned to it by your tailnet. To access SSH from another device on the tailnet, open a terminal/command prompt and type
@@ -70,18 +84,13 @@ IP or Hostname being the IP or hostname assigned to it in your tailnet
## Advanced/Beta
### Entware/OPKG installation
Recently I was able to successfully install opkg, the same package manager that OpenWRT has! This was acheved through [Entware!](https://github.com/Entware/Entware/wiki)
I modified [this](https://bin.entware.net/armv7sf-k3.2/installer/generic.sh) generic installer to include a few tweaks to make it more compatible and automated for Quectel modems. In my testing I used the RM521F-GL and RM502Q-AE but it should work for others as long as you have enough space and a /usrdata mount point to work with.
#### To install Entware/OPKG
Simply run this command from adb shell or SSH shell
wget -O- https://raw.githubusercontent.com/iamromulan/quectel-rgmii-toolkit/main/installentware.sh | sh
It isn't perfect yet so here's what you gotta know about going into it
It isn't perfect yet so it goes here under Advanced/Beta for now.
Here's what you gotta know about going into it:
- After installing, the `opkg` command will work
- You can run `opkg list` to see a list of installable packages
- You can run `opkg list` to see a list of installable packages, or head over to https://bin.entware.net/armv7sf-k3.2/Packages.html
- Everything opkg does is installed to /opt
- `/opt` is actually located at `/usrdata/opt` to save space but is
mounted at `/opt`
@@ -104,11 +113,35 @@ For example, if you were to install zerotier:
Now you can run those 3 binaries from the shell anytime since they are linked in a place already part of the system path.
## Acknowledgements
Thanks to the work of [Nate Carlson](https://github.com/natecarlson) (Telnet Deamon, Original RGMII Notes), [aesthernr](https://github.com/aesthernr) (Original simpleadmin), and [rbflurry](https://github.com/rbflurry/) (Fixing simpleadmin not functioning) we can install these! The Telnet Deamon is a Telnet to AT command server. With it, you can connect with a Telenet client like PuTTY on port 5000 to the modems gateway IP (Normally 192.168.225.1) and send AT commands over Telnet! Simpleadmin is a simple web interface you'll be able to access using the modems gateway IP address. You can see some basic signal stats, send AT commands from the browser, and change your TTL directly on the modem. By default this will be on port 8080 so if you didn't change the gateway IP address you'd go to http://192.168.225.1:8080/ and you'd find what you see in the [Screenshots](#screenshots) section.
I plan to create a watchdog service for /opt/bin and /opt/sbin that will automaticly link new packages to /bin or /sbin later on in order to combat this.
Simpleadmin heavily uses the AT Command Parsing Scripts (Basically a copy with minor tweaks) of Dairyman's Rooter Source https://github.com/ofmodemsandmen/ROOterSource2203
### TTYd installation
It isn't perfect yet so it goes here under Advanced/Beta for now.
Here's what you gotta know about going into it:
- This listens on port 443 for http requests (no SSL/TLS yet)
- This will automaticly install entware and patch the login and passwd binaries with ones from entware
- It will ask you to set a password for the `root` user account
- TTYd doesn't seem to be too mobile friendly for now but I optimized it the best i could for now so it is at least usable through a smartphone browser. Hopefully the startup script can be improved even more later.
## Acknowledgements
### GitHub Users/Individuals:
Thank You to:
[Nate Carlson](https://github.com/natecarlson) for the Original Telnet Deamon/socat bridge usage and the Original RGMII Notes
[aesthernr](https://github.com/aesthernr) for creating the Original Simple Admin
[rbflurry](https://github.com/rbflurry/) for inital Simple Admin fixes
[dr-dolomite](https://github.com/dr-dolomite) for some major stat page improvements and this repos first approved external PR!
### Existing projects:
Simpleadmin heavily uses the AT Command Parsing Scripts (Basically a copy with new changes and tweaks) of Dairyman's Rooter Source https://github.com/ofmodemsandmen/ROOterSource2203
Tailscale was obtained through Tailscale's static build page. Since these modems have a 32-bit ARM processor on-board I used the arm package. https://pkgs.tailscale.com/stable/#static
Entware/opkg was obtained through [Entware's wiki](https://github.com/Entware/Entware/wiki/Alternative-install-vs-standard)
Entware/opkg was obtained through [Entware's wiki](https://github.com/Entware/Entware/wiki/Alternative-install-vs-standard) and the installer heavily modified by [iamromulan](https://github.com/iamromulan) for use with Quectel modems
TTYd was obtained from the [TTYd Project](https://github.com/tsl0922/ttyd)

View File

@@ -1,22 +1,22 @@
#!/bin/sh
# Define toolkit paths
GITUSER="iamromulan"
GITTREE="main"
TMP_DIR="/tmp"
USRDATA_DIR="/usrdata"
SOCAT_AT_DIR="/usrdata/socat-at-bridge"
SOCAT_AT_SYSD_DIR="/usrdata/socat-at-bridge/systemd_units"
SOCAT_AT_SMD7_SYSD_DIR="/usrdata/socat-at-bridge/smd7_systemd_units"
SIMPLE_ADMIN_DIR="/usrdata/simpleadmin"
SIMPLE_FIREWALL_DIR="/usrdata/simplefirewall"
SIMPLE_FIREWALL_SCRIPT="$SIMPLE_FIREWALL_DIR/simplefirewall.sh"
SIMPLE_FIREWALL_SYSTEMD_DIR="$SIMPLE_FIREWALL_DIR/systemd"
SIMPLE_FIREWALL_SERVICE="/lib/systemd/system/simplefirewall.service"
GITHUB_URL="https://github.com/iamromulan/quectel-rgmii-toolkit/archive/refs/heads/$GITTREE.zip"
GITHUB_SIMPADMIN_FULL_URL="https://github.com/iamromulan/quectel-rgmii-toolkit/archive/refs/heads/simpleadminfull.zip"
GITHUB_SIMPADMIN_NOCMD_URL="https://github.com/iamromulan/quectel-rgmii-toolkit/archive/refs/heads/simpleadminnoatcmds.zip"
GITHUB_SIMPADMIN_TTL_URL="https://github.com/iamromulan/quectel-rgmii-toolkit/archive/refs/heads/simpleadminttlonly.zip"
GITHUB_SIMPADMIN_TEST_URL="https://github.com/iamromulan/quectel-rgmii-toolkit/archive/refs/heads/simpleadmintest.zip"
GITHUB_URL="https://github.com/$GITUSER/quectel-rgmii-toolkit/archive/refs/heads/$GITTREE.zip"
GITHUB_SIMPADMIN_FULL_URL="https://github.com/$GITUSER/quectel-rgmii-toolkit/archive/refs/heads/simpleadminfull.zip"
GITHUB_SIMPADMIN_NOCMD_URL="https://github.com/$GITUSER/quectel-rgmii-toolkit/archive/refs/heads/simpleadminnoatcmds.zip"
GITHUB_SIMPADMIN_TTL_URL="https://github.com/$GITUSER/quectel-rgmii-toolkit/archive/refs/heads/simpleadminttlonly.zip"
GITHUB_SIMPADMIN_TEST_URL="https://github.com/$GITUSER/quectel-rgmii-toolkit/archive/refs/heads/simpleadmintest.zip"
TAILSCALE_DIR="/usrdata/tailscale/"
TAILSCALE_SYSD_DIR="/usrdata/tailscale/systemd"
# AT Command Script Variables and Functions
@@ -39,20 +39,19 @@ start_listening() {
}
send_at_command() {
echo -e "\e[1;32mEnter AT command (or type 'exit' to quit): \e[0m"
echo -e "\e[1;31mThis only works for basic quick responding commands!\e[0m" # Red
echo -e "\e[1;36mType 'install' to simply type atcmd in shell from now on\e[0m"
echo -e "\e[1;36mThe installed version is much better than this portable version\e[0m"
echo -e "\e[1;32mEnter AT command (or type 'exit' to quit): \e[0m"
read at_command
if [ "$at_command" = "exit" ]; then
return 1
fi
if [ "$at_command" = "install" ]; then
wget -P /usrdata https://raw.githubusercontent.com/iamromulan/quectel-rgmii-toolkit/main/atcmd
chmod +x /usrdata/atcmd
remount_rw
ln -sf /usrdata/atcmd /sbin
remount_ro
echo -e "\e[1;32mInstalled. Type atcmd from adb shell or ssh to start an AT Command session\e[0m"
install_update_at_socat
echo -e "\e[1;32mInstalled. Type atcmd from adb shell or ssh to start an AT Command session\e[0m"
return 1
fi
echo -e "${at_command}\r" > "$DEVICE_FILE"
}
@@ -73,8 +72,8 @@ wait_for_response() {
elapsed_time=$((current_time - start_time))
if [ "$elapsed_time" -ge "$TIMEOUT" ]; then
echo -e "\e[1;31mError: Response timed out.\e[0m" # Red
echo -e "\e[1;32mIf the responce takes longer than a second or 2 to repond this will not work\e[0m" # Green
echo -e "\e[1;36mA better AT command implimentation will be made soon\e[0m" # Cyan
echo -e "\e[1;32mIf the responce takes longer than a second or 2 to respond this will not work\e[0m" # Green
echo -e "\e[1;36mType install to install the better version of this that will work.\e[0m" # Cyan
return 1
fi
sleep 1
@@ -112,80 +111,83 @@ is_simple_admin_installed() {
# Function to install/update AT Socat Bridge
install_update_at_socat() {
remount_rw
mkdir "$SOCAT_AT_DIR"
cd "$SOCAT_AT_DIR"
# Stop and disable existing services/files before installing new ones
echo -e "\033[0;32mRemoving installed AT Socat Bridge services...\033[0m"
systemctl stop at-telnet-daemon > /dev/null 2>&1
systemctl disable at-telnet-daemon > /dev/null 2>&1
systemctl stop socat-smd11 > /dev/null 2>&1
systemctl stop socat-smd11-to-ttyIN > /dev/null 2>&1
systemctl stop socat-smd11-from-ttyIN > /dev/null 2>&1
systemctl stop socat-smd7 > /dev/null 2>&1
systemctl stop socat-smd7-to-ttyIN2 > /dev/null 2>&1
systemctl stop socat-smd7-to-ttyIN > /dev/null 2>&1
systemctl stop socat-smd7-from-ttyIN2 > /dev/null 2>&1
systemctl stop socat-smd7-from-ttyIN > /dev/null 2>&1
rm /lib/systemd/system/at-telnet-daemon.service > /dev/null 2>&1
rm /lib/systemd/system/socat-smd11.service > /dev/null 2>&1
rm /lib/systemd/system/socat-smd11-to-ttyIN.service > /dev/null 2>&1
rm /lib/systemd/system/socat-smd11-from-ttyIN.service > /dev/null 2>&1
rm /lib/systemd/system/socat-smd7.service > /dev/null 2>&1
rm /lib/systemd/system/socat-smd7-to-ttyIN2.service > /dev/null 2>&1
rm /lib/systemd/system/socat-smd7-to-ttyIN.service > /dev/null 2>&1
rm /lib/systemd/system/socat-smd7-from-ttyIN.service > /dev/null 2>&1
rm /lib/systemd/system/socat-smd7-from-ttyIN2.service > /dev/null 2>&1
systemctl daemon-reload > /dev/null 2>&1
rm -rf "$SOCAT_AT_DIR" > /dev/null 2>&1
# Install service units
echo -e "\033[0;32mInstalling AT Socat Bridge services...\033[0m"
mkdir $SOCAT_AT_DIR
cd $SOCAT_AT_DIR
mkdir $SOCAT_AT_SYSD_DIR
mkdir $SOCAT_AT_SMD7_SYSD_DIR
wget https://raw.githubusercontent.com/iamromulan/quectel-rgmii-toolkit/$GITTREE/socat-at-bridge/socat-armel-static
wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/socat-at-bridge/socat-armel-static
wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/socat-at-bridge/killsmd7bridge
wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/socat-at-bridge/atcmd
cd $SOCAT_AT_SYSD_DIR
wget https://raw.githubusercontent.com/iamromulan/quectel-rgmii-toolkit/$GITTREE/socat-at-bridge/systemd_units/socat-smd11.service
wget https://raw.githubusercontent.com/iamromulan/quectel-rgmii-toolkit/$GITTREE/socat-at-bridge/systemd_units/socat-smd11-from-ttyIN.service
wget https://raw.githubusercontent.com/iamromulan/quectel-rgmii-toolkit/$GITTREE/socat-at-bridge/systemd_units/socat-smd11-to-ttyIN.service
cd $SOCAT_AT_SMD7_SYSD_DIR
wget https://raw.githubusercontent.com/iamromulan/quectel-rgmii-toolkit/$GITTREE/socat-at-bridge/smd7_systemd_units/socat-smd7-from-ttyIN.service
wget https://raw.githubusercontent.com/iamromulan/quectel-rgmii-toolkit/$GITTREE/socat-at-bridge/smd7_systemd_units/socat-smd7-to-ttyIN.service
wget https://raw.githubusercontent.com/iamromulan/quectel-rgmii-toolkit/$GITTREE/socat-at-bridge/smd7_systemd_units/socat-smd7.service
wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/socat-at-bridge/systemd_units/socat-smd11.service
wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/socat-at-bridge/systemd_units/socat-smd11-from-ttyIN.service
wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/socat-at-bridge/systemd_units/socat-smd11-to-ttyIN.service
wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/socat-at-bridge/systemd_units/socat-killsmd7bridge.service
wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/socat-at-bridge/systemd_units/socat-smd7-from-ttyIN2.service
wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/socat-at-bridge/systemd_units/socat-smd7-to-ttyIN2.service
wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/socat-at-bridge/systemd_units/socat-smd7.service
# Set execute permissions
chmod +x "$SOCAT_AT_DIR"/socat-armel-static
# User prompt for selecting device
echo -e "\e[1;32mWhich device should Simpleadmin use?\e[0m"
echo -e "\e[1;32mThis will create virtual tty ports (serial ports) that will use either smd11 or smd7\e[0m"
echo -e "\e[38;5;40m1) Use smd11 (default)\e[0m"
echo -e "\e[38;5;27m2) Use smd7 (use this if another application is using smd11 already)\e[0m"
read -p "Enter your choice (1 or 2): " device_choice
# Stop and disable existing services before installing new ones
echo -e "\033[0;32mThese errors are OK, script tries to remove all first in case you are updating\033[0m"
systemctl stop at-telnet-daemon
systemctl disable at-telnet-daemon
systemctl stop socat-smd11
systemctl stop socat-smd11-to-ttyIN
systemctl stop socat-smd11-from-ttyIN
systemctl stop socat-smd7
systemctl stop socat-smd7-to-ttyIN
systemctl stop socat-smd7-from-ttyIN
rm /lib/systemd/system/at-telnet-daemon.service
rm /lib/systemd/system/socat-smd11.service
rm /lib/systemd/system/socat-smd11-to-ttyIN.service
rm /lib/systemd/system/socat-smd11-from-ttyIN.service
rm /lib/systemd/system/socat-smd7.service
rm /lib/systemd/system/socat-smd7-to-ttyIN.service
rm /lib/systemd/system/socat-smd7-from-ttyIN.service
systemctl daemon-reload
echo -e "\033[0;32mThese errors are OK, script tries to remove all first in case you are updating\033[0m"
cd $SOCAT_AT_DIR
chmod +x socat-armel-static
chmod +x killsmd7bridge
chmod +x atcmd
# Depending on the choice, copy the respective systemd unit files
case $device_choice in
2)
cp -rf $SOCAT_AT_SMD7_SYSD_DIR/*.service /lib/systemd/system
ln -sf /lib/systemd/system/socat-smd7.service /lib/systemd/system/multi-user.target.wants/
ln -sf /lib/systemd/system/socat-smd7-to-ttyIN.service /lib/systemd/system/multi-user.target.wants/
ln -sf /lib/systemd/system/socat-smd7-from-ttyIN.service /lib/systemd/system/multi-user.target.wants/
systemctl daemon-reload
systemctl start socat-smd7
sleep 2s
systemctl start socat-smd7-to-ttyIN
systemctl start socat-smd7-from-ttyIN
remount_ro
cd /
;;
1)
cp -rf $SOCAT_AT_SYSD_DIR/*.service /lib/systemd/system
ln -sf /lib/systemd/system/socat-smd11.service /lib/systemd/system/multi-user.target.wants/
ln -sf /lib/systemd/system/socat-smd11-to-ttyIN.service /lib/systemd/system/multi-user.target.wants/
ln -sf /lib/systemd/system/socat-smd11-from-ttyIN.service /lib/systemd/system/multi-user.target.wants/
systemctl daemon-reload
systemctl start socat-smd11
sleep 2s
systemctl start socat-smd11-to-ttyIN
systemctl start socat-smd11-from-ttyIN
remount_ro
cd /
;;
esac
# Link new command for AT Commands from the shell
ln -sf $SOCAT_AT_DIR/atcmd /bin
# Install service units
echo -e "\033[0;32mAdding AT Socat Bridge systemd service units...\033[0m"
cp -rf $SOCAT_AT_SYSD_DIR/*.service /lib/systemd/system
ln -sf /lib/systemd/system/socat-killsmd7bridge.service /lib/systemd/system/multi-user.target.wants/
ln -sf /lib/systemd/system/socat-smd11.service /lib/systemd/system/multi-user.target.wants/
ln -sf /lib/systemd/system/socat-smd11-to-ttyIN.service /lib/systemd/system/multi-user.target.wants/
ln -sf /lib/systemd/system/socat-smd11-from-ttyIN.service /lib/systemd/system/multi-user.target.wants/
ln -sf /lib/systemd/system/socat-smd7.service /lib/systemd/system/multi-user.target.wants/
ln -sf /lib/systemd/system/socat-smd7-to-ttyIN2.service /lib/systemd/system/multi-user.target.wants/
ln -sf /lib/systemd/system/socat-smd7-from-ttyIN2.service /lib/systemd/system/multi-user.target.wants/
systemctl daemon-reload
systemctl start socat-smd11
sleep 2s
systemctl start socat-smd11-to-ttyIN
systemctl start socat-smd11-from-ttyIN
echo -e "\033[0;32mAT Socat Bridge service online: smd11 to ttyOUT\033[0m"
systemctl start socat-killsmd7bridge
sleep 1s
systemctl start socat-smd7
sleep 2s
systemctl start socat-smd7-to-ttyIN2
systemctl start socat-smd7-from-ttyIN2
echo -e "\033[0;32mAT Socat Bridge service online: smd7 to ttyOUT2\033[0m"
remount_ro
cd /
echo -e "\033[0;32mAT Socat Bridge services Installed!\033[0m"
}
# Function to install Simple Firewall
@@ -196,13 +198,13 @@ install_simple_firewall() {
mount -o remount,rw /
mkdir -p "$SIMPLE_FIREWALL_DIR"
mkdir -p "$SIMPLE_FIREWALL_SYSTEMD_DIR"
wget -O "$SIMPLE_FIREWALL_DIR/simplefirewall.sh" https://raw.githubusercontent.com/iamromulan/quectel-rgmii-toolkit/$GITTREE/simplefirewall/simplefirewall.sh
wget -O "$SIMPLE_FIREWALL_DIR/ttl-override" https://raw.githubusercontent.com/iamromulan/quectel-rgmii-toolkit/$GITTREE/simplefirewall/ttl-override
wget -O "$SIMPLE_FIREWALL_DIR/ttlvalue" https://raw.githubusercontent.com/iamromulan/quectel-rgmii-toolkit/$GITTREE/simplefirewall/ttlvalue
wget -O "$SIMPLE_FIREWALL_DIR/simplefirewall.sh" https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/simplefirewall/simplefirewall.sh
wget -O "$SIMPLE_FIREWALL_DIR/ttl-override" https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/simplefirewall/ttl-override
wget -O "$SIMPLE_FIREWALL_DIR/ttlvalue" https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/simplefirewall/ttlvalue
chmod +x "$SIMPLE_FIREWALL_DIR/simplefirewall.sh"
chmod +x "$SIMPLE_FIREWALL_DIR/ttl-override"
wget -O "$SIMPLE_FIREWALL_SYSTEMD_DIR/simplefirewall.service" https://raw.githubusercontent.com/iamromulan/quectel-rgmii-toolkit/$GITTREE/simplefirewall/systemd/simplefirewall.service
wget -O "$SIMPLE_FIREWALL_SYSTEMD_DIR/ttl-override.service" https://raw.githubusercontent.com/iamromulan/quectel-rgmii-toolkit/$GITTREE/simplefirewall/systemd/ttl-override.service
wget -O "$SIMPLE_FIREWALL_SYSTEMD_DIR/simplefirewall.service" https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/simplefirewall/systemd/simplefirewall.service
wget -O "$SIMPLE_FIREWALL_SYSTEMD_DIR/ttl-override.service" https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/simplefirewall/systemd/ttl-override.service
cp -rf $SIMPLE_FIREWALL_SYSTEMD_DIR/* /lib/systemd/system
ln -sf "/lib/systemd/system/simplefirewall.service" "/lib/systemd/system/multi-user.target.wants/"
ln -sf "/lib/systemd/system/ttl-override.service" "/lib/systemd/system/multi-user.target.wants/"
@@ -435,31 +437,37 @@ uninstall_simpleadmin_components() {
# Uninstall socat-at-bridge
echo -e "\e[1;32mDo you want to uninstall socat-at-bridge?\e[0m"
echo -e "\e[1;31mIf you do, AT commands and the stat page will no longer work.\e[0m"
echo -e "\e[1;31mIf you do, AT commands and the stat page will no longer work. atcmd won't either.\e[0m"
echo -e "\e[1;32m1) Yes\e[0m"
echo -e "\e[1;31m2) No\e[0m"
read -p "Enter your choice (1 or 2): " choice_socat_at_bridge
if [ "$choice_socat_at_bridge" -eq 1 ]; then
echo "Uninstalling socat-at-bridge..."
systemctl stop at-telnet-daemon
systemctl stop socat-smd11
systemctl stop socat-smd11-to-ttyIN
systemctl stop socat-smd11-from-ttyIN
systemctl stop socat-smd7
systemctl stop socat-smd7-to-ttyIN
systemctl stop socat-smd7-from-ttyIN
rm -f /lib/systemd/system/socat-smd11.service
rm -f /lib/systemd/system/socat-smd11-to-ttyIN.service
rm -f /lib/systemd/system/socat-smd11-from-ttyIN.service
rm -f /lib/systemd/system/socat-smd7.service
rm -f /lib/systemd/system/socat-smd7-to-ttyIN.service
rm -f /lib/systemd/system/socat-smd7-from-ttyIN.service
rm -f /lib/systemd/system/at-telnet-daemon.service
systemctl daemon-reload
rm -rf "$SOCAT_AT_DIR"
rm -rf "/usrdata/micropython"
rm -rf "/usrdata/at-telnet"
echo "socat-at-bridge uninstalled."
echo -e "\033[0;32mRemoving installed AT Socat Bridge services...\033[0m"
systemctl stop at-telnet-daemon > /dev/null 2>&1
systemctl disable at-telnet-daemon > /dev/null 2>&1
systemctl stop socat-smd11 > /dev/null 2>&1
systemctl stop socat-smd11-to-ttyIN > /dev/null 2>&1
systemctl stop socat-smd11-from-ttyIN > /dev/null 2>&1
systemctl stop socat-smd7 > /dev/null 2>&1
systemctl stop socat-smd7-to-ttyIN2 > /dev/null 2>&1
systemctl stop socat-smd7-to-ttyIN > /dev/null 2>&1
systemctl stop socat-smd7-from-ttyIN2 > /dev/null 2>&1
systemctl stop socat-smd7-from-ttyIN > /dev/null 2>&1
rm /lib/systemd/system/at-telnet-daemon.service > /dev/null 2>&1
rm /lib/systemd/system/socat-smd11.service > /dev/null 2>&1
rm /lib/systemd/system/socat-smd11-to-ttyIN.service > /dev/null 2>&1
rm /lib/systemd/system/socat-smd11-from-ttyIN.service > /dev/null 2>&1
rm /lib/systemd/system/socat-smd7.service > /dev/null 2>&1
rm /lib/systemd/system/socat-smd7-to-ttyIN2.service > /dev/null 2>&1
rm /lib/systemd/system/socat-smd7-to-ttyIN.service > /dev/null 2>&1
rm /lib/systemd/system/socat-smd7-from-ttyIN.service > /dev/null 2>&1
rm /lib/systemd/system/socat-smd7-from-ttyIN2.service > /dev/null 2>&1
systemctl daemon-reload > /dev/null 2>&1
rm -rf "$SOCAT_AT_DIR" > /dev/null 2>&1
rm -rf "$SOCAT_AT_DIR" > /dev/null 2>&1
rm -rf "/usrdata/micropython" > /dev/null 2>&1
rm -rf "/usrdata/at-telnet" > /dev/null 2>&1
echo -e "\033[0;32mAT Socat Bridge services removed!...\033[0m"
fi
# Uninstall the rest of Simpleadmin
@@ -536,13 +544,13 @@ install_update_remove_tailscale() {
mkdir $TAILSCALE_SYSD_DIR
cd $TAILSCALE_DIR
echo "Downloading binary: /usrdata/tailscale/tailscaled"
wget https://raw.githubusercontent.com/iamromulan/quectel-rgmii-toolkit/main/tailscale/tailscaled
wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/main/tailscale/tailscaled
echo "Downloading binary: /usrdata/tailscale/tailscale"
wget https://raw.githubusercontent.com/iamromulan/quectel-rgmii-toolkit/main/tailscale/tailscale
wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/main/tailscale/tailscale
echo "Downloading systemd files..."
cd $TAILSCALE_SYSD_DIR
wget https://raw.githubusercontent.com/iamromulan/quectel-rgmii-toolkit/main/tailscale/systemd/tailscaled.service
wget https://raw.githubusercontent.com/iamromulan/quectel-rgmii-toolkit/main/tailscale/systemd/tailscaled.defaults
wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/main/tailscale/systemd/tailscaled.service
wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/main/tailscale/systemd/tailscaled.defaults
sleep 2s
echo "Setting Permissions..."
chmod +x /usrdata/tailscale/tailscaled
@@ -577,8 +585,8 @@ configure_tailscale() {
1)
remount_rw
cd /lib/systemd/system/
wget -O tailscale-webui.service https://raw.githubusercontent.com/iamromulan/quectel-rgmii-toolkit/main/tailscale/systemd/tailscale-webui.service
wget -O tailscale-webui-trigger.service https://raw.githubusercontent.com/iamromulan/quectel-rgmii-toolkit/main/tailscale/systemd/tailscale-webui-trigger.service
wget -O tailscale-webui.service https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/main/tailscale/systemd/tailscale-webui.service
wget -O tailscale-webui-trigger.service https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/main/tailscale/systemd/tailscale-webui-trigger.service
ln -sf /lib/systemd/system/tailscale-webui-trigger.service /lib/systemd/system/multi-user.target.wants/
systemctl daemon-reload
echo "Tailscale Web UI Enabled"
@@ -787,6 +795,60 @@ WantedBy=multi-user.target" > "$cfun_service_path"
fi
}
# Function for TTYd install
install_ttyd() {
echo -e "\e[1;34mStarting ttyd installation process...\e[0m"
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
if [ "$?" -ne 0 ]; then
echo -e "\e[1;31mEntware/OPKG installation failed. Please check your internet connection or the repository URL.\e[0m"
exit 1
fi
cd /
else
echo -e "\e[1;32mEntware/OPKG is already installed.\e[0m"
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
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
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 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 /etc/systemd/system/multi-user.target.wants/
# Enabling and starting ttyd service
systemctl daemon-reload
systemctl enable ttyd
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"
}
# Main menu
while true; do
echo " .%+: "
@@ -862,7 +924,8 @@ echo " :+##+. "
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[93m8) Exit\e[0m" # Yellow (repeated color for exit option)
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)
read -p "Enter your choice: " choice
case $choice in
@@ -900,10 +963,13 @@ echo " :+##+. "
;;
7)
echo -e "\e[1;32mInstalling Entware/OPKG\e[0m"
wget -O- https://raw.githubusercontent.com/iamromulan/quectel-rgmii-toolkit/main/installentware.sh | sh
break
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)
8)
install_ttyd
;;
9)
echo -e "\e[1;32mGoodbye!\e[0m"
break
;;

View File

@@ -1,52 +1,167 @@
#!/bin/sh
TYPE='generic'
#TYPE='alternative'
#|---------|-----------------------|---------------|---------------|---------------------|-------------------|-------------------|----------------------|-------------------|
#| ARCH | aarch64-k3.10 | armv5sf-k3.2 | armv7sf-k2.6 | armv7sf-k3.2 | mipselsf-k3.4 | mipssf-k3.4 | x64-k3.2 | x86-k2.6 |
#| LOADER | ld-linux-aarch64.so.1 | ld-linux.so.3 | ld-linux.so.3 | ld-linux.so.3 | ld.so.1 | ld.so.1 | ld-linux-x86-64.so.2 | ld-linux.so.2 |
#| GLIBC | 2.27 | 2.27 | 2.23 | 2.27 | 2.27 | 2.27 | 2.27 | 2.23 |
#|---------|-----------------------|---------------|---------------|---------------------|-------------------|-------------------|----------------------|-------------------|
#|---------|-----------------|
#| ARCH | armv7sf-k3.2 |
#| LOADER | ld-linux.so.3 |
#| GLIBC | 2.27 |
#|---------|-----------------|
unset LD_LIBRARY_PATH
unset LD_PRELOAD
ARCH=armv7sf-k3.2
LOADER=ld-linux.so.3
GLIBC=2.27
PRE_OPKG_PATH=$(which opkg)
# Remount filesystem as read-write
mount -o remount,rw /
echo 'Info: Checking for prerequisites and creating folders...'
uninstall_entware() {
echo -e '\033[31mInfo: Starting Entware/OPKG uninstallation...\033[0m'
# Stop services
systemctl stop rc.unslung.service
/opt/etc/init.d/rc.unslung stop
rm /lib/systemd/system/multi-user.target.wants/rc.unslung.service
rm /lib/systemd/system/rc.unslung.service
systemctl stop opt.mount
rm /lib/systemd/system/multi-user.target.wants/start-opt-mount.service
rm /lib/systemd/system/opt.mount
rm /lib/systemd/system/start-opt-mount.service
# Unmount /opt if mounted
mountpoint -q /opt && umount /opt
# Remove Entware installation directory
rm -rf /usrdata/opt
rm -rf /opt
# Reload systemctl daemon
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
echo -e '\033[32mInfo: Entware/OPKG has been uninstalled successfully.\033[0m'
}
# Check if /opt exists
if [ -d /opt ]; then
echo 'Warning: Folder /opt exists!'
else
mkdir /opt
echo -e "\033[32mDo you want to uninstall Entware/OPKG first? It is already installed.\033[0m"
echo -e "\033[32m1) Yes\033[0m"
echo -e "\033[32m2) No\033[0m"
echo -e "\033[32m3) Cancel\033[0m"
read -p "Select an option: " choice
case $choice in
1)
# Call the uninstall function
uninstall_entware
exit 0
;;
2)
# Continue with the script
echo "Continuing with the script..."
;;
3)
echo "Canceling. Exiting script."
exit 0
;;
*)
echo "Invalid option. Please select 1, 2, or 3."
;;
esac
fi
create_opt_mount() {
# Bind /usrdata/opt to /opt
echo -e '\033[32mInfo: Setting up /opt mount to /usrdata/opt...\033[0m'
cat <<EOF > /lib/systemd/system/opt.mount
[Unit]
Description=Bind /usrdata/opt to /opt
[Mount]
What=/usrdata/opt
Where=/opt
Type=none
Options=bind
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl start opt.mount
# Additional systemd service to ensure opt.mount starts at boot
echo -e '\033[32mInfo: Creating service to start opt.mount at boot...\033[0m'
cat <<EOF > /lib/systemd/system/start-opt-mount.service
[Unit]
Description=Ensure opt.mount is started at boot
After=network.target
[Service]
Type=oneshot
ExecStart=/bin/systemctl start opt.mount
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
ln -s /lib/systemd/system/start-opt-mount.service /lib/systemd/system/multi-user.target.wants/start-opt-mount.service
}
if [ -n "$PRE_OPKG_PATH" ]; then
while true; do
echo -e "\033[32mopkg already exists at: $PRE_OPKG_PATH\033[0m"
echo -e "\033[32mDo you want to rename it to opkg_old?\033[0m"
echo -e "\033[32m1) Yes (Highly Recommended)\033[0m"
echo -e "\033[32m2) No (The opkg command may not work)\033[0m"
read -p "Select an option (1 or 2): " user_choice
case $user_choice in
1)
mv "$PRE_OPKG_PATH" "${PRE_OPKG_PATH}_old"
echo "Factory/Already existing opkg has been renamed to opkg_old."
break
;;
2)
echo "Proceeding without renaming opkg."
break
;;
*)
echo "Invalid option. Please select 1 or 2."
;;
esac
done
else
echo "Info: no existing opkg binary detected, proceeding with installation"
fi
echo -e '\033[32mInfo: Creating /opt mount pointed to /usrdata/opt ...\033[0m'
create_opt_mount
echo -e '\033[32mInfo: Proceeding with main installation ...\033[0m'
# no need to create many folders. entware-opt package creates most
for folder in bin etc lib/opkg tmp var/lock
do
if [ -d "/opt/$folder" ]; then
echo "Warning: Folder /opt/$folder exists!"
echo 'Warning: If something goes wrong please clean /opt folder and try again.'
echo -e '\033[31mWarning: Folder /opt/$folder exists!\033[0m'
echo -e '\033[31mWarning: If something goes wrong please clean /opt folder and try again.\033[0m'
else
mkdir -p /opt/$folder
fi
done
echo 'Info: Opkg package manager deployment...'
echo -e '\033[32mInfo: Opkg package manager deployment...\033[0m'
URL=http://bin.entware.net/${ARCH}/installer
wget $URL/opkg -O /opt/bin/opkg
chmod 755 /opt/bin/opkg
wget $URL/opkg.conf -O /opt/etc/opkg.conf
echo 'Info: Basic packages installation...'
echo -e '\033[32mInfo: Basic packages installation...\033[0m'
/opt/bin/opkg update
if [ $TYPE = 'alternative' ]; then
/opt/bin/opkg install busybox
fi
/opt/bin/opkg install entware-opt
# Fix for multiuser environment
@@ -68,57 +183,8 @@ done
[ -f /etc/localtime ] && ln -sf /etc/localtime /opt/etc/localtime
# Move /opt to /usrdata/opt after installation
echo 'Info: Moving Entware to /usrdata/opt...'
mkdir -p /usrdata/opt
mv /opt/* /usrdata/opt/
# Bind /usrdata/opt to /opt
echo 'Info: Setting up /opt mount to /usrdata/opt...'
cat <<EOF > /lib/systemd/system/opt.mount
[Unit]
Description=Bind /usrdata/opt to /opt
[Mount]
What=/usrdata/opt
Where=/opt
Type=none
Options=bind
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl start opt.mount
# Additional systemd service to ensure opt.mount starts at boot
echo 'Info: Creating service to start opt.mount at boot...'
cat <<EOF > /lib/systemd/system/start-opt-mount.service
[Unit]
Description=Ensure opt.mount is started at boot
After=network.target
[Service]
Type=oneshot
ExecStart=/bin/systemctl start opt.mount
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
ln -s /lib/systemd/system/start-opt-mount.service /lib/systemd/system/multi-user.target.wants/start-opt-mount.service
# Update /etc/profile for PATH
echo 'Info: Updating /etc/profile for PATH...'
export PATH=/usrdata/opt/bin:/usrdata/opt/sbin:$PATH
echo 'Info: This is only temporary, you will need to do this for each shell session...'
echo 'Info: Run export PATH=/usrdata/opt/bin:/usrdata/opt/sbin:$PATH to do it'
# Create and enable rc.unslung service
echo 'Info: Creating rc.unslung service...'
echo -e '\033[32mInfo: Creating rc.unslung (Entware init.d service)...\033[0m'
cat <<EOF > /lib/systemd/system/rc.unslung.service
[Unit]
Description=Start Entware services
@@ -137,11 +203,11 @@ EOF
systemctl daemon-reload
ln -s /lib/systemd/system/rc.unslung.service /lib/systemd/system/multi-user.target.wants/rc.unslung.service
systemctl start rc.unslung.service
echo 'Info: Congratulations!'
echo 'Info: If there are no errors above then Entware was successfully initialized.'
echo 'Info: Add /opt/bin & /opt/sbin to $PATH variable'
echo 'Info: Run export PATH=/opt/bin:/opt/sbin:$PATH to do it for this session only'
echo 'Info: opkg at /opt/bin will be linked to /bin but any package you install with opkg will not be automatically.'
echo -e '\033[32mInfo: Congratulations!\033[0m'
echo -e '\033[32mInfo: If there are no errors above then Entware was successfully initialized.\033[0m'
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
# Remount filesystem as read-only

View File

@@ -20,7 +20,7 @@ fi
MYATCMD=$(printf '%b\n' "${atcmd//%/\\x}")
if [ -n "${MYATCMD}" ]; then
x=$(urldecode "$atcmd")
runcmd=$(echo -en "$x\r\n" | microcom -t 2000 /dev/ttyOUT)
runcmd=$(echo -en "$x\r\n" | microcom -t 2000 /dev/ttyOUT2)
fi
echo "Content-type: text/plain"

55
socat-at-bridge/atcmd Normal file
View File

@@ -0,0 +1,55 @@
#!/bin/bash
DEVICE=/dev/ttyOUT2
BAUD=115200
# Function to setup device communication parameters
setup_device() {
stty -F $DEVICE cs8 $BAUD ignbrk -brkint -icrnl -imaxbel \
-opost -onlcr -isig -icanon -iexten -echo -echoe -echok \
-echoctl -echoke noflsh -ixon -crtscts
}
# Prepare the device for communication
setup_device
echo -e "\033[0;36mType 'exit' to end the session.\033[0m"
while true; do
echo -en "\033[0;36mEnter AT Command: \033[0m"
read user_input
if [[ "$user_input" == "exit" ]]; then
echo -e "\033[0;32mExiting...\033[0m"
break
fi
# Clear the device buffer before sending a new command
echo -n > $DEVICE
# Send the AT command
echo -e "$user_input\r" > $DEVICE
# Use a temporary file to capture the command output
tmpfile=$(mktemp)
# Start reading the device output to the temporary file
cat $DEVICE > "$tmpfile" &
CAT_PID=$!
# Monitor the output file for "OK" or "ERROR"
while ! grep -qe "OK" -e "ERROR" "$tmpfile"; do
sleep 1
done
# Kill the `cat` process after capturing the response
kill $CAT_PID
wait $CAT_PID 2>/dev/null
# Display the response
cat "$tmpfile" | while IFS= read -r line; do
echo -e "\033[0;32m$line\033[0m"
done
# Clean up
rm "$tmpfile"
done

View File

@@ -0,0 +1,4 @@
#!/bin/bash
# Look for the process by its command and kill it so socat can have smd7 instead
pkill -f "/usr/bin/port_bridge smd7 at_usb2 1"

View File

@@ -0,0 +1,9 @@
[Unit]
Description=Kill port_bridge process on boot
[Service]
Type=oneshot
ExecStart=/usrdata/socat-at-bridge/killsmd7bridge
[Install]
WantedBy=multi-user.target

View File

@@ -1,10 +1,10 @@
[Unit]
Description=Read from /dev/ttyIN and write to smd7
Description=Read from /dev/ttyIN2 and write to smd7
BindsTo=socat-smd7.service
After=socat-smd7.service
[Service]
ExecStart=/bin/bash -c "/bin/cat /dev/ttyIN > /dev/smd7"
ExecStart=/bin/bash -c "/bin/cat /dev/ttyIN2 > /dev/smd7"
ExecStartPost=/bin/sleep 2s
StandardInput=tty-force
Restart=always

View File

@@ -1,10 +1,10 @@
[Unit]
Description=Read from /dev/smd7 and write to ttyIN
Description=Read from /dev/smd7 and write to ttyIN2
BindsTo=socat-smd7.service
After=socat-smd7.service
[Service]
ExecStart=/bin/bash -c "/bin/cat /dev/smd7 > /dev/ttyIN"
ExecStart=/bin/bash -c "/bin/cat /dev/smd7 > /dev/ttyIN2"
ExecStartPost=/bin/sleep 2s
StandardInput=tty-force
Restart=always

View File

@@ -3,7 +3,7 @@ Description=Socat Serial Emulation for smd7
After=ql-netd.service
[Service]
ExecStart=/usrdata/socat-at-bridge/socat-armel-static -d -d pty,link=/dev/ttyIN,raw,echo=0 pty,link=/dev/ttyOUT,raw,echo=1
ExecStart=/usrdata/socat-at-bridge/socat-armel-static -d -d pty,link=/dev/ttyIN2,raw,echo=0 pty,link=/dev/ttyOUT2,raw,echo=1
# Add a delay to prevent the clients from starting too early
ExecStartPost=/bin/sleep 2s
Restart=always

90
ttyd/scripts/ttyd.bash Normal file
View File

@@ -0,0 +1,90 @@
#!/bin/bash
# Read the serial number and remove the last two digits
serial_number=$(cat /sys/devices/soc0/serial_number | sed 's/..$//')
echo "=============================================================="
echo "=============================================================="
echo "=============================================================="
echo "=============================================================="
echo "=============================================================="
echo "=============================================================="
echo "=============================================================="
echo "=============================================================="
echo "=============================================================="
echo "=============================================================="
echo "=============================================================="
echo "=============================================================="
echo "=============================================================="
echo "=============================================================="
echo "=============================================================="
echo "=============================================================="
echo "=============================================================="
# Start your Actual echo output here, 17 lines omitted for mobile compatibility. ttyd font needs to be size 25.
# Echo "Logo"
echo " .%+: "
echo " .*@@@-. "
echo " :@@@@- "
echo " @@@@#. "
echo " -@@@@#. "
echo " :. %@@@@: -# "
echo " .+- #@@@@%.+@- "
echo " .#- . +@@@@# #@- "
echo " -@*@*@% @@@@@::@@= "
echo ".+%@@@@@@@@@%=. =@@@@# #@@- .. "
echo " .@@@@@: :@@@@@ =@@@..%= "
echo " -::@-.+. @@@@@.=@@@- =@- "
echo " .@- .@@@@@:.@@@* @@. "
echo " .%- -@@@@@:=@@@@ @@# "
echo " .#- .%@@@@@@#. +@@@@@.#@@@@ @@@."
echo " .*- .@@@@@@@@@@=. @@@@@@ @@@@@ @@@:"
echo " :. .%@@@@@@@@@@@%. .@@@@@+:@@@@@ @@@-"
echo " -@@@@@@@@@@@@@@@..@@@@@@.-@@@@@ .@@@-"
echo " -@@@@@@@@@@%. .@@@@@@. @@@@@+ =@@@="
echo " =@@@@@@@@* .@@@@@@. @@@@@@..@@@@-"
echo " #@@@@@@@@-*@@@@@%..@@@@@@+ #@@@@-"
echo " @@@@@@:.-@@@@@@. @@@@@@= %@@@@@."
echo " .@@@@. *@@@@@@- .+@@@@@@-.@@@@@@+ "
echo " %@@. =@@@@@*. +@@@@@@%.-@@@@@@% "
echo " .@@ .@@@@@= :@@@@@@@@..@@@@@@@= "
echo " =@.+@@@@@. -@@@@@@@*.:@@@@@@@*. "
echo " %.*@@@@= .@@@@@@@-.:@@@@@@@+. "
echo " ..@@@@= .@@@@@@: #@@@@@@@: "
echo " .@@@@ +@@@@..%@@@@@+. "
echo " .@@@. @@@@.:@@@@+. "
echo " @@@. @@@. @@@* .@. "
echo " :@@@ %@@..@@#. *@ "
echo " -*: .@@* :@@. @@. -..@@ "
echo " =@@@@@@.*@- :@% @* =@:=@# "
echo " .@@@-+@@@@:%@..%- ...@%:@@: "
echo " .@@. @@-%@: .%@@*@@%. "
echo " :@@ :+ *@ *@@#*@@@. "
echo " =@@@.@@@@ "
echo " .*@@@:=@@@@: "
echo " .@@@@:.@@@@@: "
echo " .@@@@#.-@@@@@. "
echo " #@@@@: =@@@@@- "
echo " .@@@@@..@@@@@@* "
echo " -@@@@@. @@@@@@#. "
echo " -@@@@@ @@@@@@% "
echo " @@@@@. #@@@@@@. "
echo " :@@@@# =@@@@@@% "
echo " @@@@@: @@@@@@@: "
echo " *@@@@ @@@@@@@. "
echo " .@@@@ @@@@@@@ "
echo " #@@@. @@@@@@* "
echo " @@@# @@@@@@@ "
echo " .@@+=@@@@@@. "
echo " *@@@@@@ "
echo " :@@@@@= "
echo " .@@@@@@. "
echo " :@@@@@*. "
echo " .=@@@@@- "
echo " :+##+. "
echo "=============================================================="
echo "Test ttyd startup file by iamromulan V0.1"
echo "quectel-ID: $serial_number"
echo "=============================================================="
# Start a login session
exec /bin/login

12
ttyd/systemd/ttyd.service Normal file
View File

@@ -0,0 +1,12 @@
[Unit]
Description=TTYD Service
After=network.target
[Service]
Type=simple
ExecStartPre=/bin/sleep 5
ExecStart=/usrdata/ttyd/ttyd -p 443 -t 'theme={"foreground":"white","background":"black"}' -t fontSize=25 --writable /usrdata/ttyd/scripts/ttyd.bash
Restart=on-failure
[Install]
WantedBy=multi-user.target