From c39546736466745e5d485484e8c7d2949b80b638 Mon Sep 17 00:00:00 2001 From: Cameron Thompson <50184035+iamromulan@users.noreply.github.com> Date: Sun, 21 Apr 2024 14:43:44 -0400 Subject: [PATCH] Progress... --- simpleadmin/{scripts => console}/.profile | 0 .../menu/LAN_settings.sh} | 8 + simpleadmin/console/menu/start_menu.sh | 156 ++++++++++++++++++ .../services}/ethernet_watchdog.sh | 0 simpleadmin/{scripts => console}/ttyd.bash | 0 simpleadmin/scripts/ICCID_APN.sh | 101 ------------ simpleadmin/scripts/ICCIDfun.sh | 21 --- simpleadmin/scripts/start_menu.sh | 51 ------ simpleupdates/.rev | 1 + simpleupdates/scripts/update_simpleadmin.sh | 2 +- 10 files changed, 166 insertions(+), 174 deletions(-) rename simpleadmin/{scripts => console}/.profile (100%) rename simpleadmin/{scripts/ap_settings.sh => console/menu/LAN_settings.sh} (94%) create mode 100644 simpleadmin/console/menu/start_menu.sh rename simpleadmin/{ => console/services}/ethernet_watchdog.sh (100%) rename simpleadmin/{scripts => console}/ttyd.bash (100%) delete mode 100644 simpleadmin/scripts/ICCID_APN.sh delete mode 100644 simpleadmin/scripts/ICCIDfun.sh delete mode 100644 simpleadmin/scripts/start_menu.sh create mode 100644 simpleupdates/.rev diff --git a/simpleadmin/scripts/.profile b/simpleadmin/console/.profile similarity index 100% rename from simpleadmin/scripts/.profile rename to simpleadmin/console/.profile diff --git a/simpleadmin/scripts/ap_settings.sh b/simpleadmin/console/menu/LAN_settings.sh similarity index 94% rename from simpleadmin/scripts/ap_settings.sh rename to simpleadmin/console/menu/LAN_settings.sh index 608dc8d..5a6a28d 100644 --- a/simpleadmin/scripts/ap_settings.sh +++ b/simpleadmin/console/menu/LAN_settings.sh @@ -3,6 +3,14 @@ CONFIG_FILE="/etc/data/mobileap_cfg.xml" # Display Messages in Colors +display_random_color() { + local msg="$1" + local colors=(33 34 35 36 37) # ANSI color codes for yellow, blue, magenta, cyan, white + local num_colors=${#colors[@]} + local random_color_index=$(($RANDOM % num_colors)) # Pick a random index from the colors array + echo -e "\033[${colors[$random_color_index]}m$msg\033[0m" +} + display_green() { echo -e "\033[0;32m$1\033[0m" } diff --git a/simpleadmin/console/menu/start_menu.sh b/simpleadmin/console/menu/start_menu.sh new file mode 100644 index 0000000..cea218a --- /dev/null +++ b/simpleadmin/console/menu/start_menu.sh @@ -0,0 +1,156 @@ +#!/bin/bash + +# Define executable files path +EXE=/usrdata/root/bin + +# Display Messages in Colors +display_random_color() { + local msg="$1" + local colors=(33 34 35 36 37) # ANSI color codes for yellow, blue, magenta, cyan, white + local num_colors=${#colors[@]} + local random_color_index=$(($RANDOM % num_colors)) # Pick a random index from the colors array + echo -e "\033[${colors[$random_color_index]}m$msg\033[0m" +} + +display_green() { + echo -e "\033[0;32m$1\033[0m" +} + +display_red() { + echo -e "\033[0;31m$1\033[0m" +} + +# Menus + +toolkit() { + while true; do + display_green "Welcome to iamromulan's Simple Console Menu" + display_green "Select an option:" + echo "------------------" + display_green "1. LAN Settings" + display_green "2. Change simpleadmin (admin) password" + display_green "3. Change root password (shell/ssh/console)" + display_green "4. Open File Browser/Editor (mc)" + display_green "5. View Used/Available space" + display_green "6. Open Task Manager/View CPU Load" + display_green "7. Run speedtest.net test" + display_green "8. Run fast.com test (30Mbps max)" + display_green "9. Get and run the Toolkit" + display_green "10. Get and run the Development/unstable Toolkit" + display_green "11. Exit (Enter Root Shell)" + echo + read -p "Select an option (1-11): " option + + case "$option" in + 1) $EXE/LAN_settings ;; + 2) $EXE/simplepasswd ;; + 3) passwd ;; + 4) mc ;; + 5) dfc ;; + 6) htop ;; + 7) $EXE/speedtest ;; + 8) $EXE/fast ;; + 9) cd /tmp && wget -O RMxxx_rgmii_toolkit.sh https://raw.githubusercontent.com/iamromulan/quectel-rgmii-toolkit/main/RMxxx_rgmii_toolkit.sh && chmod +x RMxxx_rgmii_toolkit.sh && ./RMxxx_rgmii_toolkit.sh && cd / ;; + 10) cd /tmp && wget -O RMxxx_rgmii_toolkit.sh https://raw.githubusercontent.com/iamromulan/quectel-rgmii-toolkit/development/RMxxx_rgmii_toolkit.sh && chmod +x RMxxx_rgmii_toolkit.sh && ./RMxxx_rgmii_toolkit.sh && cd / ;; + 11) break ;; + *) echo "Invalid option. Please try again." ;; + esac + done +} + +apps() { + while true; do + display_green "Welcome to iamromulan's Simple Console Menu" + display_green "Select an option:" + echo "------------------" + display_green "1. LAN Settings" + display_green "2. Change simpleadmin (admin) password" + display_green "3. Change root password (shell/ssh/console)" + display_green "4. Open File Browser/Editor (mc)" + display_green "5. View Used/Available space" + display_green "6. Open Task Manager/View CPU Load" + display_green "7. Run speedtest.net test" + display_green "8. Run fast.com test (30Mbps max)" + display_green "9. Get and run the Toolkit" + display_green "10. Get and run the Development/unstable Toolkit" + display_green "11. Exit (Enter Root Shell)" + echo + read -p "Select an option (1-11): " option + + case "$option" in + 1) $EXE/LAN_settings ;; + 2) $EXE/simplepasswd ;; + 3) passwd ;; + 4) mc ;; + 5) dfc ;; + 6) htop ;; + 7) $EXE/speedtest ;; + 8) $EXE/fast ;; + 9) cd /tmp && wget -O RMxxx_rgmii_toolkit.sh https://raw.githubusercontent.com/iamromulan/quectel-rgmii-toolkit/main/RMxxx_rgmii_toolkit.sh && chmod +x RMxxx_rgmii_toolkit.sh && ./RMxxx_rgmii_toolkit.sh && cd / ;; + 10) cd /tmp && wget -O RMxxx_rgmii_toolkit.sh https://raw.githubusercontent.com/iamromulan/quectel-rgmii-toolkit/development/RMxxx_rgmii_toolkit.sh && chmod +x RMxxx_rgmii_toolkit.sh && ./RMxxx_rgmii_toolkit.sh && cd / ;; + 11) break ;; + *) echo "Invalid option. Please try again." ;; + esac + done +} + +settings() { + while true; do + display_green "Welcome to iamromulan's Simple Console Menu" + display_green "Select an option:" + echo "------------------" + display_green "1. LAN Settings" + display_green "2. Change simpleadmin (admin) password" + display_green "3. Change root password (shell/ssh/console)" + display_green "4. Open File Browser/Editor (mc)" + display_green "5. View Used/Available space" + display_green "6. Open Task Manager/View CPU Load" + display_green "7. Run speedtest.net test" + display_green "8. Run fast.com test (30Mbps max)" + display_green "9. Get and run the Toolkit" + display_green "10. Get and run the Development/unstable Toolkit" + display_green "11. Exit (Enter Root Shell)" + echo + read -p "Select an option (1-11): " option + + case "$option" in + 1) $EXE/LAN_settings ;; + 2) $EXE/simplepasswd ;; + 3) passwd ;; + 4) mc ;; + 5) dfc ;; + 6) htop ;; + 7) $EXE/speedtest ;; + 8) $EXE/fast ;; + 9) cd /tmp && wget -O RMxxx_rgmii_toolkit.sh https://raw.githubusercontent.com/iamromulan/quectel-rgmii-toolkit/main/RMxxx_rgmii_toolkit.sh && chmod +x RMxxx_rgmii_toolkit.sh && ./RMxxx_rgmii_toolkit.sh && cd / ;; + 10) cd /tmp && wget -O RMxxx_rgmii_toolkit.sh https://raw.githubusercontent.com/iamromulan/quectel-rgmii-toolkit/development/RMxxx_rgmii_toolkit.sh && chmod +x RMxxx_rgmii_toolkit.sh && ./RMxxx_rgmii_toolkit.sh && cd / ;; + 11) break ;; + *) echo "Invalid option. Please try again." ;; + esac + done +} + +main_menu() { + while true; do + display_green "Welcome to iamromulan's Simple Console Menu" + display_green "To get back to this from the root shell, just type 'menu'" + display_green "Select an option:" + echo "------------------" + display_random_color "1) Apps" + display_random_color "2) Settings" + display_random_color "3) Toolkit" + display_random_color "4) Exit (Enter Root Shell)" + echo + read -p "Select an option (1-11): " option + + case "$option" in + 1) apps ;; + 2) settings ;; + 3) toolkit ;; + 4) break ;; + *) echo "Invalid option. Please try again." ;; + esac + done +} + +main_menu \ No newline at end of file diff --git a/simpleadmin/ethernet_watchdog.sh b/simpleadmin/console/services/ethernet_watchdog.sh similarity index 100% rename from simpleadmin/ethernet_watchdog.sh rename to simpleadmin/console/services/ethernet_watchdog.sh diff --git a/simpleadmin/scripts/ttyd.bash b/simpleadmin/console/ttyd.bash similarity index 100% rename from simpleadmin/scripts/ttyd.bash rename to simpleadmin/console/ttyd.bash diff --git a/simpleadmin/scripts/ICCID_APN.sh b/simpleadmin/scripts/ICCID_APN.sh deleted file mode 100644 index 9ec5dde..0000000 --- a/simpleadmin/scripts/ICCID_APN.sh +++ /dev/null @@ -1,101 +0,0 @@ -#!/bin/sh - -# Configuration -DEVICE_FILE="/dev/smd7" -ICCID_FILE="/path/to/iccid_master_file" # Path to the ICCID-APN-IPType master file -TMP_DIR="/tmp" -TIMEOUT=4 - -# Start listening to device file -start_listening() { - cat "$DEVICE_FILE" > "$TMP_DIR/device_readout" & - CAT_PID=$! -} - -# Send AT command -send_at_command() { - local command=$1 - echo -e "${command}\r" > "$DEVICE_FILE" -} - -# Wait for and process response -wait_for_response() { - local start_time=$(date +%s) - local current_time - local elapsed_time - - while true; do - if grep -q "OK" "$TMP_DIR/device_readout" || grep -q "ERROR" "$TMP_DIR/device_readout"; then - RESPONSE=$(cat "$TMP_DIR/device_readout") - echo "Response received: $RESPONSE" - return 0 - fi - current_time=$(date +%s) - elapsed_time=$((current_time - start_time)) - if [ "$elapsed_time" -ge "$TIMEOUT" ]; then - echo "Error: Response timed out." - return 1 - fi - sleep 1 - done -} - -# Cleanup function -cleanup() { - kill "$CAT_PID" - wait "$CAT_PID" 2>/dev/null - rm -f "$TMP_DIR/device_readout" -} - -# Function to send AT command and wait for response -send_and_wait() { - send_at_command "$1" - wait_for_response -} - -# Function to update the APN -update_apn() { - local slot=$1 - local apn=$2 - local iptype=$3 - send_and_wait "AT+CGDCONT=$slot,\"$iptype\",\"$apn\"" - if [ $? -eq 0 ]; then - echo "APN updated successfully." - else - echo "Failed to update APN." - fi -} - -# Main Execution -if [ -c "$DEVICE_FILE" ]; then - start_listening - - # Get ICCID - send_and_wait "AT+CCID" - ICCID=$(echo "$RESPONSE" | grep "+CCID" | cut -d ':' -f2 | tr -d '[:space:]') - echo "ICCID: $ICCID" - - # Check ICCID in master file - if grep -q "$ICCID" "$ICCID_FILE"; then - APN=$(grep "$ICCID" "$ICCID_FILE" | cut -d ',' -f2) - IP_TYPE=$(grep "$ICCID" "$ICCID_FILE" | cut -d ',' -f3) - IP_TYPE=${IP_TYPE:-"IPV4V6"} # Default to IPV4V6 if not specified - - # Get current APN settings - send_and_wait "AT+CGDCONT?" - CURRENT_APN=$(echo "$RESPONSE" | grep "+CGDCONT: 1" | cut -d ',' -f3 | tr -d '"') - - # Compare and update APN if necessary - if [ "$APN" != "$CURRENT_APN" ]; then - update_apn 1 "$APN" "$IP_TYPE" - else - echo "No APN update needed." - fi - else - echo "ICCID not found in the master file." - fi - - cleanup -else - echo "Error: Device $DEVICE_FILE does not exist or is not a character special file." -fi diff --git a/simpleadmin/scripts/ICCIDfun.sh b/simpleadmin/scripts/ICCIDfun.sh deleted file mode 100644 index 465b478..0000000 --- a/simpleadmin/scripts/ICCIDfun.sh +++ /dev/null @@ -1,21 +0,0 @@ -edit_iccid_file() { - local iccid_file="/path/to/iccid_master_file" # Path to the ICCID-APN-IPType master file - - echo "Enter ICCID to add or edit:" - read iccid - echo "Enter APN for $iccid:" - read apn - echo "Enter IP Type (IPV4, IPV6, IPV4V6) for $iccid [Default: IPV4V6]:" - read iptype - iptype=${iptype:-"IPV4V6"} # Default to IPV4V6 if not specified - - # Check if ICCID already exists - if grep -q "$iccid" "$iccid_file"; then - # Update existing ICCID's APN and IP Type - sed -i "/$iccid/c\\$iccid,$apn,$iptype" "$iccid_file" - else - # Add new ICCID, APN, and IP Type - echo "$iccid,$apn,$iptype" >> "$iccid_file" - fi - echo "ICCID file updated." -} diff --git a/simpleadmin/scripts/start_menu.sh b/simpleadmin/scripts/start_menu.sh deleted file mode 100644 index 36b1a89..0000000 --- a/simpleadmin/scripts/start_menu.sh +++ /dev/null @@ -1,51 +0,0 @@ -#!/bin/bash - -# Define executable files path -EXE=/usrdata/root/bin - -# Display Messages in Colors -display_green() { - echo -e "\033[0;32m$1\033[0m" -} - -display_red() { - echo -e "\033[0;31m$1\033[0m" -} - -main_menu() { - while true; do - display_green "Welcome to iamromulan's Simple Console Menu" - display_green "Select an option:" - echo "------------------" - display_green "1. QCMAP Settings" - display_green "2. Change simpleadmin (admin) password" - display_green "3. Change root password (shell/ssh/console)" - display_green "4. Open File Browser/Editor (mc)" - display_green "5. View Used/Available space" - display_green "6. Open Task Manager/View CPU Load" - display_green "7. Run speedtest.net test" - display_green "8. Run fast.com test (30Mbps max)" - display_green "9. Get and run the Toolkit" - display_green "10. Get and run the Development/unstable Toolkit" - display_green "11. Exit (Enter Root Shell)" - echo - read -p "Select an option (1-11): " option - - case "$option" in - 1) $EXE/ap_settings ;; - 2) $EXE/simplepasswd ;; - 3) passwd ;; - 4) mc ;; - 5) dfc ;; - 6) htop ;; - 7) $EXE/speedtest ;; - 8) $EXE/fast ;; - 9) cd /tmp && wget -O RMxxx_rgmii_toolkit.sh https://raw.githubusercontent.com/iamromulan/quectel-rgmii-toolkit/main/RMxxx_rgmii_toolkit.sh && chmod +x RMxxx_rgmii_toolkit.sh && ./RMxxx_rgmii_toolkit.sh && cd / ;; - 10) cd /tmp && wget -O RMxxx_rgmii_toolkit.sh https://raw.githubusercontent.com/iamromulan/quectel-rgmii-toolkit/development/RMxxx_rgmii_toolkit.sh && chmod +x RMxxx_rgmii_toolkit.sh && ./RMxxx_rgmii_toolkit.sh && cd / ;; - 11) break ;; - *) echo "Invalid option. Please try again." ;; - esac - done -} - -main_menu diff --git a/simpleupdates/.rev b/simpleupdates/.rev new file mode 100644 index 0000000..d8263ee --- /dev/null +++ b/simpleupdates/.rev @@ -0,0 +1 @@ +2 \ No newline at end of file diff --git a/simpleupdates/scripts/update_simpleadmin.sh b/simpleupdates/scripts/update_simpleadmin.sh index 9733328..afb8f1d 100644 --- a/simpleupdates/scripts/update_simpleadmin.sh +++ b/simpleupdates/scripts/update_simpleadmin.sh @@ -172,7 +172,7 @@ install_ttyd() { echo -e "\e[1;34mStarting ttyd installation process...\e[0m" cd $SIMPLE_ADMIN_DIR wget -O ttyd https://github.com/tsl0922/ttyd/releases/download/1.7.7/ttyd.armhf && chmod +x ttyd - wget -O $SIMPLE_ADMIN_DIR/scripts/ttyd.bash "https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/simpleadmin/scripts/ttyd.bash" && chmod +x scripts/ttyd.bash + wget -O $SIMPLE_ADMIN_DIR/scripts/ttyd.bash "https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/simpleadmin/console/ttyd.bash" && chmod +x scripts/ttyd.bash wget -O $SIMPLE_ADMIN_DIR/systemd/ttyd.service "https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/simpleadmin/systemd/ttyd.service" cp -f $SIMPLE_ADMIN_DIR/systemd/ttyd.service /lib/systemd/system/ ln -sf /usrdata/simpleadmin/ttyd /bin