From 05c387d539e2cef09116a1ac3eb0325c6d679345 Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Sun, 7 Apr 2024 01:46:29 +0000 Subject: [PATCH 01/14] First WIP of rework to lighttpd --- RMxxx_rgmii_toolkit.sh | 20 ++++++++------ lighttpd/README.md | 7 +++++ lighttpd/gencert.sh | 4 +++ lighttpd/lighttpd.conf | 47 ++++++++++++++++++++++++++++++++ lighttpd/lighttpd.service | 14 ++++++++++ simplefirewall/simplefirewall.sh | 2 +- sshd/README.md | 10 +++++++ sshd/sshd.service | 20 ++++++++++++++ ttyd/systemd/ttyd.service | 2 +- 9 files changed, 116 insertions(+), 10 deletions(-) create mode 100644 lighttpd/README.md create mode 100644 lighttpd/gencert.sh create mode 100644 lighttpd/lighttpd.conf create mode 100644 lighttpd/lighttpd.service create mode 100644 sshd/README.md create mode 100644 sshd/sshd.service diff --git a/RMxxx_rgmii_toolkit.sh b/RMxxx_rgmii_toolkit.sh index 51bff03..ed22bc1 100644 --- a/RMxxx_rgmii_toolkit.sh +++ b/RMxxx_rgmii_toolkit.sh @@ -302,6 +302,18 @@ configure_simple_firewall() { # Function to install/update Simple Admin install_simple_admin() { + # 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 + 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 while true; do echo -e "\e[1;32mWhat version of Simple Admin do you want to install? This will start a webserver on port 8080\e[0m" echo -e "\e[1;32m1) Stable current version, (Main Branch)\e[0m" @@ -328,7 +340,6 @@ install_simple_admin() { mkdir $SIMPLE_ADMIN_DIR/www/js cd $SIMPLE_ADMIN_DIR/systemd wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/main/simpleadmin/systemd/simpleadmin_generate_status.service - wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/main/simpleadmin/systemd/simpleadmin_httpd.service sleep 1 cd $SIMPLE_ADMIN_DIR/scripts wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/main/simpleadmin/scripts/build_modem_status @@ -361,11 +372,9 @@ install_simple_admin() { cp -rf $SIMPLE_ADMIN_DIR/systemd/* /lib/systemd/system systemctl daemon-reload sleep 1 - ln -sf /lib/systemd/system/simpleadmin_httpd.service /lib/systemd/system/multi-user.target.wants/ ln -sf /lib/systemd/system/simpleadmin_generate_status.service /lib/systemd/system/multi-user.target.wants/ systemctl start simpleadmin_generate_status sleep 1 - systemctl start simpleadmin_httpd remount_ro echo -e "\e[1;32msimpleadmin has been installed and is now ready for use!\e[0m" break @@ -387,7 +396,6 @@ install_simple_admin() { mkdir $SIMPLE_ADMIN_DIR/www/js cd $SIMPLE_ADMIN_DIR/systemd wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/development/simpleadmin/systemd/simpleadmin_generate_status.service - wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/development/simpleadmin/systemd/simpleadmin_httpd.service sleep 1 cd $SIMPLE_ADMIN_DIR/scripts wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/development/simpleadmin/scripts/build_modem_status @@ -422,11 +430,9 @@ install_simple_admin() { cp -rf $SIMPLE_ADMIN_DIR/systemd/* /lib/systemd/system systemctl daemon-reload sleep 1 - ln -sf /lib/systemd/system/simpleadmin_httpd.service /lib/systemd/system/multi-user.target.wants/ ln -sf /lib/systemd/system/simpleadmin_generate_status.service /lib/systemd/system/multi-user.target.wants/ systemctl start simpleadmin_generate_status sleep 1 - systemctl start simpleadmin_httpd remount_ro echo -e "\e[1;32msimpleadmin has been installed and is now ready for use!\e[0m" break @@ -508,9 +514,7 @@ uninstall_simpleadmin_components() { read -p "Enter your choice (1 or 2): " choice_simpleadmin if [ "$choice_simpleadmin" -eq 1 ]; then echo "Uninstalling the rest of Simpleadmin..." - systemctl stop simpleadmin_httpd systemctl stop simpleadmin_generate_status - rm -f /lib/systemd/system/simpleadmin_httpd.service rm -f /lib/systemd/system/simpleadmin_generate_status.service systemctl daemon-reload rm -rf "$SIMPLE_ADMIN_DIR" diff --git a/lighttpd/README.md b/lighttpd/README.md new file mode 100644 index 0000000..85017ea --- /dev/null +++ b/lighttpd/README.md @@ -0,0 +1,7 @@ +lighttpd +lighttpd-mod-auth +lighttpd-mod-authn_file +lighttpd-mod-cgi +lighttpd-mod-openssl +lighttpd-mod-proxy +printf "USER:$(openssl passwd -crypt PASSWORD)\n" >> .htpasswd diff --git a/lighttpd/gencert.sh b/lighttpd/gencert.sh new file mode 100644 index 0000000..a98208e --- /dev/null +++ b/lighttpd/gencert.sh @@ -0,0 +1,4 @@ +#!/bin/bash +openssl req -new -newkey rsa:2048 -days 3650 -nodes -x509 \ + -subj "/C=US/ST=MI/L=Romulus/O=RMIITools/CN=localhost" \ + -keyout server.key -out server.crt diff --git a/lighttpd/lighttpd.conf b/lighttpd/lighttpd.conf new file mode 100644 index 0000000..6487a6e --- /dev/null +++ b/lighttpd/lighttpd.conf @@ -0,0 +1,47 @@ +server.modules = ( + "mod_redirect", + "mod_cgi", + "mod_proxy", + "mod_openssl", + "mod_authn_file", +) + +server.username = "nobody" +server.groupname = "nogroup" + +server.port = 80 +server.document-root = "/usrdata/simpleadmin/www" +index-file.names = ( "index.html" ) + +auth.backend = "htpasswd" +auth.backend.htpasswd.userfile = "/usrdata/lighttpd/.htpasswd" + +$SERVER["socket"] == "0.0.0.0:443" { + ssl.engine = "enable" + ssl.privkey= "/usrdata/lighttpd/server.key" + ssl.pemfile= "/usrdata/lighttpd/server.crt" + ssl.acme-tls-1 = "/etc/lighttpd/dehydrated/tls-alpn-01" + ssl.openssl.ssl-conf-cmd = ("MinProtocol" => "TLSv1.2") # (lighttpd 1.4.56 default; recommended to accept only TLSv1.2 and TLSv1.3) + auth.require = ( "/" => ( + "method" => "basic", + "realm" => "Authorized users only", + "require" => "valid-user" + ) + ) +} + +# Redirect everything to https +$HTTP["scheme"] == "http" { + url.redirect = ("" => "https://${url.authority}${url.path}${qsa}") +} + +# Anything in /cgi-bin will be run as a script +$HTTP["url"] =~ "/cgi-bin/" { + cgi.assign = ( "" => "" ) +} + +# Handle proxy to ttyd if it's running +$HTTP["url"] =~ "(^/ttyd)" { + proxy.header = ("map-urlpath" => ( "/ttyd" => "/" ), "upgrade" => "enable" ) + proxy.server = ( "" => ("" => ( "host" => "127.0.0.1", "port" => 8443 ))) +} diff --git a/lighttpd/lighttpd.service b/lighttpd/lighttpd.service new file mode 100644 index 0000000..a40c389 --- /dev/null +++ b/lighttpd/lighttpd.service @@ -0,0 +1,14 @@ +[Unit] +Description=Lighttpd Daemon +After=network.target + +[Service] +Type=simple +PIDFile=/opt/var/run/lighttpd.pid +ExecStartPre=/opt/sbin/lighttpd -tt -f /usrdata/lighttpd/lighttpd.conf +ExecStart=/opt/sbin/lighttpd -D -f /usrdata/lighttpd/lighttpd.conf +ExecReload=/bin/kill -USR1 $MAINPID +Restart=on-failure + +[Install] +WantedBy=multi-user.target diff --git a/simplefirewall/simplefirewall.sh b/simplefirewall/simplefirewall.sh index 47394bc..f208465 100644 --- a/simplefirewall/simplefirewall.sh +++ b/simplefirewall/simplefirewall.sh @@ -1,7 +1,7 @@ #!/bin/bash # Define the ports you want to block -PORTS=("80" "8080" "8088" "443") # Default ports, will be modified by the install script +PORTS=("80" "443") # Default ports, will be modified by the install script # First, allow specified ports on bridge0, eth0, and tailscale0 for port in "${PORTS[@]}"; do diff --git a/sshd/README.md b/sshd/README.md new file mode 100644 index 0000000..64656a0 --- /dev/null +++ b/sshd/README.md @@ -0,0 +1,10 @@ +# Generate Host Keys +ssh-keygen -A + +# Must edit in /opt/etc/ssh/sshd_config +PasswordAuthentication yes +UsePAM yes +PermitRootLogin yes + +# Need to add ssh user in /opt/etc/passwd +sshd:x:106:65534:Linux User,,,:/opt/run/sshd:/bin/nologin diff --git a/sshd/sshd.service b/sshd/sshd.service new file mode 100644 index 0000000..799bd33 --- /dev/null +++ b/sshd/sshd.service @@ -0,0 +1,20 @@ +[Unit] +Description=OpenBSD Secure Shell server +Documentation=man:sshd(8) man:sshd_config(5) +After=network.target + +[Service] +ExecStartPre=/opt/usr/sbin/sshd -t +ExecStart=/opt/usr/sbin/sshd -D +ExecReload=/opt/usr/sbin/sshd -t +ExecReload=/bin/kill -HUP $MAINPID +KillMode=process +Restart=on-failure +RestartPreventExitStatus=255 +Type=notify +RuntimeDirectory=sshd +RuntimeDirectoryMode=0755 + +[Install] +WantedBy=multi-user.target +Alias=sshd.service diff --git a/ttyd/systemd/ttyd.service b/ttyd/systemd/ttyd.service index 36280b8..225fd68 100644 --- a/ttyd/systemd/ttyd.service +++ b/ttyd/systemd/ttyd.service @@ -5,7 +5,7 @@ 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 +ExecStart=/usrdata/ttyd/ttyd -i 127.0.0.1 -p 8088 -t 'theme={"foreground":"white","background":"black"}' -t fontSize=25 --writable /usrdata/ttyd/scripts/ttyd.bash Restart=on-failure [Install] From c82d9496a779f56c497a2c7fe70b1c72162bac4c Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Tue, 9 Apr 2024 02:03:26 +0000 Subject: [PATCH 02/14] Made a few changes to lighttpd --- RMxxx_rgmii_toolkit.sh | 109 +++++++++++++++++++++++------------------ installentware.sh | 30 ++---------- 2 files changed, 66 insertions(+), 73 deletions(-) diff --git a/RMxxx_rgmii_toolkit.sh b/RMxxx_rgmii_toolkit.sh index ed22bc1..10fdd06 100644 --- a/RMxxx_rgmii_toolkit.sh +++ b/RMxxx_rgmii_toolkit.sh @@ -1,12 +1,15 @@ #!/bin/sh # Define toolkit paths -GITUSER="iamromulan" -GITTREE="development" +GITUSER="snowzach" +GITTREE="lighttpd" +# GITUSER="iamromulan" +# GITTREE="development" TMP_DIR="/tmp" USRDATA_DIR="/usrdata" SOCAT_AT_DIR="/usrdata/socat-at-bridge" SOCAT_AT_SYSD_DIR="/usrdata/socat-at-bridge/systemd_units" +LIGHTTPD_DIR="/usrdata/lighttpd" SIMPLE_ADMIN_DIR="/usrdata/simpleadmin" SIMPLE_FIREWALL_DIR="/usrdata/simplefirewall" SIMPLE_FIREWALL_SCRIPT="$SIMPLE_FIREWALL_DIR/simplefirewall.sh" @@ -97,6 +100,21 @@ send_at_commands() { fi } +# Check for existing Entware/opkg installation, install if not installed +ensure_entware_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 + 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 +} + # Check if Simple Admin is installed is_simple_admin_installed() { [ -d "$SIMPLE_ADMIN_DIR" ] && return 0 || return 1 @@ -300,20 +318,38 @@ configure_simple_firewall() { echo -e "\e[1;32mFirewall configuration updated.\e[0m" } +# Function to install Lighttpd +install_lighttpd() { + ensure_entware_installed + + /opt/bin/opkg install lighttpd lighttpd-mod-auth lighttpd-mod-authn_file lighttpd-mod-cgi lighttpd-mod-openssl lighttpd-mod-proxy + + systemctl stop lighttpd + echo -e "\033[0;32mInstalling/Updating Lighttpd...\033[0m" + mount -o remount,rw / + mkdir -p "$LIGHTTPD_DIR" + wget -O "$LIGHTTPD_DIR/lighttpd.conf" https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/lighttpd/lighttpd.conf + wget -O "$LIGHTTPD_DIR/lighttpd.service" https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/lighttpd/lighttpd.service + ln -sf "$LIGHTTPD_DIR/lighttpd.service" "/lib/systemd/system/lighttpd.service" + openssl req -new -newkey rsa:2048 -days 3650 -nodes -x509 \ + -subj "/C=US/ST=MI/L=Romulus/O=RMIITools/CN=localhost" \ + -keyout $LIGHTTPD_DIR/server.key -out $LIGHTTPD_DIR/server.crt + systemctl daemon-reload + systemctl enable lighttpd + systemctl start lighttpd + remount_ro + echo -e "\033[0;32mSimple Firewall installation/update complete.\033[0m" + + echo -e "\e[1;31mPlease set your system login password.\e[0m" + #printf "USER:$(openssl passwd -crypt PASSWORD)\n" >> .htpasswd +} + + # Function to install/update Simple Admin install_simple_admin() { - # 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 - 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 + + install_lighttpd + while true; do echo -e "\e[1;32mWhat version of Simple Admin do you want to install? This will start a webserver on port 8080\e[0m" echo -e "\e[1;32m1) Stable current version, (Main Branch)\e[0m" @@ -836,18 +872,8 @@ WantedBy=multi-user.target" > "$cfun_service_path" 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 - 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 + + ensure_entware_installed mount -o remount,rw / @@ -1020,34 +1046,21 @@ echo " :+##+. " 4) tailscale_menu - ;; + ;; 5) - manage_reboot_timer + manage_reboot_timer ;; 6) - manage_cfun_fix + manage_cfun_fix ;; - 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 / + 7) + ensure_entware_installed ;; 8) install_ttyd - ;; + ;; 9) - echo -e "\e[1;32mInstalling Speedtest.net CLI (speedtest command)\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 - 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 + ensure_entware_installed echo -e "\e[1;32mInstalling Speedtest.net CLI (speedtest command)\e[0m" remount_rw mkdir /usrdata/root @@ -1084,8 +1097,8 @@ echo " :+##+. " echo -e "\e[1;32mGoodbye!\e[0m" break ;; - *) - echo -e "\e[1;31mInvalid option\e[0m" + *) + echo -e "\e[1;31mInvalid option\e[0m" ;; esac done diff --git a/installentware.sh b/installentware.sh index cc0532a..638c684 100644 --- a/installentware.sh +++ b/installentware.sh @@ -92,29 +92,12 @@ Type=none Options=bind [Install] -WantedBy=multi-user.target +WantedBy=local-fs.target EOF systemctl daemon-reload + systemctl enable opt.mount 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 < /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 @@ -222,8 +205,8 @@ opkg update && opkg install shadow-login shadow-passwd # 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 + ln -s /etc/shadow /opt/etc/ + ln -s /etc/passwd /opt/etc mkdir /usrdata/root mkdir /usrdata/root/bin touch /usrdata/root/.profile @@ -239,12 +222,9 @@ opkg update && opkg install shadow-login shadow-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 / From 74790da711ed0d1391893a2280c6cdfc97517584 Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Tue, 9 Apr 2024 15:48:46 +0000 Subject: [PATCH 03/14] SSH updates --- RMxxx_rgmii_toolkit.sh | 60 +++++++++++++++++++++++++++++------------- installentware.sh | 14 +++++----- sshd/sshd.service | 6 ++--- 3 files changed, 52 insertions(+), 28 deletions(-) diff --git a/RMxxx_rgmii_toolkit.sh b/RMxxx_rgmii_toolkit.sh index 10fdd06..b03ae9a 100644 --- a/RMxxx_rgmii_toolkit.sh +++ b/RMxxx_rgmii_toolkit.sh @@ -431,34 +431,34 @@ install_simple_admin() { mkdir $SIMPLE_ADMIN_DIR/www/css mkdir $SIMPLE_ADMIN_DIR/www/js cd $SIMPLE_ADMIN_DIR/systemd - wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/development/simpleadmin/systemd/simpleadmin_generate_status.service + wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/simpleadmin/systemd/simpleadmin_generate_status.service sleep 1 cd $SIMPLE_ADMIN_DIR/scripts - wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/development/simpleadmin/scripts/build_modem_status - wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/development/simpleadmin/scripts/modemstatus_parse.sh - wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/development/simpleadmin/scripts/tojson.sh + wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/simpleadmin/scripts/build_modem_status + wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/simpleadmin/scripts/modemstatus_parse.sh + wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/simpleadmin/scripts/tojson.sh sleep 1 cd $SIMPLE_ADMIN_DIR/www - wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/development/simpleadmin/www/atcommander.html - wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/development/simpleadmin/www/index.html - wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/development/simpleadmin/www/speedtest.html - wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/development/simpleadmin/www/styles.css - wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/development/simpleadmin/www/ttl.html - wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/development/simpleadmin/www/sms.html - wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/development/simpleadmin/www/bandlock.html + wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/simpleadmin/www/atcommander.html + wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/simpleadmin/www/index.html + wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/simpleadmin/www/speedtest.html + wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/simpleadmin/www/styles.css + wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/simpleadmin/www/ttl.html + wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/simpleadmin/www/sms.html + wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/simpleadmin/www/bandlock.html sleep 1 cd $SIMPLE_ADMIN_DIR/www/js - wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/development/simpleadmin/www/js/alpinejs.min.js + wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/simpleadmin/www/js/alpinejs.min.js sleep 1 cd $SIMPLE_ADMIN_DIR/www/css - wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/development/simpleadmin/www/css/admin.css - wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/development/simpleadmin/www/css/bulma.css + wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/simpleadmin/www/css/admin.css + wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/simpleadmin/www/css/bulma.css sleep 1 cd $SIMPLE_ADMIN_DIR/www/cgi-bin - wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/development/simpleadmin/www/cgi-bin/get_atcommand - wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/development/simpleadmin/www/cgi-bin/get_csq - wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/development/simpleadmin/www/cgi-bin/get_ttl_status - wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/development/simpleadmin/www/cgi-bin/set_ttl + wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/simpleadmin/www/cgi-bin/get_atcommand + wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/simpleadmin/www/cgi-bin/get_csq + wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/simpleadmin/www/cgi-bin/get_ttl_status + wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/simpleadmin/www/cgi-bin/set_ttl sleep 1 cd / chmod +x $SIMPLE_ADMIN_DIR/scripts/* @@ -1017,7 +1017,8 @@ echo " :+##+. " 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) + echo -e "\e[92m11) Install OpenSSH Server\e[0m" # Light Green + echo -e "\e[93m12) Exit\e[0m" # Yellow (repeated color for exit option) read -p "Enter your choice: " choice case $choice in @@ -1094,6 +1095,27 @@ echo " :+##+. " echo -e "\e[1;32mThe fast.com test tops out at 40Mbps on the modem\e[0m" ;; 11) + echo -e "\e[1;32mOpenSSH Server\e[0m" + remount_rw + + mkdir /usrdata/sshd + wget -O /usrdata/sshd/sshd.service "https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/sshd/sshd.service" + ln -sf "/usrdata/sshd/sshd.service" "/lib/systemd/system/sshd.service" + + opkg install openssh-server-pam + /opt/bin/ssh-keygen -A + systemctl daemon-reload + systemctl enable sshd + + sed -i "s/^.*UsePAM .*/UsePAM yes/" "/opt/etc/ssh/sshd_config" + sed -i "s/^.*PermitRootLogin .*/PermitRootLogin yes/" "/opt/etc/ssh/sshd_config" + adduser -u 106 -G nogroup -h /opt/var/run -s /bin/nologin -S -D -H sshd + + systemctl start sshd + + echo -e "\e[1;32mOpenSSH installed!!\e[0m" + ;; + 12) echo -e "\e[1;32mGoodbye!\e[0m" break ;; diff --git a/installentware.sh b/installentware.sh index 638c684..354c6b7 100644 --- a/installentware.sh +++ b/installentware.sh @@ -83,7 +83,9 @@ create_opt_mount() { echo -e '\033[32mInfo: Setting up /opt mount to /usrdata/opt...\033[0m' cat < /lib/systemd/system/opt.mount [Unit] -Description=Bind /usrdata/opt to /opt +After=systemrw.mount sockets.target +Before=basic.target +RequiresMountsFor=/usrdata [Mount] What=/usrdata/opt @@ -92,7 +94,7 @@ Type=none Options=bind [Install] -WantedBy=local-fs.target +WantedBy=basic.target local-fs.target EOF systemctl daemon-reload @@ -203,10 +205,10 @@ opkg update && opkg install shadow-login shadow-passwd fi # Replace the login and passwd binaries and set home for root to a writable directory - rm /opt/etc/shadow - rm /opt/etc/passwd - ln -s /etc/shadow /opt/etc/ - ln -s /etc/passwd /opt/etc + mv /etc/shadow /opt/etc/shadow + mv /etc/passwd /opt/etc/passwd + ln -s /opt/etc/shadow /etc/shadow + ln -s /opt/etc/passwd /etc/passwd mkdir /usrdata/root mkdir /usrdata/root/bin touch /usrdata/root/.profile diff --git a/sshd/sshd.service b/sshd/sshd.service index 799bd33..6ad757c 100644 --- a/sshd/sshd.service +++ b/sshd/sshd.service @@ -4,9 +4,9 @@ Documentation=man:sshd(8) man:sshd_config(5) After=network.target [Service] -ExecStartPre=/opt/usr/sbin/sshd -t -ExecStart=/opt/usr/sbin/sshd -D -ExecReload=/opt/usr/sbin/sshd -t +ExecStartPre=/opt/sbin/sshd -t +ExecStart=/opt/sbin/sshd -D +ExecReload=/opt/sbin/sshd -t ExecReload=/bin/kill -HUP $MAINPID KillMode=process Restart=on-failure From 223e704adc646dcb1914d9af87c495750db93095 Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Tue, 9 Apr 2024 17:08:26 +0000 Subject: [PATCH 04/14] Fix OPKG installer --- RMxxx_rgmii_toolkit.sh | 1 + installentware.sh | 13 +++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/RMxxx_rgmii_toolkit.sh b/RMxxx_rgmii_toolkit.sh index b03ae9a..1788c7c 100644 --- a/RMxxx_rgmii_toolkit.sh +++ b/RMxxx_rgmii_toolkit.sh @@ -1095,6 +1095,7 @@ echo " :+##+. " echo -e "\e[1;32mThe fast.com test tops out at 40Mbps on the modem\e[0m" ;; 11) + ensure_entware_installed echo -e "\e[1;32mOpenSSH Server\e[0m" remount_rw diff --git a/installentware.sh b/installentware.sh index 354c6b7..2c48849 100644 --- a/installentware.sh +++ b/installentware.sh @@ -83,6 +83,7 @@ create_opt_mount() { echo -e '\033[32mInfo: Setting up /opt mount to /usrdata/opt...\033[0m' cat < /lib/systemd/system/opt.mount [Unit] +Description=Bind /usrdata/opt to /opt After=systemrw.mount sockets.target Before=basic.target RequiresMountsFor=/usrdata @@ -205,10 +206,10 @@ opkg update && opkg install shadow-login shadow-passwd fi # Replace the login and passwd binaries and set home for root to a writable directory - mv /etc/shadow /opt/etc/shadow - mv /etc/passwd /opt/etc/passwd - ln -s /opt/etc/shadow /etc/shadow - ln -s /opt/etc/passwd /etc/passwd + 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 @@ -224,9 +225,13 @@ opkg update && opkg install shadow-login shadow-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 / From 2024ec569c7766183faf2399d44b2361ae8474ec Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Tue, 9 Apr 2024 19:18:06 +0000 Subject: [PATCH 05/14] Fixes --- RMxxx_rgmii_toolkit.sh | 9 +++++---- installentware.sh | 1 + lighttpd/README.md | 2 ++ lighttpd/lighttpd.conf | 2 +- socat-at-bridge/systemd_units/socat-smd11.service | 2 +- socat-at-bridge/systemd_units/socat-smd7.service | 2 +- 6 files changed, 11 insertions(+), 7 deletions(-) diff --git a/RMxxx_rgmii_toolkit.sh b/RMxxx_rgmii_toolkit.sh index 1788c7c..c8b6b81 100644 --- a/RMxxx_rgmii_toolkit.sh +++ b/RMxxx_rgmii_toolkit.sh @@ -329,8 +329,9 @@ install_lighttpd() { mount -o remount,rw / mkdir -p "$LIGHTTPD_DIR" wget -O "$LIGHTTPD_DIR/lighttpd.conf" https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/lighttpd/lighttpd.conf - wget -O "$LIGHTTPD_DIR/lighttpd.service" https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/lighttpd/lighttpd.service - ln -sf "$LIGHTTPD_DIR/lighttpd.service" "/lib/systemd/system/lighttpd.service" + wget -O "/lib/systemd/system/lighttpd.service" https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/lighttpd/lighttpd.service + ln -sf "/lib/systemd/system/lighttpd.service" "/lib/systemd/system/multi-user.target.wants/" + openssl req -new -newkey rsa:2048 -days 3650 -nodes -x509 \ -subj "/C=US/ST=MI/L=Romulus/O=RMIITools/CN=localhost" \ -keyout $LIGHTTPD_DIR/server.key -out $LIGHTTPD_DIR/server.crt @@ -1100,8 +1101,8 @@ echo " :+##+. " remount_rw mkdir /usrdata/sshd - wget -O /usrdata/sshd/sshd.service "https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/sshd/sshd.service" - ln -sf "/usrdata/sshd/sshd.service" "/lib/systemd/system/sshd.service" + wget -O /lib/systemd/system/sshd.service "https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/sshd/sshd.service" + ln -sf "/lib/systemd/system/sshd.service" "/lib/systemd/system/multi-user.target.wants/" opkg install openssh-server-pam /opt/bin/ssh-keygen -A diff --git a/installentware.sh b/installentware.sh index 2c48849..ec0e9df 100644 --- a/installentware.sh +++ b/installentware.sh @@ -99,6 +99,7 @@ WantedBy=basic.target local-fs.target EOF systemctl daemon-reload + ln -s /lib/systemd/system/opt.mount /lib/systemd/system/local-fs.target.wants/opt.mount systemctl enable opt.mount systemctl start opt.mount } diff --git a/lighttpd/README.md b/lighttpd/README.md index 85017ea..d0edda5 100644 --- a/lighttpd/README.md +++ b/lighttpd/README.md @@ -5,3 +5,5 @@ lighttpd-mod-cgi lighttpd-mod-openssl lighttpd-mod-proxy printf "USER:$(openssl passwd -crypt PASSWORD)\n" >> .htpasswd + + diff --git a/lighttpd/lighttpd.conf b/lighttpd/lighttpd.conf index 6487a6e..306aadf 100644 --- a/lighttpd/lighttpd.conf +++ b/lighttpd/lighttpd.conf @@ -7,7 +7,7 @@ server.modules = ( ) server.username = "nobody" -server.groupname = "nogroup" +server.groupname = "dialout" server.port = 80 server.document-root = "/usrdata/simpleadmin/www" diff --git a/socat-at-bridge/systemd_units/socat-smd11.service b/socat-at-bridge/systemd_units/socat-smd11.service index a9e0747..76a6137 100644 --- a/socat-at-bridge/systemd_units/socat-smd11.service +++ b/socat-at-bridge/systemd_units/socat-smd11.service @@ -3,7 +3,7 @@ Description=Socat Serial Emulation for smd11 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/ttyIN,raw,echo=0,group=20,perm=660 pty,link=/dev/ttyOUT,raw,echo=1,group=20,perm=660 # Add a delay to prevent the clients from starting too early ExecStartPost=/bin/sleep 2s Restart=always diff --git a/socat-at-bridge/systemd_units/socat-smd7.service b/socat-at-bridge/systemd_units/socat-smd7.service index 6b8b1bd..e524283 100644 --- a/socat-at-bridge/systemd_units/socat-smd7.service +++ b/socat-at-bridge/systemd_units/socat-smd7.service @@ -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/ttyIN2,raw,echo=0 pty,link=/dev/ttyOUT2,raw,echo=1 +ExecStart=/usrdata/socat-at-bridge/socat-armel-static -d -d pty,link=/dev/ttyIN2,raw,echo=0,group=20,perm=660 pty,link=/dev/ttyOUT2,raw,echo=1,group=20,perm=660 # Add a delay to prevent the clients from starting too early ExecStartPost=/bin/sleep 2s Restart=always From 65a8dadbb652de92a3f441ed246154eb8867a74a Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Tue, 9 Apr 2024 20:32:57 +0000 Subject: [PATCH 06/14] Fix script --- RMxxx_rgmii_toolkit.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/RMxxx_rgmii_toolkit.sh b/RMxxx_rgmii_toolkit.sh index c8b6b81..39fcf7d 100644 --- a/RMxxx_rgmii_toolkit.sh +++ b/RMxxx_rgmii_toolkit.sh @@ -336,16 +336,14 @@ install_lighttpd() { -subj "/C=US/ST=MI/L=Romulus/O=RMIITools/CN=localhost" \ -keyout $LIGHTTPD_DIR/server.key -out $LIGHTTPD_DIR/server.crt systemctl daemon-reload - systemctl enable lighttpd systemctl start lighttpd - remount_ro + echo -e "\033[0;32mSimple Firewall installation/update complete.\033[0m" echo -e "\e[1;31mPlease set your system login password.\e[0m" - #printf "USER:$(openssl passwd -crypt PASSWORD)\n" >> .htpasswd + printf "USER:$(openssl passwd -crypt PASSWORD)\n" >> $LIGHTTPD_DIR/.htpasswd } - # Function to install/update Simple Admin install_simple_admin() { @@ -389,6 +387,7 @@ install_simple_admin() { wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/main/simpleadmin/www/speedtest.html wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/main/simpleadmin/www/styles.css wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/main/simpleadmin/www/ttl.html + wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/development/simpleadmin/www/bandlock.html sleep 1 cd $SIMPLE_ADMIN_DIR/www/js wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/main/simpleadmin/www/js/alpinejs.min.js From c081b5c63f7a50ae5687cc8cb874bdc1e810a79d Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Tue, 9 Apr 2024 21:11:46 +0000 Subject: [PATCH 07/14] Clearly this causes some issue --- installentware.sh | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/installentware.sh b/installentware.sh index ec0e9df..cc0532a 100644 --- a/installentware.sh +++ b/installentware.sh @@ -84,9 +84,6 @@ create_opt_mount() { cat < /lib/systemd/system/opt.mount [Unit] Description=Bind /usrdata/opt to /opt -After=systemrw.mount sockets.target -Before=basic.target -RequiresMountsFor=/usrdata [Mount] What=/usrdata/opt @@ -95,13 +92,29 @@ Type=none Options=bind [Install] -WantedBy=basic.target local-fs.target +WantedBy=multi-user.target EOF systemctl daemon-reload - ln -s /lib/systemd/system/opt.mount /lib/systemd/system/local-fs.target.wants/opt.mount - systemctl enable opt.mount 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 < /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 @@ -233,6 +246,5 @@ opkg update && opkg install shadow-login shadow-passwd ln -sf /opt/bin/dfc /bin opkg install lsof ln -sf /opt/bin/lsof /bin - # Remount filesystem as read-only mount -o remount,ro / From 59b3bfa6bafc05e870d2b0a7397bbf9e32a9a1fb Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Tue, 9 Apr 2024 21:34:44 +0000 Subject: [PATCH 08/14] Add useradd for sshd --- RMxxx_rgmii_toolkit.sh | 4 ++-- sshd/sshd.service | 7 ++----- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/RMxxx_rgmii_toolkit.sh b/RMxxx_rgmii_toolkit.sh index 39fcf7d..ac2aa10 100644 --- a/RMxxx_rgmii_toolkit.sh +++ b/RMxxx_rgmii_toolkit.sh @@ -1103,14 +1103,14 @@ echo " :+##+. " wget -O /lib/systemd/system/sshd.service "https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/sshd/sshd.service" ln -sf "/lib/systemd/system/sshd.service" "/lib/systemd/system/multi-user.target.wants/" - opkg install openssh-server-pam + opkg install openssh-server-pam shadow-useradd /opt/bin/ssh-keygen -A systemctl daemon-reload systemctl enable sshd sed -i "s/^.*UsePAM .*/UsePAM yes/" "/opt/etc/ssh/sshd_config" sed -i "s/^.*PermitRootLogin .*/PermitRootLogin yes/" "/opt/etc/ssh/sshd_config" - adduser -u 106 -G nogroup -h /opt/var/run -s /bin/nologin -S -D -H sshd + useradd -u 106 -g nogroup -d /opt/var/run -s /bin/nologin -r -N -M sshd systemctl start sshd diff --git a/sshd/sshd.service b/sshd/sshd.service index 6ad757c..f6c3ca8 100644 --- a/sshd/sshd.service +++ b/sshd/sshd.service @@ -4,16 +4,13 @@ Documentation=man:sshd(8) man:sshd_config(5) After=network.target [Service] +Type=simple +PIDFile=/opt/var/run/sshd.pid ExecStartPre=/opt/sbin/sshd -t ExecStart=/opt/sbin/sshd -D -ExecReload=/opt/sbin/sshd -t ExecReload=/bin/kill -HUP $MAINPID KillMode=process Restart=on-failure -RestartPreventExitStatus=255 -Type=notify -RuntimeDirectory=sshd -RuntimeDirectoryMode=0755 [Install] WantedBy=multi-user.target From b63b4d4cead5f327ffced6b0a6eb26c903f4f2d2 Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Wed, 10 Apr 2024 02:42:21 +0000 Subject: [PATCH 09/14] Add password config --- RMxxx_rgmii_toolkit.sh | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/RMxxx_rgmii_toolkit.sh b/RMxxx_rgmii_toolkit.sh index ac2aa10..d9b5cbb 100644 --- a/RMxxx_rgmii_toolkit.sh +++ b/RMxxx_rgmii_toolkit.sh @@ -338,10 +338,19 @@ install_lighttpd() { systemctl daemon-reload systemctl start lighttpd - echo -e "\033[0;32mSimple Firewall installation/update complete.\033[0m" + echo -e "\033[0;32mLighttpd installation/update complete.\033[0m" - echo -e "\e[1;31mPlease set your system login password.\e[0m" - printf "USER:$(openssl passwd -crypt PASSWORD)\n" >> $LIGHTTPD_DIR/.htpasswd + while true; do + echo -e "\e[1;31mPlease set your root web login password.\e[0m" + read password + if [ -z "$password" ]; then + echo -e "\e[1;32mNo password provided.\e[0m" + else + printf "root:$(openssl passwd -crypt \"$password\")\n" >> $LIGHTTPD_DIR/.htpasswd + echo -e "\e[1;32mPassword set.\e[0m" + break + fi + done } # Function to install/update Simple Admin From b5166a969ea6dcdb48cc62251ff547c5d429259e Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Wed, 10 Apr 2024 02:47:03 +0000 Subject: [PATCH 10/14] Fix password bug --- RMxxx_rgmii_toolkit.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/RMxxx_rgmii_toolkit.sh b/RMxxx_rgmii_toolkit.sh index d9b5cbb..f74f46c 100644 --- a/RMxxx_rgmii_toolkit.sh +++ b/RMxxx_rgmii_toolkit.sh @@ -345,6 +345,7 @@ install_lighttpd() { read password if [ -z "$password" ]; then echo -e "\e[1;32mNo password provided.\e[0m" + else printf "root:$(openssl passwd -crypt \"$password\")\n" >> $LIGHTTPD_DIR/.htpasswd echo -e "\e[1;32mPassword set.\e[0m" From 0b3cce7a1f7b7da93c4633c6c40c9a6e613bfc51 Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Wed, 10 Apr 2024 02:58:25 +0000 Subject: [PATCH 11/14] Fix password --- RMxxx_rgmii_toolkit.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/RMxxx_rgmii_toolkit.sh b/RMxxx_rgmii_toolkit.sh index f74f46c..5d15df4 100644 --- a/RMxxx_rgmii_toolkit.sh +++ b/RMxxx_rgmii_toolkit.sh @@ -345,9 +345,8 @@ install_lighttpd() { read password if [ -z "$password" ]; then echo -e "\e[1;32mNo password provided.\e[0m" - else - printf "root:$(openssl passwd -crypt \"$password\")\n" >> $LIGHTTPD_DIR/.htpasswd + printf "root:$(openssl passwd -crypt $password)\n" >> $LIGHTTPD_DIR/.htpasswd echo -e "\e[1;32mPassword set.\e[0m" break fi From dc7f3f17d2ef475ff08acc7caaabc0410d93c188 Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Wed, 10 Apr 2024 12:20:12 +0000 Subject: [PATCH 12/14] last minor updates --- RMxxx_rgmii_toolkit.sh | 11 ++++++++--- lighttpd/README.md | 9 --------- lighttpd/gencert.sh | 4 ---- sshd/README.md | 10 ---------- 4 files changed, 8 insertions(+), 26 deletions(-) delete mode 100644 lighttpd/README.md delete mode 100644 lighttpd/gencert.sh delete mode 100644 sshd/README.md diff --git a/RMxxx_rgmii_toolkit.sh b/RMxxx_rgmii_toolkit.sh index 5d15df4..702d95b 100644 --- a/RMxxx_rgmii_toolkit.sh +++ b/RMxxx_rgmii_toolkit.sh @@ -323,6 +323,7 @@ install_lighttpd() { ensure_entware_installed /opt/bin/opkg install lighttpd lighttpd-mod-auth lighttpd-mod-authn_file lighttpd-mod-cgi lighttpd-mod-openssl lighttpd-mod-proxy + rm /opt/etc/init.d/S80lighttpd # Ensure rc.unslung doesn't try to start it systemctl stop lighttpd echo -e "\033[0;32mInstalling/Updating Lighttpd...\033[0m" @@ -342,11 +343,12 @@ install_lighttpd() { while true; do echo -e "\e[1;31mPlease set your root web login password.\e[0m" - read password + read -s password if [ -z "$password" ]; then echo -e "\e[1;32mNo password provided.\e[0m" else - printf "root:$(openssl passwd -crypt $password)\n" >> $LIGHTTPD_DIR/.htpasswd + echo -n "root:" > $LIGHTTPD_DIR/.htpasswd + openssl passwd -crypt "$password" >> $LIGHTTPD_DIR/.htpasswd echo -e "\e[1;32mPassword set.\e[0m" break fi @@ -1113,14 +1115,17 @@ echo " :+##+. " ln -sf "/lib/systemd/system/sshd.service" "/lib/systemd/system/multi-user.target.wants/" opkg install openssh-server-pam shadow-useradd + rm /opt/etc/init.d/S40sshd # Ensure rc.unslung doesn't try to start it /opt/bin/ssh-keygen -A systemctl daemon-reload systemctl enable sshd + # Enable PAM and PermitRootLogin sed -i "s/^.*UsePAM .*/UsePAM yes/" "/opt/etc/ssh/sshd_config" sed -i "s/^.*PermitRootLogin .*/PermitRootLogin yes/" "/opt/etc/ssh/sshd_config" - useradd -u 106 -g nogroup -d /opt/var/run -s /bin/nologin -r -N -M sshd + # Ensure the sshd user exists in the /opt/etc/passwd file + grep "sshd:x:106" /opt/etc/passwd || echo "sshd:x:106:65534:Linux User,,,:/opt/run/sshd:/bin/nologin" >> /opt/etc/passwd systemctl start sshd echo -e "\e[1;32mOpenSSH installed!!\e[0m" diff --git a/lighttpd/README.md b/lighttpd/README.md deleted file mode 100644 index d0edda5..0000000 --- a/lighttpd/README.md +++ /dev/null @@ -1,9 +0,0 @@ -lighttpd -lighttpd-mod-auth -lighttpd-mod-authn_file -lighttpd-mod-cgi -lighttpd-mod-openssl -lighttpd-mod-proxy -printf "USER:$(openssl passwd -crypt PASSWORD)\n" >> .htpasswd - - diff --git a/lighttpd/gencert.sh b/lighttpd/gencert.sh deleted file mode 100644 index a98208e..0000000 --- a/lighttpd/gencert.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -openssl req -new -newkey rsa:2048 -days 3650 -nodes -x509 \ - -subj "/C=US/ST=MI/L=Romulus/O=RMIITools/CN=localhost" \ - -keyout server.key -out server.crt diff --git a/sshd/README.md b/sshd/README.md deleted file mode 100644 index 64656a0..0000000 --- a/sshd/README.md +++ /dev/null @@ -1,10 +0,0 @@ -# Generate Host Keys -ssh-keygen -A - -# Must edit in /opt/etc/ssh/sshd_config -PasswordAuthentication yes -UsePAM yes -PermitRootLogin yes - -# Need to add ssh user in /opt/etc/passwd -sshd:x:106:65534:Linux User,,,:/opt/run/sshd:/bin/nologin From 315b937e8f0dfff623cc64d6d6a953c63fff46eb Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Wed, 10 Apr 2024 12:42:49 +0000 Subject: [PATCH 13/14] Ensure lighttpd installed for ttyd --- RMxxx_rgmii_toolkit.sh | 6 +++++- lighttpd/lighttpd.conf | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/RMxxx_rgmii_toolkit.sh b/RMxxx_rgmii_toolkit.sh index 702d95b..8f95250 100644 --- a/RMxxx_rgmii_toolkit.sh +++ b/RMxxx_rgmii_toolkit.sh @@ -361,7 +361,7 @@ install_simple_admin() { install_lighttpd while true; do - echo -e "\e[1;32mWhat version of Simple Admin do you want to install? This will start a webserver on port 8080\e[0m" + echo -e "\e[1;32mWhat version of Simple Admin do you want to install? This will start a webserver on port 80/443\e[0m" echo -e "\e[1;32m1) Stable current version, (Main Branch)\e[0m" echo -e "\e[1;31m2) Install Test Build (Development Branch)\e[0m" echo -e "\e[0;33m3) Return to Main Menu\e[0m" @@ -888,6 +888,10 @@ install_ttyd() { mount -o remount,rw / + if [ ! -d "/usrdata/lighttpd" ]; then + install_lighttpd + fi + 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.5 (DO NOT UPDATE WHILE USING ttyd! Use ADB or SSH instead)\e[0m" diff --git a/lighttpd/lighttpd.conf b/lighttpd/lighttpd.conf index 306aadf..ea60e50 100644 --- a/lighttpd/lighttpd.conf +++ b/lighttpd/lighttpd.conf @@ -43,5 +43,5 @@ $HTTP["url"] =~ "/cgi-bin/" { # Handle proxy to ttyd if it's running $HTTP["url"] =~ "(^/ttyd)" { proxy.header = ("map-urlpath" => ( "/ttyd" => "/" ), "upgrade" => "enable" ) - proxy.server = ( "" => ("" => ( "host" => "127.0.0.1", "port" => 8443 ))) + proxy.server = ( "" => ("" => ( "host" => "127.0.0.1", "port" => 8088 ))) } From 1663b34e1ddd149c788214d1acfd2f3d207c9cfe Mon Sep 17 00:00:00 2001 From: Cameron Thompson <50184035+iamromulan@users.noreply.github.com> Date: Wed, 10 Apr 2024 23:41:21 -0400 Subject: [PATCH 14/14] Prep to merge --- RMxxx_rgmii_toolkit.sh | 582 ++++++++++++++++----------- installentware.sh | 12 +- lighttpd/lighttpd.conf | 4 +- simpleadmin/.rev | 2 +- simpleadmin/www/atcommander.html | 9 +- simpleadmin/www/bandlock.html | 7 +- simpleadmin/www/index.html | 5 +- simpleadmin/www/sms.html | 5 +- simpleadmin/www/speedtest.html | 5 +- simpleadmin/www/ttl.html | 11 +- simplefirewall/.rev | 2 +- simpleupdates/scripts/update_ttyd.sh | 42 ++ socat-at-bridge/.rev | 2 +- sshd/.rev | 1 + tailscale/.rev | 2 +- ttyd/.rev | 2 +- ttyd/scripts/ttyd.bash | 16 +- 17 files changed, 433 insertions(+), 276 deletions(-) create mode 100644 simpleupdates/scripts/update_ttyd.sh create mode 100644 sshd/.rev diff --git a/RMxxx_rgmii_toolkit.sh b/RMxxx_rgmii_toolkit.sh index 8f95250..ae4e7a1 100644 --- a/RMxxx_rgmii_toolkit.sh +++ b/RMxxx_rgmii_toolkit.sh @@ -1,10 +1,10 @@ #!/bin/sh # Define toolkit paths -GITUSER="snowzach" -GITTREE="lighttpd" -# GITUSER="iamromulan" -# GITTREE="development" +GITUSER="iamromulan" +GITTREE="development" +GITMAINTREE="main" +GITDEVTREE="development" TMP_DIR="/tmp" USRDATA_DIR="/usrdata" SOCAT_AT_DIR="/usrdata/socat-at-bridge" @@ -102,6 +102,7 @@ send_at_commands() { # Check for existing Entware/opkg installation, install if not installed ensure_entware_installed() { + remount_rw 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 @@ -112,7 +113,56 @@ ensure_entware_installed() { cd / else echo -e "\e[1;32mEntware/OPKG is already installed.\e[0m" + if [ "$(readlink /bin/login)" != "/opt/bin/login" ]; then + opkg update && opkg install shadow-login shadow-passwd shadow-useradd + 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 -p /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/ + ln -sf /opt/bin/useradd /usr/bin/ + echo -e "\e[1;31mPlease set the root password.\e[0m" + /usr/bin/passwd + + # Install basic and useful utilities + opkg install mc htop dfc lsof + ln -sf /opt/bin/mc /bin + ln -sf /opt/bin/htop /bin + ln -sf /opt/bin/dfc /bin + ln -sf /opt/bin/lsof /bin + fi + + if [ ! -f "/usrdata/root/.profile" ]; then + opkg update && opkg install shadow-useradd + mkdir -p /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 + fi fi + if [ ! -f "/opt/sbin/useradd" ]; then + echo "useradd does not exist. Installing shadow-useradd..." + opkg install shadow-useradd + else + echo "useradd already exists. Continuing..." + fi + } # Check if Simple Admin is installed @@ -204,6 +254,7 @@ install_update_at_socat() { # Function to install Simple Firewall install_simple_firewall() { + remount_rw systemctl stop simplefirewall systemctl stop ttl-override echo -e "\033[0;32mInstalling/Updating Simple Firewall...\033[0m" @@ -321,13 +372,25 @@ configure_simple_firewall() { # Function to install Lighttpd install_lighttpd() { ensure_entware_installed + remount_rw + # Check for simpleadmin_httpd service and remove if exists + if [ -f "/lib/systemd/system/simpleadmin_httpd.service" ]; then + systemctl stop simpleadmin_httpd + rm /lib/systemd/system/simpleadmin_httpd.service + rm /lib/systemd/system/multi-user.target.wants/simpleadmin_httpd.service + fi /opt/bin/opkg install lighttpd lighttpd-mod-auth lighttpd-mod-authn_file lighttpd-mod-cgi lighttpd-mod-openssl lighttpd-mod-proxy - rm /opt/etc/init.d/S80lighttpd # Ensure rc.unslung doesn't try to start it - + # Ensure rc.unslung doesn't try to start it + # Dynamically find and remove any Lighttpd-related init script + for script in /opt/etc/init.d/*lighttpd*; do + if [ -f "$script" ]; then + echo "Removing existing Lighttpd init script: $script" + rm "$script" # Remove the script if it contains 'lighttpd' in its name + fi + done systemctl stop lighttpd echo -e "\033[0;32mInstalling/Updating Lighttpd...\033[0m" - mount -o remount,rw / mkdir -p "$LIGHTTPD_DIR" wget -O "$LIGHTTPD_DIR/lighttpd.conf" https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/lighttpd/lighttpd.conf wget -O "/lib/systemd/system/lighttpd.service" https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/lighttpd/lighttpd.service @@ -355,135 +418,229 @@ install_lighttpd() { done } +# Function to install or update ttyd +install_ttyd() { + echo -e "\e[1;34mStarting ttyd installation process...\e[0m" + + ensure_entware_installed + + mount -o remount,rw / + + if [ ! -d "/usrdata/lighttpd" ]; then + install_lighttpd + fi + + 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.7 (If you are using ttyd you will temporarly loose connection ...)\e[0m" + echo -e "\e[1;31m2.) Skip Update (Chose this if you already updated)\e[0m" + read -p "Enter your choice (1/2): " choice + case $choice in + 1) + echo -e "\e[1;34mUpdating ttyd...\e[0m" + echo -e "\e[1;34mIf you are using ttyd you will temporarly loose connection ...\e[0m" + mkdir /usrdata/simpleupdates/scripts + wget -O /usrdata/simpleupdates/scripts/update_ttyd.sh https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/simpleupdates/scripts/update_ttyd.sh && chmod +x /usrdata/simpleupdates/scripts/update_ttyd.sh + /usrdata/simpleupdates/scripts/update_ttyd.sh + echo -e "\e[1;32mttyd has been updated.\e[0m" + ;; + 2) + echo -e "\e[1;34mSkiping ttyd update...\e[0m" + ;; + *) + echo -e "\e[1;31mInvalid option. Exiting.\e[0m" + exit 1 + ;; + esac + return + fi + + # 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://github.com/tsl0922/ttyd/releases/download/1.7.7/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 /usrdata/ttyd/ttyd /bin + + # Enabling and starting ttyd service + systemctl daemon-reload + 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;32mInstallation Complete! ttyd server is up on port 443. Note: No TLS/SSL enabled yet.\e[0m" +} + +check_and_install_ttyd() { + remount_rw + local service_file="/lib/systemd/system/ttyd.service" + local exec_start_expected1="/usrdata/ttyd/ttyd -p 443 -t 'theme={\"foreground\":\"white\",\"background\":\"black\"}' -t fontSize=25 --writable /usrdata/ttyd/scripts/ttyd.bash" + local exec_start_expected2="/usrdata/ttyd/ttyd -i 127.0.0.1 -p 8088 -t 'theme={\"foreground\":\"white\",\"background\":\"black\"}' -t fontSize=25 --writable /usrdata/ttyd/scripts/ttyd.bash" + + if [ -f "$service_file" ]; then + # Extract ExecStart line from ttyd.service + local exec_start=$(grep ExecStart $service_file) + + if [ "$exec_start" == "ExecStart=$exec_start_expected1" ]; then + install_ttyd + elif [ "$exec_start" == "ExecStart=$exec_start_expected2" ]; then + # Continue without action + echo "No action required, ttyd service is configured as expected." + else + install_ttyd + fi + else + install_ttyd + fi +} + # Function to install/update Simple Admin install_simple_admin() { - - install_lighttpd - while true; do - echo -e "\e[1;32mWhat version of Simple Admin do you want to install? This will start a webserver on port 80/443\e[0m" - echo -e "\e[1;32m1) Stable current version, (Main Branch)\e[0m" + echo -e "\e[1;32mWhat version of Simple Admin do you want to install? This will start a webserver on port 8080 (80/443 on test build)\e[0m" + echo -e "\e[1;32m1) Stable current version, (Main Branch)\e[0m" echo -e "\e[1;31m2) Install Test Build (Development Branch)\e[0m" echo -e "\e[0;33m3) Return to Main Menu\e[0m" echo -e "\e[1;32mSelect your choice: \e[0m" read choice case $choice in - 1) - echo -e "\e[1;32mInstalling simpleadmin from the main stable branch\e[0m" - install_update_at_socat - sleep 1 - install_simple_firewall - sleep 1 - remount_rw - sleep 1 - mkdir $SIMPLE_ADMIN_DIR - mkdir $SIMPLE_ADMIN_DIR/systemd + 1) + echo -e "\e[1;32mInstalling simpleadmin from the main stable branch\e[0m" + install_update_at_socat + sleep 1 + install_simple_firewall + sleep 1 + remount_rw + sleep 1 + mkdir $SIMPLE_ADMIN_DIR + mkdir $SIMPLE_ADMIN_DIR/systemd mkdir $SIMPLE_ADMIN_DIR/scripts mkdir $SIMPLE_ADMIN_DIR/www - mkdir $SIMPLE_ADMIN_DIR/www/cgi-bin - mkdir $SIMPLE_ADMIN_DIR/www/css + mkdir $SIMPLE_ADMIN_DIR/www/cgi-bin + mkdir $SIMPLE_ADMIN_DIR/www/css mkdir $SIMPLE_ADMIN_DIR/www/js - cd $SIMPLE_ADMIN_DIR/systemd - wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/main/simpleadmin/systemd/simpleadmin_generate_status.service - sleep 1 - cd $SIMPLE_ADMIN_DIR/scripts - wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/main/simpleadmin/scripts/build_modem_status - wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/main/simpleadmin/scripts/modemstatus_parse.sh - wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/main/simpleadmin/scripts/tojson.sh - sleep 1 - cd $SIMPLE_ADMIN_DIR/www - wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/main/simpleadmin/www/atcommander.html - wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/main/simpleadmin/www/index.html - wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/main/simpleadmin/www/speedtest.html - wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/main/simpleadmin/www/styles.css - wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/main/simpleadmin/www/ttl.html - wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/development/simpleadmin/www/bandlock.html - sleep 1 - cd $SIMPLE_ADMIN_DIR/www/js - wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/main/simpleadmin/www/js/alpinejs.min.js + cd $SIMPLE_ADMIN_DIR/systemd + wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITMAINTREE/simpleadmin/systemd/simpleadmin_generate_status.service + wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/main/simpleadmin/systemd/simpleadmin_httpd.service + sleep 1 + cd $SIMPLE_ADMIN_DIR/scripts + wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITMAINTREE/simpleadmin/scripts/build_modem_status + wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITMAINTREE/simpleadmin/scripts/modemstatus_parse.sh + wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITMAINTREE/simpleadmin/scripts/tojson.sh + sleep 1 + cd $SIMPLE_ADMIN_DIR/www + wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITMAINTREE/simpleadmin/www/atcommander.html + wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITMAINTREE/simpleadmin/www/index.html + wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITMAINTREE/simpleadmin/www/speedtest.html + wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITMAINTREE/simpleadmin/www/styles.css + wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITMAINTREE/simpleadmin/www/ttl.html + wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITMAINTREE/simpleadmin/www/bandlock.html + sleep 1 + cd $SIMPLE_ADMIN_DIR/www/js + wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITMAINTREE/simpleadmin/www/js/alpinejs.min.js sleep 1 cd $SIMPLE_ADMIN_DIR/www/css - wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/main/simpleadmin/www/css/admin.css - wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/main/simpleadmin/www/css/bulma.css - sleep 1 - cd $SIMPLE_ADMIN_DIR/www/cgi-bin - wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/main/simpleadmin/www/cgi-bin/get_atcommand - wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/main/simpleadmin/www/cgi-bin/get_csq - wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/main/simpleadmin/www/cgi-bin/get_ttl_status - wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/main/simpleadmin/www/cgi-bin/set_ttl - sleep 1 - cd / - chmod +x $SIMPLE_ADMIN_DIR/scripts/* - chmod +x $SIMPLE_ADMIN_DIR/www/cgi-bin/* - cp -rf $SIMPLE_ADMIN_DIR/systemd/* /lib/systemd/system - systemctl daemon-reload - sleep 1 - ln -sf /lib/systemd/system/simpleadmin_generate_status.service /lib/systemd/system/multi-user.target.wants/ - systemctl start simpleadmin_generate_status - sleep 1 - remount_ro - echo -e "\e[1;32msimpleadmin has been installed and is now ready for use!\e[0m" - break - ;; - 2) - echo -e "\e[1;31m2) Installing simpleadmin from the development test branch\e[0m" - install_update_at_socat - sleep 1 - install_simple_firewall - sleep 1 - remount_rw - sleep 1 - mkdir $SIMPLE_ADMIN_DIR - mkdir $SIMPLE_ADMIN_DIR/systemd + wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITMAINTREE/simpleadmin/www/css/admin.css + wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITMAINTREE/simpleadmin/www/css/bulma.css + sleep 1 + cd $SIMPLE_ADMIN_DIR/www/cgi-bin + wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITMAINTREE/simpleadmin/www/cgi-bin/get_atcommand + wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITMAINTREE/simpleadmin/www/cgi-bin/get_csq + wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITMAINTREE/simpleadmin/www/cgi-bin/get_ttl_status + wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITMAINTREE/simpleadmin/www/cgi-bin/set_ttl + sleep 1 + cd / + chmod +x $SIMPLE_ADMIN_DIR/scripts/* + chmod +x $SIMPLE_ADMIN_DIR/www/cgi-bin/* + cp -rf $SIMPLE_ADMIN_DIR/systemd/* /lib/systemd/system + systemctl daemon-reload + sleep 1 + ln -sf /lib/systemd/system/simpleadmin_httpd.service /lib/systemd/system/multi-user.target.wants/ + ln -sf /lib/systemd/system/simpleadmin_generate_status.service /lib/systemd/system/multi-user.target.wants/ + systemctl start simpleadmin_generate_status + sleep 1 + remount_ro + echo -e "\e[1;32msimpleadmin has been installed and is now ready for use!\e[0m" + break + ;; + 2) + echo -e "\e[1;31m2) Installing simpleadmin from the development test branch\e[0m" + install_update_at_socat + sleep 1 + install_simple_firewall + sleep 1 + install_lighttpd + sleep 1 + remount_rw + sleep 1 + mkdir $SIMPLE_ADMIN_DIR + mkdir $SIMPLE_ADMIN_DIR/systemd mkdir $SIMPLE_ADMIN_DIR/scripts mkdir $SIMPLE_ADMIN_DIR/www - mkdir $SIMPLE_ADMIN_DIR/www/cgi-bin - mkdir $SIMPLE_ADMIN_DIR/www/css + mkdir $SIMPLE_ADMIN_DIR/www/cgi-bin + mkdir $SIMPLE_ADMIN_DIR/www/css mkdir $SIMPLE_ADMIN_DIR/www/js - cd $SIMPLE_ADMIN_DIR/systemd - wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/simpleadmin/systemd/simpleadmin_generate_status.service - sleep 1 - cd $SIMPLE_ADMIN_DIR/scripts - wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/simpleadmin/scripts/build_modem_status - wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/simpleadmin/scripts/modemstatus_parse.sh - wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/simpleadmin/scripts/tojson.sh - sleep 1 - cd $SIMPLE_ADMIN_DIR/www - wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/simpleadmin/www/atcommander.html - wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/simpleadmin/www/index.html - wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/simpleadmin/www/speedtest.html - wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/simpleadmin/www/styles.css - wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/simpleadmin/www/ttl.html - wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/simpleadmin/www/sms.html - wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/simpleadmin/www/bandlock.html - sleep 1 - cd $SIMPLE_ADMIN_DIR/www/js - wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/simpleadmin/www/js/alpinejs.min.js + cd $SIMPLE_ADMIN_DIR/systemd + wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITDEVTREE/simpleadmin/systemd/simpleadmin_generate_status.service + sleep 1 + cd $SIMPLE_ADMIN_DIR/scripts + wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITDEVTREE/simpleadmin/scripts/build_modem_status + wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITDEVTREE/simpleadmin/scripts/modemstatus_parse.sh + wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITDEVTREE/simpleadmin/scripts/tojson.sh + sleep 1 + cd $SIMPLE_ADMIN_DIR/www + wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITDEVTREE/simpleadmin/www/atcommander.html + wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITDEVTREE/simpleadmin/www/index.html + wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITDEVTREE/simpleadmin/www/speedtest.html + wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITDEVTREE/simpleadmin/www/styles.css + wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITDEVTREE/simpleadmin/www/ttl.html + wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITDEVTREE/simpleadmin/www/sms.html + wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITDEVTREE/simpleadmin/www/bandlock.html + sleep 1 + cd $SIMPLE_ADMIN_DIR/www/js + wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITDEVTREE/simpleadmin/www/js/alpinejs.min.js sleep 1 cd $SIMPLE_ADMIN_DIR/www/css - wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/simpleadmin/www/css/admin.css - wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/simpleadmin/www/css/bulma.css - sleep 1 - cd $SIMPLE_ADMIN_DIR/www/cgi-bin - wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/simpleadmin/www/cgi-bin/get_atcommand - wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/simpleadmin/www/cgi-bin/get_csq - wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/simpleadmin/www/cgi-bin/get_ttl_status - wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/simpleadmin/www/cgi-bin/set_ttl - sleep 1 - cd / - chmod +x $SIMPLE_ADMIN_DIR/scripts/* - chmod +x $SIMPLE_ADMIN_DIR/www/cgi-bin/* - cp -rf $SIMPLE_ADMIN_DIR/systemd/* /lib/systemd/system - systemctl daemon-reload - sleep 1 - ln -sf /lib/systemd/system/simpleadmin_generate_status.service /lib/systemd/system/multi-user.target.wants/ - systemctl start simpleadmin_generate_status - sleep 1 - remount_ro - echo -e "\e[1;32msimpleadmin has been installed and is now ready for use!\e[0m" - break - ;; + wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITDEVTREE/simpleadmin/www/css/admin.css + wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITDEVTREE/simpleadmin/www/css/bulma.css + sleep 1 + cd $SIMPLE_ADMIN_DIR/www/cgi-bin + wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITDEVTREE/simpleadmin/www/cgi-bin/get_atcommand + wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITDEVTREE/simpleadmin/www/cgi-bin/get_csq + wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITDEVTREE/simpleadmin/www/cgi-bin/get_ttl_status + wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITDEVTREE/simpleadmin/www/cgi-bin/set_ttl + sleep 1 + cd / + chmod +x $SIMPLE_ADMIN_DIR/scripts/* + chmod +x $SIMPLE_ADMIN_DIR/www/cgi-bin/* + cp -rf $SIMPLE_ADMIN_DIR/systemd/* /lib/systemd/system + sleep 1 + systemctl daemon-reload + sleep 1 + ln -sf /lib/systemd/system/simpleadmin_generate_status.service /lib/systemd/system/multi-user.target.wants/ + systemctl start simpleadmin_generate_status + sleep 1 + check_and_install_ttyd + sleep 1 + remount_ro + echo -e "\e[1;32msimpleadmin has been installed and is now ready for use!\e[0m" + break + ;; 3) echo "Returning to main menu..." break @@ -499,7 +656,7 @@ install_simple_admin() { uninstall_simpleadmin_components() { echo -e "\e[1;32mStarting the uninstallation process for Simpleadmin components.\e[0m" echo -e "\e[1;32mNote: Uninstalling certain components may affect the functionality of others.\e[0m" - echo -e "\e[1;36mIf you are upgrading from an older version of the toolkit uninstall/say yes to all everything.\e[0m" + echo -e "\e[1;36mIf you are upgrading from an older version of the toolkit uninstall/say yes to all everything except ttyd.\e[0m" remount_rw # Uninstall Simple Firewall @@ -527,47 +684,68 @@ uninstall_simpleadmin_components() { read -p "Enter your choice (1 or 2): " choice_socat_at_bridge if [ "$choice_socat_at_bridge" -eq 1 ]; then 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" + 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 - echo -e "\e[1;32mDo you want to uninstall the rest of Simpleadmin?\e[0m" + # Uninstall ttyd + echo -e "\e[1;32mDo you want to uninstall ttyd?\e[0m" + echo -e "\e[1;31mWarning: Do not uninstall if you are currently using ttyd to do this!!!\e[0m" + echo -e "\e[1;31mInstalling the test build will prompt ttyd to be updated if it needs it anyways\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_simpleadmin if [ "$choice_simpleadmin" -eq 1 ]; then - echo "Uninstalling the rest of Simpleadmin..." - systemctl stop simpleadmin_generate_status - rm -f /lib/systemd/system/simpleadmin_generate_status.service - systemctl daemon-reload - rm -rf "$SIMPLE_ADMIN_DIR" - echo "The rest of Simpleadmin uninstalled." + 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" + fi + + echo "Uninstalling the rest of Simpleadmin..." + + # Check if Lighttpd service is installed and remove it if present + if [ -f "/lib/systemd/system/lighttpd.service" ]; then + echo "Lighttpd detected, uninstalling Lighttpd and its modules..." + systemctl stop lighttpd + opkg remove lighttpd lighttpd-mod-auth lighttpd-mod-authn_file lighttpd-mod-cgi lighttpd-mod-openssl lighttpd-mod-proxy + rm -rf $LIGHTTPD_DIR + fi + + systemctl stop simpleadmin_generate_status + systemctl stop simpleadmin_httpd + rm -f /lib/systemd/system/simpleadmin_httpd.service + rm -f /lib/systemd/system/simpleadmin_generate_status.service + systemctl daemon-reload + rm -rf "$SIMPLE_ADMIN_DIR" + echo "The rest of Simpleadmin and Lighttpd (if present) uninstalled." remount_ro - fi echo "Uninstallation process completed." } @@ -881,77 +1059,6 @@ WantedBy=multi-user.target" > "$cfun_service_path" fi } -install_ttyd() { - echo -e "\e[1;34mStarting ttyd installation process...\e[0m" - - ensure_entware_installed - - mount -o remount,rw / - - if [ ! -d "/usrdata/lighttpd" ]; then - install_lighttpd - fi - - 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.5 (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.5/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 - - # 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://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 /usrdata/ttyd/ttyd /bin - - # Enabling and starting ttyd service - systemctl daemon-reload - 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;32mInstallation Complete! ttyd server is up on port 443. Note: No TLS/SSL enabled yet.\e[0m" -} - # Main menu @@ -1029,11 +1136,10 @@ 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/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[92m11) Install OpenSSH Server\e[0m" # Light Green - echo -e "\e[93m12) Exit\e[0m" # Yellow (repeated color for exit option) + echo -e "\e[92m8) Install Speedtest.net CLI app (speedtest command)\e[0m" # Light Green + echo -e "\e[92m9) Install Fast.com CLI app (fast command)(tops out at 40Mbps)\e[0m" # Light Green + echo -e "\e[92m10) Install OpenSSH Server\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 @@ -1072,10 +1178,7 @@ echo " :+##+. " 7) ensure_entware_installed ;; - 8) - install_ttyd - ;; - 9) + 8) ensure_entware_installed echo -e "\e[1;32mInstalling Speedtest.net CLI (speedtest command)\e[0m" remount_rw @@ -1095,7 +1198,7 @@ echo " :+##+. " echo -e "\e[1;32mNormaly only an issue in adb, ttyd and ssh you are forced to login\e[0m" echo -e "\e[1;32mIf in adb just type login and then try to run the speedtest command\e[0m" ;; - 10) + 9) echo -e "\e[1;32mInstalling fast.com CLI (fast command)\e[0m" remount_rw mkdir /usrdata/root @@ -1109,7 +1212,7 @@ echo " :+##+. " 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) + 10) ensure_entware_installed echo -e "\e[1;32mOpenSSH Server\e[0m" remount_rw @@ -1118,8 +1221,13 @@ echo " :+##+. " wget -O /lib/systemd/system/sshd.service "https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/sshd/sshd.service" ln -sf "/lib/systemd/system/sshd.service" "/lib/systemd/system/multi-user.target.wants/" - opkg install openssh-server-pam shadow-useradd - rm /opt/etc/init.d/S40sshd # Ensure rc.unslung doesn't try to start it + opkg install openssh-server-pam + for script in /opt/etc/init.d/*sshd*; do + if [ -f "$script" ]; then + echo "Removing existing sshd init script: $script" + rm "$script" # Remove the script if it contains 'sshd' in its name + fi + done /opt/bin/ssh-keygen -A systemctl daemon-reload systemctl enable sshd @@ -1134,7 +1242,7 @@ echo " :+##+. " echo -e "\e[1;32mOpenSSH installed!!\e[0m" ;; - 12) + 11) echo -e "\e[1;32mGoodbye!\e[0m" break ;; diff --git a/installentware.sh b/installentware.sh index cc0532a..dc7058a 100644 --- a/installentware.sh +++ b/installentware.sh @@ -1,5 +1,5 @@ #!/bin/sh -# Modified by iamromlan to set up a proper entware environment for Quectel RM5xx series m.2 modems +# Modified by iamromulan to set up a proper entware environment for Quectel RM5xx series m.2 modems TYPE='generic' #|---------|-----------------| #| TARGET | Quectel Modem | @@ -213,7 +213,7 @@ 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 install shadow-login shadow-passwd +opkg update && opkg install shadow-login shadow-passwd shadow-useradd if [ "$?" -ne 0 ]; then echo -e "\e[1;31mPackage installation failed. Please check your internet connection and try again.\e[0m" exit 1 @@ -234,17 +234,15 @@ opkg update && opkg install shadow-login shadow-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" + ln -sf /opt/bin/useradd /usr/bin/ + echo -e "\e[1;31mPlease set the root password.\e[0m" /usr/bin/passwd # Install basic and useful utilites - opkg install mc + opkg install mc htop dfc lsof 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/lighttpd/lighttpd.conf b/lighttpd/lighttpd.conf index ea60e50..c5ee638 100644 --- a/lighttpd/lighttpd.conf +++ b/lighttpd/lighttpd.conf @@ -41,7 +41,7 @@ $HTTP["url"] =~ "/cgi-bin/" { } # Handle proxy to ttyd if it's running -$HTTP["url"] =~ "(^/ttyd)" { - proxy.header = ("map-urlpath" => ( "/ttyd" => "/" ), "upgrade" => "enable" ) +$HTTP["url"] =~ "(^/console)" { + proxy.header = ("map-urlpath" => ( "/console" => "/" ), "upgrade" => "enable" ) proxy.server = ( "" => ("" => ( "host" => "127.0.0.1", "port" => 8088 ))) } diff --git a/simpleadmin/.rev b/simpleadmin/.rev index 56a6051..d8263ee 100644 --- a/simpleadmin/.rev +++ b/simpleadmin/.rev @@ -1 +1 @@ -1 \ No newline at end of file +2 \ No newline at end of file diff --git a/simpleadmin/www/atcommander.html b/simpleadmin/www/atcommander.html index 11b6317..5d75843 100644 --- a/simpleadmin/www/atcommander.html +++ b/simpleadmin/www/atcommander.html @@ -4,7 +4,7 @@ - Simple Settings + AT Commands @@ -35,13 +35,12 @@ > diff --git a/simpleadmin/www/bandlock.html b/simpleadmin/www/bandlock.html index ee02b3f..b2501e3 100644 --- a/simpleadmin/www/bandlock.html +++ b/simpleadmin/www/bandlock.html @@ -44,13 +44,12 @@ > diff --git a/simpleadmin/www/index.html b/simpleadmin/www/index.html index dac2f1c..5da9ec7 100644 --- a/simpleadmin/www/index.html +++ b/simpleadmin/www/index.html @@ -36,11 +36,12 @@ > diff --git a/simpleadmin/www/sms.html b/simpleadmin/www/sms.html index 9c0a4ba..2d56e5d 100644 --- a/simpleadmin/www/sms.html +++ b/simpleadmin/www/sms.html @@ -36,11 +36,12 @@ > diff --git a/simpleadmin/www/speedtest.html b/simpleadmin/www/speedtest.html index 90ad0a6..798f364 100644 --- a/simpleadmin/www/speedtest.html +++ b/simpleadmin/www/speedtest.html @@ -37,11 +37,12 @@ > diff --git a/simpleadmin/www/ttl.html b/simpleadmin/www/ttl.html index 3b03658..c4994af 100644 --- a/simpleadmin/www/ttl.html +++ b/simpleadmin/www/ttl.html @@ -31,11 +31,12 @@ diff --git a/simplefirewall/.rev b/simplefirewall/.rev index 56a6051..d8263ee 100644 --- a/simplefirewall/.rev +++ b/simplefirewall/.rev @@ -1 +1 @@ -1 \ No newline at end of file +2 \ No newline at end of file diff --git a/simpleupdates/scripts/update_ttyd.sh b/simpleupdates/scripts/update_ttyd.sh new file mode 100644 index 0000000..e1e053c --- /dev/null +++ b/simpleupdates/scripts/update_ttyd.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +# Define constants +GITUSER="iamromulan" +GITTREE="main" +SERVICE_FILE="/lib/systemd/system/install_ttyd.service" +TMP_SCRIPT="/tmp/install_ttyd.sh" + +# Create the systemd service file +cat < "$SERVICE_FILE" +[Unit] +Description=Update ttyd service + +[Service] +Type=oneshot +ExecStart=/bin/bash $TMP_SCRIPT + +[Install] +WantedBy=multi-user.target +EOF + +# Create and populate the temporary shell script for installation +cat < "$TMP_SCRIPT" +#!/bin/bash +mount -o remount,rw / +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.7/ttyd.armhf && chmod +x /usrdata/ttyd/ttyd +wget -O /usrdata/ttyd/scripts/ttyd.bash "https://raw.githubusercontent.com/$GITUSER/$GITTREE/ttyd/scripts/ttyd.bash" && chmod +x /usrdata/ttyd/scripts/ttyd.bash +wget -O /usrdata/ttyd/systemd/ttyd.service "https://raw.githubusercontent.com/$GITUSER/$GITTREE/ttyd/systemd/ttyd.service" +cp -f /usrdata/ttyd/systemd/ttyd.service /lib/systemd/system/ +systemctl daemon-reload +systemctl start ttyd +echo -e "\e[1;32mttyd has been updated.\e[0m" +EOF + +# Make the temporary script executable +chmod +x "$TMP_SCRIPT" + +# Reload systemd to recognize the new service and start the update +systemctl daemon-reload +systemctl start install_ttyd.service diff --git a/socat-at-bridge/.rev b/socat-at-bridge/.rev index 56a6051..d8263ee 100644 --- a/socat-at-bridge/.rev +++ b/socat-at-bridge/.rev @@ -1 +1 @@ -1 \ No newline at end of file +2 \ No newline at end of file diff --git a/sshd/.rev b/sshd/.rev new file mode 100644 index 0000000..d8263ee --- /dev/null +++ b/sshd/.rev @@ -0,0 +1 @@ +2 \ No newline at end of file diff --git a/tailscale/.rev b/tailscale/.rev index 56a6051..d8263ee 100644 --- a/tailscale/.rev +++ b/tailscale/.rev @@ -1 +1 @@ -1 \ No newline at end of file +2 \ No newline at end of file diff --git a/ttyd/.rev b/ttyd/.rev index 56a6051..d8263ee 100644 --- a/ttyd/.rev +++ b/ttyd/.rev @@ -1 +1 @@ -1 \ No newline at end of file +2 \ No newline at end of file diff --git a/ttyd/scripts/ttyd.bash b/ttyd/scripts/ttyd.bash index e62635d..93980e8 100644 --- a/ttyd/scripts/ttyd.bash +++ b/ttyd/scripts/ttyd.bash @@ -1,9 +1,15 @@ #!/bin/bash -# Read the serial number -serial_number=$(/usrdata/socat-at-bridge/atcmd 'AT+EGMR=0,5' | grep '+EGMR:' | cut -d '"' -f2) -# Read the firmware revision -firmware_revision=$(/usrdata/socat-at-bridge/atcmd 'AT+CGMR' | grep -o 'RM[0-9A-Z]*' | head -1) +# Check if /usrdata/socat-at-bridge/atcmd exists +if [ -f "/usrdata/socat-at-bridge/atcmd" ]; then + # Read the serial number + serial_number=$(/usrdata/socat-at-bridge/atcmd 'AT+EGMR=0,5' | grep '+EGMR:' | cut -d '"' -f2) + # Read the firmware revision + firmware_revision=$(/usrdata/socat-at-bridge/atcmd 'AT+CGMR' | grep -o 'RM[0-9A-Z]*' | head -1) +else + serial_number="UNKNOWN" + firmware_revision="UNKNOWN" +fi echo "==============================================================" echo "==============================================================" @@ -84,7 +90,7 @@ echo " :@@@@@*. " echo " .=@@@@@- " echo " :+##+. " echo "==============================================================" -echo "TTYd session file by iamromulan v1.0" +echo "TTYd session file by iamromulan v1.1" echo "Firmware Revision: $firmware_revision" echo "Serial Number: $serial_number" echo "=============================================================="