Revert "temporarily reverted back at_queue scripts"

This reverts commit 5daf4bb388.
This commit is contained in:
Cameron Thompson
2025-08-27 23:40:26 -04:00
parent 20c2f37452
commit 1442ce21eb

View File

@@ -2,7 +2,6 @@
# AT Queue Client for OpenWRT # AT Queue Client for OpenWRT
# Located in /www/cgi-bin/services/at_queue_client # Located in /www/cgi-bin/services/at_queue_client
AUTH_FILE="/tmp/auth_success"
QUEUE_DIR="/tmp/at_queue" QUEUE_DIR="/tmp/at_queue"
RESULTS_DIR="$QUEUE_DIR/results" RESULTS_DIR="$QUEUE_DIR/results"
QUEUE_MANAGER="/www/cgi-bin/services/at_queue_manager.sh" QUEUE_MANAGER="/www/cgi-bin/services/at_queue_manager.sh"
@@ -185,32 +184,6 @@ if [ "${SCRIPT_NAME}" != "" ]; then
# Output headers only once at the beginning # Output headers only once at the beginning
echo "Content-Type: application/json" echo "Content-Type: application/json"
echo "" echo ""
# Get Token from Authorization Header
TOKEN="${HTTP_AUTHORIZATION}"
if [ ! -f $AUTH_FILE ]; then
output_json "{\"error\":\"Unauthenticated Request\"}" "0"
exit 1
fi
if [ -z "$TOKEN" ] || "${TOKEN}" = "" || [ $(grep "${TOKEN}" "${AUTH_FILE}" | wc -l) -eq 0 ]; then
output_json "{\"response\": { \"status\": \"error\", \"raw_output\": \"Not Authorized\" }, \"command\": {\"timestamp\": \"$(date +%Y%m%d'T'%H%M%S)\"}, \"error\":\"Not Authorized\"}" "0"
exit 1
fi
# Check if token is within 2 hours
TOKEN_LINE=$(grep "${TOKEN}" "${AUTH_FILE}")
TOKEN_DATE=$(echo "$TOKEN_LINE" | awk '{print $1}' | sed 's/T/ /')
TOKEN_TIME=$(date -d "$TOKEN_DATE" +%s 2>/dev/null)
NOW_TIME=$(date +%s)
MAX_AGE=$((2 * 3600)) # 2 hours in seconds
if [ -z "$TOKEN_TIME" ] || [ $((NOW_TIME - TOKEN_TIME)) -gt $MAX_AGE ]; then
output_json "{ \"response\": { \"status\": \"error\", \"raw_output\": \"Token expired. Reauthenticate to get new token.\" }, \"command\": {\"timestamp\": \"$(date +%Y%m%d'T'%H%M%S)\"}, \"error\":\"Token expired\"}" "0"
# Cleanup/Remove token from file
sed -i -e "s/.*${TOKEN}.*//g" /tmp/auth_success 2>/dev/null
exit 1
fi
# Parse query string # Parse query string
eval $(echo "$QUERY_STRING" | sed 's/&/;/g') eval $(echo "$QUERY_STRING" | sed 's/&/;/g')