quecmanager-beta fixes
Co-Authored-By: Russel Yasol <73575327+dr-dolomite@users.noreply.github.com>
This commit is contained in:
@@ -1,39 +0,0 @@
|
||||
#!/bin/sh
|
||||
echo "Content-type: application/json"
|
||||
echo ""
|
||||
|
||||
CONFIG_FILE="/etc/quecmanager/imei_config.txt"
|
||||
|
||||
if [ ! -f "$CONFIG_FILE" ]; then
|
||||
echo "{}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Read the configuration file
|
||||
iccidProfile1=$(grep "^iccidProfile1=" "$CONFIG_FILE" | cut -d'=' -f2)
|
||||
imeiProfile1=$(grep "^imeiProfile1=" "$CONFIG_FILE" | cut -d'=' -f2)
|
||||
iccidProfile2=$(grep "^iccidProfile2=" "$CONFIG_FILE" | cut -d'=' -f2)
|
||||
imeiProfile2=$(grep "^imeiProfile2=" "$CONFIG_FILE" | cut -d'=' -f2)
|
||||
|
||||
# Build the JSON response
|
||||
echo "{"
|
||||
|
||||
# Add Profile 1 if it exists
|
||||
if [ -n "$iccidProfile1" ]; then
|
||||
echo " \"profile1\": {"
|
||||
echo " \"iccid\": \"$iccidProfile1\","
|
||||
echo " \"imei\": \"$imeiProfile1\""
|
||||
echo " }"
|
||||
# Add comma if Profile 2 exists
|
||||
[ -n "$iccidProfile2" ] && echo " ,"
|
||||
fi
|
||||
|
||||
# Add Profile 2 if it exists
|
||||
if [ -n "$iccidProfile2" ]; then
|
||||
echo " \"profile2\": {"
|
||||
echo " \"iccid\": \"$iccidProfile2\","
|
||||
echo " \"imei\": \"$imeiProfile2\""
|
||||
echo " }"
|
||||
fi
|
||||
|
||||
echo "}"
|
||||
64
ipk-source/sdxpinn-quecmanager-beta/root/www/cgi-bin/settings/force-rerun.sh
Executable file
64
ipk-source/sdxpinn-quecmanager-beta/root/www/cgi-bin/settings/force-rerun.sh
Executable file
@@ -0,0 +1,64 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Send CGI headers first
|
||||
echo "Content-Type: application/json"
|
||||
echo "Cache-Control: no-cache"
|
||||
echo
|
||||
|
||||
# Initialize variables for file paths
|
||||
APN_SCRIPT="/etc/quecmanager/apn_profile/apnProfiles.sh"
|
||||
IMEI_SCRIPT="/etc/quecmanager/imei_profile/imeiProfiles.sh"
|
||||
|
||||
# Function to output JSON
|
||||
output_json() {
|
||||
local status="$1"
|
||||
local message="$2"
|
||||
echo "{\"status\": \"$status\", \"message\": \"$message\"}"
|
||||
}
|
||||
|
||||
# Function to execute script if it exists
|
||||
execute_if_exists() {
|
||||
local script_path="$1"
|
||||
|
||||
if [ -f "$script_path" ] && [ -x "$script_path" ]; then
|
||||
$script_path >/dev/null 2>&1
|
||||
return $?
|
||||
fi
|
||||
return 2
|
||||
}
|
||||
|
||||
# Main execution
|
||||
main() {
|
||||
scripts_executed=0
|
||||
has_error=0
|
||||
|
||||
# Try to execute APN script
|
||||
execute_if_exists "$APN_SCRIPT"
|
||||
apn_result=$?
|
||||
if [ $apn_result -eq 0 ]; then
|
||||
scripts_executed=$(($scripts_executed + 1))
|
||||
elif [ $apn_result -eq 1 ]; then
|
||||
has_error=1
|
||||
fi
|
||||
|
||||
# Try to execute IMEI script
|
||||
execute_if_exists "$IMEI_SCRIPT"
|
||||
imei_result=$?
|
||||
if [ $imei_result -eq 0 ]; then
|
||||
scripts_executed=$(($scripts_executed + 1))
|
||||
elif [ $imei_result -eq 1 ]; then
|
||||
has_error=1
|
||||
fi
|
||||
|
||||
# Output appropriate message based on results
|
||||
if [ $scripts_executed -eq 0 ]; then
|
||||
output_json "info" "No scripts to restart"
|
||||
elif [ $has_error -eq 1 ]; then
|
||||
output_json "error" "Error executing one or more scripts"
|
||||
else
|
||||
output_json "success" "Scripts restarted successfully"
|
||||
fi
|
||||
}
|
||||
|
||||
# Run main function
|
||||
main
|
||||
11
ipk-source/sdxpinn-quecmanager-beta/root/www/cgi-bin/settings/get-ip.sh
Executable file
11
ipk-source/sdxpinn-quecmanager-beta/root/www/cgi-bin/settings/get-ip.sh
Executable file
@@ -0,0 +1,11 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Set the content type to JSON
|
||||
echo "Content-Type: application/json"
|
||||
echo ""
|
||||
|
||||
# Get the IP address of the br-lan interface
|
||||
brlan_ip=$(ip route | grep 'dev br-lan proto kernel scope link' | awk '{print $9}')
|
||||
|
||||
# Output the IP in JSON format
|
||||
echo "{\"br_lan_ip\": \"$brlan_ip\"}"
|
||||
Reference in New Issue
Block a user