Copy QuecManager beta to non-beta
QM BETA --> regular/non-beta
This commit is contained in:
@@ -2,6 +2,9 @@
|
||||
# Updated QuecProfiles daemon with enhanced SA/NSA NR5G band management and TTL support
|
||||
# Including profile application functions and fixed comparison logic
|
||||
|
||||
# Load centralized logging
|
||||
. /www/cgi-bin/services/quecmanager_logger.sh
|
||||
|
||||
# Configuration
|
||||
QUEUE_DIR="/tmp/at_queue"
|
||||
TOKEN_FILE="$QUEUE_DIR/token"
|
||||
@@ -15,25 +18,49 @@ DEFAULT_CHECK_INTERVAL=60 # Default check interval in seconds
|
||||
COMMAND_TIMEOUT=10 # Default timeout for AT commands in seconds
|
||||
QUEUE_PRIORITY=3 # Medium-high priority (1 is highest for cell scan)
|
||||
MAX_TOKEN_WAIT=15 # Maximum seconds to wait for token acquisition
|
||||
SCRIPT_NAME_LOG="quecprofiles_daemon"
|
||||
|
||||
# Initialize log file
|
||||
echo "$(date) - Starting QuecProfiles daemon with SA/NSA NR5G and TTL support (PID: $$)" >"$DEBUG_LOG"
|
||||
echo "$(date) - Starting QuecProfiles daemon with SA/NSA NR5G and TTL support (PID: $$)" >"$DETAILED_LOG"
|
||||
# Initialize log files and use centralized logging
|
||||
mkdir -p "$(dirname "$DEBUG_LOG")" "$(dirname "$DETAILED_LOG")"
|
||||
touch "$DEBUG_LOG" "$DETAILED_LOG"
|
||||
chmod 644 "$DEBUG_LOG" "$DETAILED_LOG"
|
||||
|
||||
# Function to log messages
|
||||
# Log startup message using centralized logging
|
||||
qm_log_info "service" "$SCRIPT_NAME_LOG" "Starting QuecProfiles daemon with SA/NSA NR5G and TTL support (PID: $$)"
|
||||
|
||||
# Also maintain file logging for compatibility
|
||||
echo "$(date) - Starting QuecProfiles daemon with SA/NSA NR5G and TTL support (PID: $$)" >"$DEBUG_LOG"
|
||||
echo "$(date) - Starting QuecProfiles daemon with SA/NSA NR5G and TTL support (PID: $$)" >"$DETAILED_LOG"
|
||||
|
||||
# Function to log messages - now uses centralized logging
|
||||
log_message() {
|
||||
local message="$1"
|
||||
local level="${2:-info}"
|
||||
local timestamp=$(date "+%Y-%m-%d %H:%M:%S")
|
||||
|
||||
# Log to system log
|
||||
# Use centralized logging
|
||||
case "$level" in
|
||||
"error")
|
||||
qm_log_error "service" "$SCRIPT_NAME_LOG" "$message"
|
||||
;;
|
||||
"warn")
|
||||
qm_log_warn "service" "$SCRIPT_NAME_LOG" "$message"
|
||||
;;
|
||||
"debug")
|
||||
qm_log_debug "service" "$SCRIPT_NAME_LOG" "$message"
|
||||
;;
|
||||
*)
|
||||
qm_log_info "service" "$SCRIPT_NAME_LOG" "$message"
|
||||
;;
|
||||
esac
|
||||
|
||||
# Also maintain system logging for compatibility
|
||||
logger -t quecprofiles_daemon -p "daemon.$level" "$message"
|
||||
|
||||
# Log to debug file
|
||||
# Log to debug file (maintain existing behavior)
|
||||
echo "[$timestamp] [$level] $message" >>"$DEBUG_LOG"
|
||||
|
||||
# For detailed logs or errors
|
||||
# For detailed logs or errors (maintain existing behavior)
|
||||
if [ "$level" = "error" ] || [ "$level" = "debug" ]; then
|
||||
echo "[$timestamp] [$level] $message" >>"$DETAILED_LOG"
|
||||
fi
|
||||
@@ -607,6 +634,7 @@ apply_profile_settings() {
|
||||
local current_nsa_nr5g_bands="${14}"
|
||||
local current_imei="${15}"
|
||||
local iccid="${16}"
|
||||
local mobile_provider="${17}"
|
||||
|
||||
# Set TTL to 0 (disabled) if not specified
|
||||
ttl="${ttl:-0}"
|
||||
@@ -619,6 +647,7 @@ apply_profile_settings() {
|
||||
log_message "- APN: $apn ($pdp_type)" "info"
|
||||
log_message "- IMEI: $imei" "info"
|
||||
log_message "- TTL: $ttl" "info"
|
||||
log_message "- Mobile Provider: $mobile_provider" "info"
|
||||
|
||||
# Check if any changes are needed using improved comparison
|
||||
local needs_apn_change=0
|
||||
@@ -630,6 +659,7 @@ apply_profile_settings() {
|
||||
local needs_ttl_change=0
|
||||
local changes_needed=0
|
||||
local requires_reboot=0
|
||||
local change_for_reboot=""
|
||||
|
||||
# Use normalized comparison
|
||||
compare_values "$current_apn" "$apn" "apn" && needs_apn_change=1 && changes_needed=1
|
||||
@@ -804,6 +834,7 @@ apply_profile_settings() {
|
||||
if [ $? -eq 0 ]; then
|
||||
changes_made=1
|
||||
requires_reboot=1
|
||||
change_for_reboot="IMEI"
|
||||
log_message "IMEI changed successfully to $imei (device will reboot)" "info"
|
||||
update_track "rebooting" "IMEI changed, device will reboot" "$profile_name" "95"
|
||||
else
|
||||
@@ -813,9 +844,56 @@ apply_profile_settings() {
|
||||
fi
|
||||
fi
|
||||
|
||||
# Apply unique rule setup for Verizon, but also handle "Other" Mobile Providers because of MPDN_rule shenanigans
|
||||
# Probably requires reboot
|
||||
output_check=$(execute_at_command "AT+QMAP=\"mpdn_rule\"")
|
||||
sleep 1 # Short delay to ensure command is processed
|
||||
qmap_rule0=$(echo "$output_check" | grep '+QMAP: "MPDN_rule",0,')
|
||||
qmap_ippt_rule0=$(echo "$qmap_rule0" | cut -d',' -f5)
|
||||
if [ $apply_success -eq 1 ] && [ -n "$mobile_provider" ]; then
|
||||
if [ "$mobile_provider" = "Verizon" ]; then
|
||||
# If Verizon, data call should be set to rule 3, AT+QMAP="mpdn_rule",0,3,0,0,1
|
||||
if echo "$qmap_rule0" | awk -F',' '{exit !($2==0 && $3==3 && $6==1)}'; then
|
||||
log_message "Verizon rule already set correctly, no changes needed" "info"
|
||||
else
|
||||
log_message "Setting Verizon data call mpdn_rule to 3" "info"
|
||||
update_track "applying" "Setting Verizon data call rule to 3" "$profile_name" "100"
|
||||
verizon_cmd="AT+QMAP=\"mpdn_rule\",0,3,0,$qmap_ippt_rule0,1"
|
||||
execute_at_command "$verizon_cmd" 10 "$token_id" >/dev/null
|
||||
sleep 1 # Short delay to ensure command is processed
|
||||
fi
|
||||
elif [ "$mobile_provider" = "Other" ]; then
|
||||
# Check if MPDN_rule 0 is already set to all zeros
|
||||
if echo "$qmap_rule0" | awk -F',' '{exit !($2==0 && $3==0 && $6==0)}'; then
|
||||
log_message "Default rule already set correctly, no changes needed" "info"
|
||||
else
|
||||
log_message "Setting to default mpdn_rule and releasing" "info"
|
||||
update_track "applying" "Setting Default data call mpdn_rule to 0" "$profile_name" "100"
|
||||
def_cmd1="AT+QMAP=\"mpdn_rule\",0"
|
||||
execute_at_command "$def_cmd1" 10 "$token_id"
|
||||
sleep 1 # Short delay to ensure command is processed
|
||||
def_cmd2="AT+QMAP=\"mpdn_rule\",0,1,0,$qmap_ippt_rule0,1"
|
||||
execute_at_command "$def_cmd2" 10 "$token_id"
|
||||
sleep 1 # Short delay to ensure command is processed
|
||||
if [ "$qmap_ippt_rule0" = "0" ]; then
|
||||
log_message "IPPT is disabled for rule, release the MPDN_rule" "info"
|
||||
def_cmd3="AT+QMAP=\"mpdn_rule\",0"
|
||||
execute_at_command "$def_cmd3" 10 "$token_id"
|
||||
sleep 1 # Short delay to ensure command is processed
|
||||
if [ "$(cat /sys/devices/soc0/machine)" = "SDXPINN" ]; then
|
||||
requires_reboot=1
|
||||
change_for_reboot="MPDN_rule"
|
||||
update_track "rebooting" "MPDN_rule released, device will reboot" "$profile_name" "105"
|
||||
fi
|
||||
else
|
||||
log_message "IPPT is enabled for rule0 not releasing MPDN_rule, no reboot needed: IPPT Value $qmap_ippt_rule0" "info"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# Release token
|
||||
release_token "$token_id"
|
||||
|
||||
# Mark profile as applied if changes were made
|
||||
if [ $changes_made -eq 1 ]; then
|
||||
mark_profile_applied "$iccid" "$profile_name"
|
||||
@@ -824,7 +902,7 @@ apply_profile_settings() {
|
||||
# If IMEI was changed, need to reboot
|
||||
if [ $requires_reboot -eq 1 ]; then
|
||||
log_message "IMEI change requires reboot, scheduling reboot..." "info"
|
||||
update_track "rebooting" "Device is rebooting to apply IMEI change" "$profile_name" "100"
|
||||
update_track "rebooting" "Device is rebooting to apply $change_for_reboot change" "$profile_name" "100"
|
||||
sleep 2
|
||||
reboot &
|
||||
return 0
|
||||
@@ -913,11 +991,12 @@ check_profile() {
|
||||
local pdp_type=$(uci -q get quecprofiles.$profile_index.pdp_type)
|
||||
local imei=$(uci -q get quecprofiles.$profile_index.imei)
|
||||
local ttl=$(uci -q get quecprofiles.$profile_index.ttl)
|
||||
|
||||
local mobile_provider=$(uci -q get quecprofiles.$profile_index.mobile_provider)
|
||||
|
||||
# Check if profile is paused
|
||||
local paused=$(uci -q get quecprofiles.$profile_index.paused)
|
||||
paused="${paused:-0}" # Default to not paused if not set
|
||||
|
||||
|
||||
# Skip applying paused profiles
|
||||
if [ "$paused" = "1" ]; then
|
||||
log_message "Profile '$profile_name' is paused, skipping application" "info"
|
||||
@@ -982,7 +1061,7 @@ check_profile() {
|
||||
# Apply profile settings with the new parameters
|
||||
apply_profile_settings "$profile_name" "$network_type" "$lte_bands" "$sa_nr5g_bands" "$nsa_nr5g_bands" \
|
||||
"$apn" "$pdp_type" "$imei" "$ttl" "$current_apn" "$current_mode" "$current_lte_bands" \
|
||||
"$current_sa_nr5g_bands" "$current_nsa_nr5g_bands" "$current_imei" "$current_iccid"
|
||||
"$current_sa_nr5g_bands" "$current_nsa_nr5g_bands" "$current_imei" "$current_iccid" "$mobile_provider"
|
||||
return $?
|
||||
else
|
||||
log_message "Automatic profile switching is disabled, not applying profile" "info"
|
||||
@@ -1038,7 +1117,7 @@ main() {
|
||||
while [ $sleep_counter -lt $check_interval ]; do
|
||||
sleep 5
|
||||
sleep_counter=$((sleep_counter + 5))
|
||||
|
||||
|
||||
# Check for manual trigger during sleep
|
||||
if [ -f "$CHECK_TRIGGER" ]; then
|
||||
log_message "Manual check triggered during sleep" "info"
|
||||
|
||||
Reference in New Issue
Block a user