QuecManger 1.0.0
Release Notes: Enhanced Web App Architecture: - Optimized the structure for better scalability and maintainability. - Refined Data Fetching Logic: Improved the efficiency and reliability of data retrieval processes. - Optimized AT Terminal: Enhanced functionality for smoother interaction with AT commands. - Revamped UI/UX Design: Streamlined user interface and experience for improved accessibility and usability. New Features: - MTU Settings: Added customizable Maximum Transmission Unit (MTU) settings. - APN and IMEI Profiles: Introduced the ability to configure APN and IMEI profiles for better device management. - Persistent Cell Locking: Added native support for persistent cell locking, ensuring consistent network connections. - QuecWatch: Connection monitoring with auto reconnect and reboot settable Co-Authored-By: Russel Yasol <73575327+dr-dolomite@users.noreply.github.com>
This commit is contained in:
@@ -1,66 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Set content-type for JSON response
|
||||
echo "Content-type: application/json"
|
||||
echo ""
|
||||
|
||||
# Define the lock file
|
||||
LOCK_FILE="/tmp/home_data.lock"
|
||||
|
||||
# Acquire the lock (wait if needed)
|
||||
exec 200>$LOCK_FILE
|
||||
flock -x 200
|
||||
|
||||
# Temporary files for input/output and AT port
|
||||
INPUT_FILE="/tmp/input_$$.txt"
|
||||
OUTPUT_FILE="/tmp/output_$$.txt"
|
||||
AT_PORT="/dev/smd11"
|
||||
|
||||
# Debug file path
|
||||
DEBUG_FILE="/tmp/debug-json-result.txt"
|
||||
|
||||
# Function to escape JSON strings (handling quotes and newlines)
|
||||
escape_json() {
|
||||
# Escape newlines and double quotes
|
||||
echo "$1" | sed ':a;N;$!ba;s/\n/\\n/g; s/"/\\"/g'
|
||||
}
|
||||
|
||||
# Initialize JSON response array
|
||||
JSON_RESPONSE="["
|
||||
|
||||
# List of AT commands to run, one by one
|
||||
for COMMAND in 'AT+QMAP="MPDN_RULE"' 'AT+QMAP="DHCPV4DNS"' 'AT+QCFG="usbnet"'; do
|
||||
# Write the command to the input file
|
||||
echo "$COMMAND" > "$INPUT_FILE"
|
||||
|
||||
# Run the command using atinout
|
||||
atinout "$INPUT_FILE" "$AT_PORT" "$OUTPUT_FILE"
|
||||
|
||||
# Read the output from the output file
|
||||
OUTPUT=$(cat "$OUTPUT_FILE")
|
||||
|
||||
# Escape special characters for JSON (escape only output)
|
||||
ESCAPED_OUTPUT=$(escape_json "$OUTPUT")
|
||||
|
||||
# Append the response as an object to the JSON response array
|
||||
JSON_RESPONSE="${JSON_RESPONSE}{\"response\":\"$ESCAPED_OUTPUT\"},"
|
||||
done
|
||||
|
||||
# Remove the trailing comma and close the JSON array
|
||||
if [ "${JSON_RESPONSE: -1}" = "," ]; then
|
||||
JSON_RESPONSE="${JSON_RESPONSE%,}]"
|
||||
else
|
||||
JSON_RESPONSE="${JSON_RESPONSE}]"
|
||||
fi
|
||||
|
||||
# Write the JSON response to the debug file for troubleshooting
|
||||
echo "$JSON_RESPONSE" > "$DEBUG_FILE"
|
||||
|
||||
# Return the output as a valid JSON response
|
||||
echo "$JSON_RESPONSE"
|
||||
|
||||
# Clean up temporary files
|
||||
rm "$INPUT_FILE" "$OUTPUT_FILE"
|
||||
|
||||
# Release the lock
|
||||
flock -u 200
|
||||
26
ipk-source/sdxpinn-quecmanager/root/www/cgi-bin/advance/fetch_commands.sh
Executable file
26
ipk-source/sdxpinn-quecmanager/root/www/cgi-bin/advance/fetch_commands.sh
Executable file
@@ -0,0 +1,26 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Set content type for JSON response
|
||||
echo "Content-Type: application/json"
|
||||
echo ""
|
||||
|
||||
# Check if the file exists
|
||||
if [ -f "/etc/config/atcommands.user" ]; then
|
||||
# Start JSON object
|
||||
printf "{\n"
|
||||
awk -F';' '
|
||||
BEGIN { first = 1 }
|
||||
{
|
||||
gsub(/\r/, "", $0)
|
||||
if (!first) printf ",\n "
|
||||
else printf " "
|
||||
gsub(/"/, "\\\"", $1)
|
||||
gsub(/"/, "\\\"", $2)
|
||||
printf "\"%s\": \"%s\"", $1, $2
|
||||
first = 0
|
||||
}
|
||||
' /etc/config/atcommands.user
|
||||
printf "\n}"
|
||||
else
|
||||
echo '{"error": "No Data"}'
|
||||
fi
|
||||
90
ipk-source/sdxpinn-quecmanager/root/www/cgi-bin/advance/mtu.sh
Executable file
90
ipk-source/sdxpinn-quecmanager/root/www/cgi-bin/advance/mtu.sh
Executable file
@@ -0,0 +1,90 @@
|
||||
#!/bin/sh
|
||||
echo "Content-type: application/json"
|
||||
echo ""
|
||||
mtu_firewall_file="/etc/firewall.user.mtu"
|
||||
network_interface="rmnet_data0"
|
||||
lan_utils_script="/etc/data/lanUtils.sh"
|
||||
|
||||
get_current_mtu() {
|
||||
ip link show "$network_interface" | grep -o "mtu [0-9]*" | cut -d' ' -f2
|
||||
}
|
||||
|
||||
update_lanutils_mtu_config() {
|
||||
local action="$1"
|
||||
if [ "$action" = "add" ]; then
|
||||
# Add the MTU firewall file line if not already present
|
||||
if ! grep -q "local mtu_firewall_file=/etc/firewall.user.mtu" "$lan_utils_script"; then
|
||||
sed -i '/local ttl_firewall_file=\/etc\/firewall.user.ttl/a local mtu_firewall_file=/etc/firewall.user.mtu' "$lan_utils_script"
|
||||
fi
|
||||
elif [ "$action" = "remove" ]; then
|
||||
# Remove the MTU firewall file line if present
|
||||
sed -i '/local mtu_firewall_file=\/etc\/firewall.user.mtu/d' "$lan_utils_script"
|
||||
fi
|
||||
}
|
||||
|
||||
case "$REQUEST_METHOD" in
|
||||
GET)
|
||||
# Fetch current MTU
|
||||
current_mtu=$(get_current_mtu)
|
||||
current_mtu=${current_mtu:-1500}
|
||||
|
||||
# Check if custom MTU is configured
|
||||
if [ -f "$mtu_firewall_file" ]; then
|
||||
echo "{\"isEnabled\": true, \"currentValue\": $current_mtu}"
|
||||
else
|
||||
echo "{\"isEnabled\": false, \"currentValue\": $current_mtu}"
|
||||
fi
|
||||
;;
|
||||
|
||||
POST)
|
||||
read -r post_data
|
||||
mtu_value=$(echo "$post_data" | sed 's/mtu=//')
|
||||
|
||||
# Check for disable functionality
|
||||
if [ "$mtu_value" = "disable" ]; then
|
||||
# Remove the MTU configuration file
|
||||
rm -f "$mtu_firewall_file"
|
||||
|
||||
# Remove the MTU configuration line from lanUtils.sh
|
||||
update_lanutils_mtu_config "remove"
|
||||
|
||||
# Get the default MTU
|
||||
default_mtu=$(get_current_mtu)
|
||||
default_mtu=${default_mtu:-1500}
|
||||
|
||||
echo "{\"success\": true, \"message\": \"MTU configuration disabled\", \"currentValue\": $default_mtu}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Validate MTU input
|
||||
if ! [[ "$mtu_value" =~ ^[0-9]+$ ]]; then
|
||||
echo "{\"success\": false, \"error\": \"Invalid MTU value\"}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Create firewall MTU configuration file with individual interface commands
|
||||
> "$mtu_firewall_file" # Clear the file
|
||||
for iface in $(ls /sys/class/net | grep '^rmnet_data'); do
|
||||
echo "ip link set $iface mtu $mtu_value" >> "$mtu_firewall_file"
|
||||
done
|
||||
|
||||
# Immediately apply MTU change
|
||||
for iface in $(ls /sys/class/net | grep '^rmnet_data'); do
|
||||
ip link set "$iface" mtu "$mtu_value"
|
||||
done
|
||||
|
||||
# Add the MTU configuration line to lanUtils.sh
|
||||
update_lanutils_mtu_config "add"
|
||||
|
||||
# Run lanUtils.sh to update network configuration
|
||||
if [ -f "$lan_utils_script" ]; then
|
||||
. "$lan_utils_script"
|
||||
fi
|
||||
|
||||
echo "{\"success\": true, \"message\": \"MTU configuration updated to $mtu_value\", \"currentValue\": $mtu_value}"
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "{\"success\": false, \"error\": \"Invalid request method\"}"
|
||||
;;
|
||||
esac
|
||||
Reference in New Issue
Block a user