Ready for version 1.1.2

PR for the main repository, version 1.1.2 with sms_tool as the major change
This commit is contained in:
Russel Yasol
2025-01-17 14:29:29 +08:00
parent 622d0d9361
commit 397e0de45a
139 changed files with 168 additions and 2883 deletions

View File

@@ -1,5 +1,5 @@
Package: sdxpinn-quecmanager-beta Package: sdxpinn-quecmanager-beta
Version: 1.1.0-6 Version: 1.1.2
Architecture: aarch64_cortex-a53 Architecture: aarch64_cortex-a53
Maintainer: Russel Yasol dr-dolomite@github.com Cameron Thompson iamromulan@github.com Maintainer: Russel Yasol dr-dolomite@github.com Cameron Thompson iamromulan@github.com
Description: A custom web UI desgined to run alongside luci for Quectel RM55x modems Description: A custom web UI desgined to run alongside luci for Quectel RM55x modems

View File

@@ -1,21 +1,32 @@
#!/bin/sh /etc/rc.common #!/bin/sh /etc/rc.common
START=49 START=99
STOP=10 STOP=10
USE_PROCD=1 USE_PROCD=1
start_service() { start_service() {
echo "Starting QuecManager services" # echo "Starting QuecManager services"
echo "Executed"
echo "Starting Signal Metrics Logger"
# Start Signal Metrics Logger
procd_open_instance procd_open_instance
procd_set_param command /www/cgi-bin/services/log_signal_metrics.sh procd_set_param command /www/cgi-bin/services/log_signal_metrics.sh
procd_set_param respawn procd_set_param respawn
procd_set_param stdout 1 procd_set_param stdout 1
procd_set_param stderr 1 procd_set_param stderr 1
procd_close_instance procd_close_instance
procd_open_instance
procd_set_param command /www/cgi-bin/services/at_queue_processor.sh
procd_set_param respawn
procd_set_param stdout 1
procd_set_param stderr 1
procd_close_instance
procd_open_instance
procd_set_param command /www/cgi-bin/services/clear_logs.sh
procd_set_param respawn
procd_set_param stdout 1
procd_set_param stderr 1
procd_close_instance
echo "Signal Metrics Logger Running" echo "Signal Metrics Logger Running"
echo "All QuecManager services Running" echo "All QuecManager services Running"
} }

View File

@@ -1,4 +0,0 @@
AT_port = dev/smd11
AT_port_custom = dev/smd7
data_refresh_rate = 5000
# end of config (don't remove this line)

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1 +0,0 @@
self.__BUILD_MANIFEST=function(r,e,t){return{__rewrites:{afterFiles:[],beforeFiles:[],fallback:[]},__routerFilterStatic:{numItems:22,errorRate:1e-4,numBits:422,numHashes:14,bitArray:[0,0,0,1,1,1,e,e,r,e,r,r,e,e,r,e,r,r,r,r,e,e,r,r,e,e,r,r,e,r,e,r,r,e,e,e,e,r,e,r,e,r,e,e,e,e,r,e,e,r,r,e,r,e,r,r,r,e,e,r,r,r,e,r,r,r,e,r,r,e,r,r,e,r,e,e,e,e,r,e,e,e,e,r,e,r,e,e,r,r,r,r,r,r,r,e,r,r,e,e,e,r,r,e,e,r,r,r,r,r,e,e,e,e,r,e,r,e,r,e,e,e,r,r,e,r,r,e,e,e,e,e,e,r,r,e,e,e,e,e,r,r,r,e,r,e,r,e,e,r,e,r,r,e,e,r,r,e,e,r,r,r,r,r,e,r,r,e,e,e,e,r,r,r,r,r,r,r,e,r,r,r,r,r,e,r,e,e,r,r,r,r,r,r,r,r,e,e,r,e,r,r,r,r,r,r,e,e,e,e,e,r,r,r,r,r,r,r,e,r,r,r,r,e,e,r,e,e,e,e,e,e,r,r,r,r,e,r,r,e,e,e,e,r,r,e,e,e,r,e,e,r,r,r,r,r,r,r,e,r,r,e,r,e,r,r,e,e,e,e,r,r,r,r,e,e,r,e,e,r,e,r,e,e,r,e,e,e,e,e,e,e,e,e,r,r,r,e,r,e,e,r,e,e,r,e,e,r,e,e,r,e,e,r,e,r,e,e,r,e,e,e,r,e,e,e,r,r,e,e,e,r,r,r,e,r,e,e,r,r,e,e,e,r,r,e,e,e,e,e,r,r,e,e,e,r,r,r,r,r,e,e,e,e,e,e,r,e,e,e,e,r,e,r,r,r,r,r,r,r,r,e,r,r,e,r,r,r,r,r,r,r,r,e,r,r,r,r,e,r,e,e,r,e,e,r,e,r,r,r,e,e,r,e,e,r,e,r,e,e,r,e]},__routerFilterDynamic:{numItems:e,errorRate:1e-4,numBits:e,numHashes:null,bitArray:[]},"/_error":["static/chunks/pages/_error-f347b70a71a8047b.js"],sortedPages:["/_app","/_error"]}}(1,0,0),self.__BUILD_MANIFEST_CB&&self.__BUILD_MANIFEST_CB();

View File

@@ -1 +0,0 @@
self.__BUILD_MANIFEST=function(r,e,t){return{__rewrites:{afterFiles:[],beforeFiles:[],fallback:[]},__routerFilterStatic:{numItems:21,errorRate:1e-4,numBits:403,numHashes:14,bitArray:[0,1,1,0,1,e,0,r,r,e,e,e,e,e,e,r,e,e,e,e,r,r,e,e,r,r,e,r,r,r,r,e,r,r,e,e,r,r,r,r,r,e,r,r,r,e,e,e,e,e,r,r,r,e,e,r,r,r,e,r,r,e,e,e,e,e,r,e,e,r,r,r,e,e,e,e,r,e,r,e,r,e,r,e,e,e,e,r,r,r,e,r,e,e,r,r,e,r,e,e,e,r,r,r,r,e,e,e,r,r,e,r,r,e,e,r,r,r,e,r,r,r,e,e,r,e,e,e,e,e,e,r,r,e,r,r,e,r,r,r,e,r,e,r,e,e,r,e,e,r,r,e,r,e,r,r,r,e,e,e,e,r,e,e,e,r,e,r,r,e,r,r,e,e,e,e,e,e,e,r,e,r,r,e,r,e,r,r,e,e,r,e,e,e,r,r,e,r,r,e,r,e,e,r,r,e,r,e,e,e,r,e,r,r,e,e,e,r,r,r,e,e,r,r,r,e,e,r,r,e,e,e,r,r,e,r,e,r,r,e,e,r,r,e,e,r,r,r,e,r,e,e,r,r,e,e,e,e,e,r,r,r,e,e,e,r,e,r,r,r,e,e,e,e,r,e,e,r,r,r,r,r,e,e,r,e,e,e,r,r,r,r,r,e,e,e,r,r,e,e,r,r,e,e,e,e,e,e,r,r,r,e,r,e,e,r,e,r,r,r,r,r,r,e,r,r,r,r,e,r,r,r,r,e,r,r,e,e,r,e,e,r,r,r,r,e,r,r,e,r,r,e,r,r,e,r,r,e,r,e,r,r,e,r,r,e,r,e,e,r,e,e,e,e,r,r,e,r,e,r,r,e,r,e,e,r,r,e,r,e,e,e,e,e,e,e,e,r,e,r,r,r,r]},__routerFilterDynamic:{numItems:r,errorRate:1e-4,numBits:r,numHashes:null,bitArray:[]},"/_error":["static/chunks/pages/_error-f347b70a71a8047b.js"],sortedPages:["/_app","/_error"]}}(0,1,0),self.__BUILD_MANIFEST_CB&&self.__BUILD_MANIFEST_CB();

View File

@@ -1 +0,0 @@
self.__SSG_MANIFEST=new Set([]);self.__SSG_MANIFEST_CB&&self.__SSG_MANIFEST_CB()

View File

@@ -0,0 +1 @@
self.__BUILD_MANIFEST=function(r,e,t){return{__rewrites:{afterFiles:[],beforeFiles:[],fallback:[]},__routerFilterStatic:{numItems:20,errorRate:1e-4,numBits:384,numHashes:14,bitArray:[1,0,0,0,1,1,e,r,r,r,r,e,e,r,e,e,r,r,r,e,e,e,e,e,r,r,e,e,r,e,e,r,r,r,r,e,e,e,e,e,e,r,e,r,e,e,e,r,r,e,r,e,r,e,e,e,e,e,r,e,r,r,r,r,e,r,e,e,e,e,r,e,r,r,e,r,e,e,r,r,e,r,e,e,e,r,r,r,e,r,e,r,e,e,r,r,e,r,e,e,r,r,e,e,r,r,r,e,r,r,e,r,e,r,e,r,r,r,e,e,r,r,r,e,r,e,e,e,e,r,e,r,r,r,r,r,r,r,r,r,e,r,e,e,e,r,r,e,e,e,e,r,e,r,r,r,r,r,r,r,e,r,e,e,e,r,e,r,r,e,e,r,e,r,r,r,e,e,r,r,r,e,e,r,r,e,r,e,r,r,r,r,r,r,e,e,r,r,r,e,e,e,e,r,e,r,r,r,e,r,r,r,e,r,e,r,r,r,r,r,e,r,e,e,e,r,e,e,r,e,e,e,r,r,r,r,r,e,e,r,e,e,e,e,r,e,r,r,e,r,r,e,e,r,e,e,r,r,r,e,r,e,r,r,r,e,r,e,e,r,r,e,r,e,r,e,r,r,r,e,r,e,r,r,r,r,e,e,e,e,r,r,e,e,r,r,r,e,r,e,r,r,e,r,e,r,r,r,e,e,r,e,r,r,r,r,r,e,r,e,r,r,r,r,e,e,e,r,r,r,e,r,r,r,r,r,e,e,r,r,e,e,e,r,r,e,r,r,r,e,r,r,e,r,e,r,r,e,e,e,e,e,r,e,e,r,e,e,r,e,r,r,e,r,e,r,e,e,r,r,r,e,r,e]},__routerFilterDynamic:{numItems:e,errorRate:1e-4,numBits:e,numHashes:null,bitArray:[]},"/_error":["static/chunks/pages/_error-f347b70a71a8047b.js"],sortedPages:["/_app","/_error"]}}(1,0,0),self.__BUILD_MANIFEST_CB&&self.__BUILD_MANIFEST_CB();

File diff suppressed because one or more lines are too long

View File

@@ -1 +0,0 @@
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7040,9188],{44833:()=>{}},_=>{var e=e=>_(_.s=e);_.O(0,[191,6035,7358],()=>e(44833)),_N_E=_.O()}]);

View File

@@ -1 +0,0 @@
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3075],{43946:(e,a,s)=>{Promise.resolve().then(s.bind(s,31753))},31753:(e,a,s)=>{"use strict";s.r(a),s.d(a,{default:()=>d});var t=s(20475);s(20107);var r=s(16118),l=s(9477),n=s.n(l);let d=e=>{let{children:a}=e,s=(0,r.usePathname)();return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:"mx-auto grid w-full max-w-6xl gap-2",children:(0,t.jsx)("h1",{className:"text-3xl font-semibold",children:"Experimental"})}),(0,t.jsxs)("div",{className:"mx-auto grid w-full max-w-6xl items-start gap-6 md:grid-cols-[180px_1fr] lg:grid-cols-[250px_1fr]",children:[(0,t.jsxs)("nav",{className:"grid gap-4 text-sm text-muted-foreground","x-chunk":"dashboard-04-chunk-0",children:[(0,t.jsx)(n(),{href:"/dashboard/experimental/quecwatch",className:"".concat("/dashboard/experimental/quecwatch/"===s?"font-semibold text-primary":"text-sm"),children:"QuecWatch"}),(0,t.jsx)(n(),{href:"/dashboard/experimental/keep-alive",className:"".concat("/dashboard/experimental/keep-alive/"===s?"font-semibold text-primary":"text-sm"),children:"Keep Alive"})]}),a]})]})}},16118:(e,a,s)=>{"use strict";var t=s(65834);s.o(t,"usePathname")&&s.d(a,{usePathname:function(){return t.usePathname}}),s.o(t,"useRouter")&&s.d(a,{useRouter:function(){return t.useRouter}})}},e=>{var a=a=>e(e.s=a);e.O(0,[9477,191,6035,7358],()=>a(43946)),_N_E=e.O()}]);

View File

@@ -1 +0,0 @@
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7040,9188],{44833:()=>{}},_=>{var e=e=>_(_.s=e);_.O(0,[191,6035,7358],()=>e(44833)),_N_E=_.O()}]);

View File

@@ -0,0 +1 @@
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7040],{44833:()=>{}},_=>{var e=e=>_(_.s=e);_.O(0,[191,6035,7358],()=>e(44833)),_N_E=_.O()}]);

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5680],{78190:(e,s,t)=>{Promise.resolve().then(t.bind(t,36994))},36994:(e,s,t)=>{"use strict";t.r(s),t.d(s,{default:()=>d});var r=t(20475);t(20107);var a=t(16118),n=t(9477),u=t.n(n);let d=e=>{let{children:s}=e,t=(0,a.usePathname)();return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"mx-auto grid w-full max-w-6xl gap-2",children:(0,r.jsx)("h1",{className:"text-3xl font-semibold",children:"Settings"})}),(0,r.jsxs)("div",{className:"mx-auto grid w-full max-w-6xl items-start gap-6 md:grid-cols-[180px_1fr] lg:grid-cols-[250px_1fr]",children:[(0,r.jsx)("nav",{className:"grid gap-4 text-sm text-muted-foreground","x-chunk":"dashboard-04-chunk-0",children:(0,r.jsx)(u(),{href:"/dashboard/settings/security",className:"".concat("/dashboard/settings/security/"===t?"font-semibold text-primary":"text-sm"),children:"Security"})}),s]})]})}},16118:(e,s,t)=>{"use strict";var r=t(65834);t.o(r,"usePathname")&&t.d(s,{usePathname:function(){return r.usePathname}}),t.o(r,"useRouter")&&t.d(s,{useRouter:function(){return r.useRouter}})}},e=>{var s=s=>e(e.s=s);e.O(0,[9477,191,6035,7358],()=>s(78190)),_N_E=e.O()}]);

View File

@@ -1 +0,0 @@
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5680],{55809:(e,s,t)=>{Promise.resolve().then(t.bind(t,36994))},36994:(e,s,t)=>{"use strict";t.r(s),t.d(s,{default:()=>l});var a=t(20475);t(20107);var r=t(16118),n=t(9477),d=t.n(n);let l=e=>{let{children:s}=e,t=(0,r.usePathname)();return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"mx-auto grid w-full max-w-6xl gap-2",children:(0,a.jsx)("h1",{className:"text-3xl font-semibold",children:"Settings"})}),(0,a.jsxs)("div",{className:"mx-auto grid w-full max-w-6xl items-start gap-6 md:grid-cols-[180px_1fr] lg:grid-cols-[250px_1fr]",children:[(0,a.jsxs)("nav",{className:"grid gap-4 text-sm text-muted-foreground","x-chunk":"dashboard-04-chunk-0",children:[(0,a.jsx)(d(),{href:"/dashboard/settings/general",className:"".concat("/dashboard/settings/general/"===t?"font-semibold text-primary":"text-sm"),children:"General"}),(0,a.jsx)(d(),{href:"/dashboard/settings/security",className:"".concat("/dashboard/settings/security/"===t?"font-semibold text-primary":"text-sm"),children:"Security"})]}),s]})]})}},16118:(e,s,t)=>{"use strict";var a=t(65834);t.o(a,"usePathname")&&t.d(s,{usePathname:function(){return a.usePathname}}),t.o(a,"useRouter")&&t.d(s,{useRouter:function(){return a.useRouter}})}},e=>{var s=s=>e(e.s=s);e.O(0,[9477,191,6035,7358],()=>s(55809)),_N_E=e.O()}]);

View File

@@ -1 +0,0 @@
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5680],{78190:(e,s,t)=>{Promise.resolve().then(t.bind(t,36994))},36994:(e,s,t)=>{"use strict";t.r(s),t.d(s,{default:()=>l});var a=t(20475);t(20107);var r=t(16118),n=t(9477),d=t.n(n);let l=e=>{let{children:s}=e,t=(0,r.usePathname)();return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"mx-auto grid w-full max-w-6xl gap-2",children:(0,a.jsx)("h1",{className:"text-3xl font-semibold",children:"Settings"})}),(0,a.jsxs)("div",{className:"mx-auto grid w-full max-w-6xl items-start gap-6 md:grid-cols-[180px_1fr] lg:grid-cols-[250px_1fr]",children:[(0,a.jsxs)("nav",{className:"grid gap-4 text-sm text-muted-foreground","x-chunk":"dashboard-04-chunk-0",children:[(0,a.jsx)(d(),{href:"/dashboard/settings/general",className:"".concat("/dashboard/settings/general/"===t?"font-semibold text-primary":"text-sm"),children:"General"}),(0,a.jsx)(d(),{href:"/dashboard/settings/security",className:"".concat("/dashboard/settings/security/"===t?"font-semibold text-primary":"text-sm"),children:"Security"})]}),s]})]})}},16118:(e,s,t)=>{"use strict";var a=t(65834);t.o(a,"usePathname")&&t.d(s,{usePathname:function(){return a.usePathname}}),t.o(a,"useRouter")&&t.d(s,{useRouter:function(){return a.useRouter}})}},e=>{var s=s=>e(e.s=s);e.O(0,[9477,191,6035,7358],()=>s(78190)),_N_E=e.O()}]);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1 +0,0 @@
self.__BUILD_MANIFEST=function(r,e,t){return{__rewrites:{afterFiles:[],beforeFiles:[],fallback:[]},__routerFilterStatic:{numItems:21,errorRate:1e-4,numBits:403,numHashes:14,bitArray:[0,1,1,0,1,e,0,r,r,e,e,e,e,e,e,r,e,e,e,e,r,r,e,e,r,r,e,r,r,r,r,e,r,r,e,e,r,r,r,r,r,e,r,r,r,e,e,e,e,e,r,r,r,e,e,r,r,r,e,r,r,e,e,e,e,e,r,e,e,r,r,r,e,e,e,e,r,e,r,e,r,e,r,e,e,e,e,r,r,r,e,r,e,e,r,r,e,r,e,e,e,r,r,r,r,e,e,e,r,r,e,r,r,e,e,r,r,r,e,r,r,r,e,e,r,e,e,e,e,e,e,r,r,e,r,r,e,r,r,r,e,r,e,r,e,e,r,e,e,r,r,e,r,e,r,r,r,e,e,e,e,r,e,e,e,r,e,r,r,e,r,r,e,e,e,e,e,e,e,r,e,r,r,e,r,e,r,r,e,e,r,e,e,e,r,r,e,r,r,e,r,e,e,r,r,e,r,e,e,e,r,e,r,r,e,e,e,r,r,r,e,e,r,r,r,e,e,r,r,e,e,e,r,r,e,r,e,r,r,e,e,r,r,e,e,r,r,r,e,r,e,e,r,r,e,e,e,e,e,r,r,r,e,e,e,r,e,r,r,r,e,e,e,e,r,e,e,r,r,r,r,r,e,e,r,e,e,e,r,r,r,r,r,e,e,e,r,r,e,e,r,r,e,e,e,e,e,e,r,r,r,e,r,e,e,r,e,r,r,r,r,r,r,e,r,r,r,r,e,r,r,r,r,e,r,r,e,e,r,e,e,r,r,r,r,e,r,r,e,r,r,e,r,r,e,r,r,e,r,e,r,r,e,r,r,e,r,e,e,r,e,e,e,e,r,r,e,r,e,r,r,e,r,e,e,r,r,e,r,e,e,e,e,e,e,e,e,r,e,r,r,r,r]},__routerFilterDynamic:{numItems:r,errorRate:1e-4,numBits:r,numHashes:null,bitArray:[]},"/_error":["static/chunks/pages/_error-f347b70a71a8047b.js"],sortedPages:["/_app","/_error"]}}(0,1,0),self.__BUILD_MANIFEST_CB&&self.__BUILD_MANIFEST_CB();

View File

@@ -1 +0,0 @@
self.__SSG_MANIFEST=new Set([]);self.__SSG_MANIFEST_CB&&self.__SSG_MANIFEST_CB()

View File

@@ -1,26 +0,0 @@
#!/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

View File

@@ -1,49 +0,0 @@
#!/bin/sh
echo "Content-type: application/json"
echo ""
# Create a temporary file to store the processed data
temp_file=$(mktemp)
# Process ARP entries and store in temporary file
arp -a | while IFS= read -r line; do
if [ -n "$line" ]; then
# Extract hostname (or IP if hostname is "?"), IP, and MAC
hostname=$(echo "$line" | awk '{print $1}')
ip=$(echo "$line" | awk -F '[()]' '{print $2}')
mac=$(echo "$line" | awk '{print $4}')
# Skip entries without valid MAC addresses
if [ "$mac" = "<incomplete>" ]; then
continue
fi
# If hostname is "?", use the IP address instead
if [ "$hostname" = "?" ]; then
hostname="$ip"
fi
# Store each entry in the temp file
echo "$hostname:$ip:$mac" >> "$temp_file"
fi
done
# Initialize JSON array
echo -n "["
# Process the temporary file to create JSON
first=true
while IFS=: read -r hostname ip mac; do
if [ "$first" = true ]; then
first=false
else
echo -n ","
fi
echo -n "{\"hostname\":\"$hostname\",\"ip\":\"$ip\",\"mac\":\"$mac\"}"
done < "$temp_file"
# Close the JSON array
echo "]"
# Clean up
rm -f "$temp_file"

View File

@@ -1,90 +0,0 @@
#!/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

View File

@@ -1,94 +0,0 @@
#!/bin/sh
echo "Content-type: application/json"
echo ""
ttl_file="/etc/firewall.user.ttl"
lan_utils_script="/etc/data/lanUtils.sh"
setup_persistent_config() {
if [ ! -f "$lan_utils_script" ]; then
echo "{\"success\": false, \"error\": \"lanUtils.sh not found\"}"
return 1
fi
# Backup the original script if not already done
if [ ! -f "${lan_utils_script}.bak" ]; then
cp "$lan_utils_script" "${lan_utils_script}.bak"
fi
# Add the local ttl_firewall_file line if it's not already present
if ! grep -q "local ttl_firewall_file" "$lan_utils_script"; then
sed -i '/local tcpmss_firewall_filev6/a \ local ttl_firewall_file=/etc/firewall.user.ttl' "$lan_utils_script"
fi
# Add the condition to include the ttl_firewall_file if it's not already present
if ! grep -q "if \[ -f \"\$ttl_firewall_file\" \]; then" "$lan_utils_script"; then
sed -i '/if \[ -f "\$tcpmss_firewall_filev6" \]; then/i \ if [ -f "\$ttl_firewall_file" ]; then\n cat \$ttl_firewall_file >> \$firewall_file\n fi' "$lan_utils_script"
fi
}
clear_existing_rules() {
local current_ttl=$1
if [ -n "$current_ttl" ]; then
iptables -t mangle -D POSTROUTING -o rmnet+ -j TTL --ttl-set "$current_ttl" 2>/dev/null
ip6tables -t mangle -D POSTROUTING -o rmnet+ -j HL --hl-set "$current_ttl" 2>/dev/null
fi
}
case "$REQUEST_METHOD" in
GET)
# Ensure consistent JSON format for GET requests
if [ -s "$ttl_file" ]; then
ttl_value=$(grep 'iptables -t mangle -A POSTROUTING' "$ttl_file" | awk '{for(i=1;i<=NF;i++){if($i=="--ttl-set"){print $(i+1)}}}')
# Ensure ttl_value is a number, default to 0 if not
if ! [[ "$ttl_value" =~ ^[0-9]+$ ]]; then
ttl_value=0
fi
echo "{\"isEnabled\": true, \"currentValue\": $ttl_value}"
else
echo "{\"isEnabled\": false, \"currentValue\": 0}"
fi
;;
POST)
read -r post_data
ttl_value=$(echo "$post_data" | sed 's/ttl=//')
# Ensure ttl_file exists
touch "$ttl_file" 2>/dev/null
if [ ! -f "$ttl_file" ]; then
echo "{\"success\": false, \"error\": \"Cannot create TTL file\"}"
exit 1
fi
# Setup persistent configuration
setup_persistent_config
# Get current TTL value for cleanup
current_ttl=$(grep 'iptables -t mangle -A POSTROUTING' "$ttl_file" | awk '{for(i=1;i<=NF;i++){if($i=="--ttl-set"){print $(i+1)}}}')
if ! [[ "$ttl_value" =~ ^[0-9]+$ ]]; then
echo "{\"success\": false, \"error\": \"Invalid TTL value\"}"
elif [ "$ttl_value" = "0" ]; then
clear_existing_rules "$current_ttl"
> "$ttl_file"
echo "{\"success\": true}"
else
# Clear existing rules
clear_existing_rules "$current_ttl"
# Set new rules
echo "iptables -t mangle -A POSTROUTING -o rmnet+ -j TTL --ttl-set $ttl_value" > "$ttl_file"
echo "ip6tables -t mangle -A POSTROUTING -o rmnet+ -j HL --hl-set $ttl_value" >> "$ttl_file"
# Apply the rules
iptables -t mangle -A POSTROUTING -o rmnet+ -j TTL --ttl-set "$ttl_value"
ip6tables -t mangle -A POSTROUTING -o rmnet+ -j HL --hl-set "$ttl_value"
echo "{\"success\": true}"
fi
;;
*)
echo "{\"success\": false, \"error\": \"Invalid request method\"}"
;;
esac

View File

@@ -1,78 +0,0 @@
#!/bin/sh
# Function to URL-decode the input
urldecode() {
local data="$1"
echo -e "$(echo "$data" | sed 's/+/ /g;s/%\(..\)/\\x\1/g;')"
}
# Set content-type for JSON response
echo "Content-type: application/json"
echo ""
# Read the input from POST data
read INPUT_DATA
# Extract the command from the input data (format: command=AT+COMMAND)
RAW_COMMAND=$(echo "$INPUT_DATA" | sed 's/command=//g')
# URL-decode the command
COMMAND=$(urldecode "$RAW_COMMAND")
# Define unique input/output files and AT port
INPUT_FILE="/tmp/custom_input_$$.txt"
OUTPUT_FILE="/tmp/custom_output_$$.txt"
# Debug logging
DEBUG_LOG="/tmp/debug.log"
echo "Starting at_handler script at $(date)" > "$DEBUG_LOG"
CONFIG_FILE="/etc/quecManager.conf"
# Check config file
if [ ! -f "$CONFIG_FILE" ]; then
echo "Config file not found: $CONFIG_FILE" >> "$DEBUG_LOG"
echo '{"error": "Config file not found"}'
exit 1
fi
# Get AT_PORT with debug logging
AT_PORT=$(head -n 1 "$CONFIG_FILE" | cut -d'=' -f2 | tr -d ' \n\r' | sed 's|^dev/||')
echo "Raw config line: $(head -n 1 "$CONFIG_FILE")" >> "$DEBUG_LOG"
echo "Extracted AT_PORT: '$AT_PORT'" >> "$DEBUG_LOG"
if [ -z "$AT_PORT" ]; then
echo "AT_PORT is empty" >> "$DEBUG_LOG"
output_error "Failed to read AT_PORT from config"
fi
# Check if AT_PORT exists
if [ ! -c "/dev/$AT_PORT" ]; then
echo "AT_PORT device not found: /dev/$AT_PORT" >> "$DEBUG_LOG"
echo "Available smd devices:" >> "$DEBUG_LOG"
ls -l /dev/smd* >> "$DEBUG_LOG" 2>&1
output_error "AT_PORT device not found"
fi
# Write the command directly to the input file
echo "$COMMAND" > "$INPUT_FILE"
# Run the command using atinout
atinout "$INPUT_FILE" "/dev/$AT_PORT" "$OUTPUT_FILE"
# Read the output from output.txt
OUTPUT=$(cat "$OUTPUT_FILE")
# Escape special characters (like newlines and double quotes) for JSON compatibility
ESCAPED_OUTPUT=$(echo "$OUTPUT" | sed ':a;N;$!ba;s/\n/\\n/g; s/"/\\"/g')
# Escape double quotes in the command for JSON compatibility
ESCAPED_COMMAND=$(echo "$COMMAND" | sed 's/"/\\"/g')
# Create the JSON response
JSON_RESPONSE=$(printf "{\"command\":\"%s\",\"output\":\"%s\"}" "$ESCAPED_COMMAND" "$ESCAPED_OUTPUT")
# Return the output as a valid JSON response
echo "$JSON_RESPONSE"
# Clean up temporary files
rm "$INPUT_FILE" "$OUTPUT_FILE"

View File

@@ -1,45 +0,0 @@
#!/bin/sh
# Set Content-Type for CGI script
echo "Content-type: application/json"
echo ""
# Read POST data
read POST_DATA
# Debug log for generated hash
DEBUG_LOG = "/tmp/auth.log"
# Extract the password from POST data (URL encoded)
USER="root"
INPUT_PASSWORD=$(echo "$POST_DATA" | sed -n 's/^.*password=\([^&]*\).*$/\1/p')
# URL-decode the password (replace + with space and decode %XX)
INPUT_PASSWORD=$(echo "$INPUT_PASSWORD" | sed 's/+/ /g;s/%\(..\)/\\x\1/g' | xargs -0 printf "%b")
# Extract the hashed password from /etc/shadow for the specified user
USER_SHADOW_ENTRY=$(grep "^$USER:" /etc/shadow)
if [ -z "$USER_SHADOW_ENTRY" ]; then
echo '{"state":"failed", "message":"User not found"}'
exit 1
fi
# Extract the password hash (it's the second field, colon-separated)
USER_HASH=$(echo "$USER_SHADOW_ENTRY" | cut -d: -f2)
# Extract the salt (MD5 uses the $1$ prefix followed by the salt)
SALT=$(echo "$USER_HASH" | cut -d'$' -f3)
# Generate a hash from the input password using the same salt
GENERATED_HASH=$(echo "$INPUT_PASSWORD" | openssl passwd -1 -salt "$SALT" -stdin)
# Log generated hash for debugging
echo "Generated hash: $GENERATED_HASH" >> $DEBUG_LOG
# Compare the generated hash with the one in the shadow file
if [ "$GENERATED_HASH" = "$USER_HASH" ]; then
echo '{"state":"success"}'
else
echo '{"state":"failed"}'
fi

View File

@@ -1,66 +0,0 @@
#!/bin/sh
echo "Content-type: application/json"
echo ""
# Initialize error flag
has_error=false
error_message=""
# Function to append to error message
append_error() {
if [ -z "$error_message" ]; then
error_message="$1"
else
error_message="$error_message; $1"
fi
has_error=true
}
# Remove the entire quecmanager directory
if [ -d "/etc/quecmanager/apn_profile/" ]; then
rm -rf /etc/quecmanager/apn_profile/
if [ $? -ne 0 ]; then
append_error "Failed to remove quecmanager directory"
fi
else
append_error "quecmanager directory not found"
fi
# Remove the line from rc.local
if [ -f "/etc/rc.local" ]; then
# Create a temporary file
temp_file=$(mktemp)
# Remove the apnProfiles.sh line and copy to temp file
sed '/\/etc\/quecmanager\/apnProfiles.sh/d' /etc/rc.local > "$temp_file"
# Check if sed command was successful
if [ $? -eq 0 ]; then
# Replace original file with modified version
mv "$temp_file" /etc/rc.local
if [ $? -ne 0 ]; then
append_error "Failed to update rc.local"
fi
else
append_error "Failed to modify rc.local"
rm -f "$temp_file"
fi
else
append_error "rc.local file not found"
fi
# Remove temporary files that might have been created
rm -f /tmp/apn_result.txt
rm -f /tmp/debug.log
rm -f /tmp/inputICCID.txt
rm -f /tmp/outputICCID.txt
rm -f /tmp/inputAPN.txt
rm -f /tmp/outputAPN.txt
# Return appropriate JSON response
if [ "$has_error" = true ]; then
echo "{\"status\": \"error\", \"message\": \"$error_message\"}"
else
echo "{\"status\": \"success\", \"message\": \"APN profiles and configuration successfully removed\"}"
fi

View File

@@ -1,45 +0,0 @@
#!/bin/sh
echo "Content-type: application/json"
echo ""
CONFIG_FILE="/etc/quecmanager/apn_profile/apn_config.txt"
if [ ! -f "$CONFIG_FILE" ]; then
echo "{}"
exit 0
fi
# Read the configuration file
iccidProfile1=$(grep "^iccidProfile1=" "$CONFIG_FILE" | cut -d'=' -f2)
apnProfile1=$(grep "^apnProfile1=" "$CONFIG_FILE" | cut -d'=' -f2)
pdpType1=$(grep "^pdpType1=" "$CONFIG_FILE" | cut -d'=' -f2)
iccidProfile2=$(grep "^iccidProfile2=" "$CONFIG_FILE" | cut -d'=' -f2)
apnProfile2=$(grep "^apnProfile2=" "$CONFIG_FILE" | cut -d'=' -f2)
pdpType2=$(grep "^pdpType2=" "$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 " \"apn\": \"$apnProfile1\","
echo " \"pdpType\": \"$pdpType1\""
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 " \"apn\": \"$apnProfile2\","
echo " \"pdpType\": \"$pdpType2\""
echo " }"
fi
echo "}"

View File

@@ -1,189 +0,0 @@
#!/bin/sh
# Parse POST data
read -r QUERY_STRING
# Function to urldecode
urldecode() {
echo -e "$(echo "$1" | sed 's/+/ /g;s/%\([0-9A-F][0-9A-F]\)/\\x\1/g')"
}
# Extract values from POST data
iccidProfile1=$(echo "$QUERY_STRING" | grep -o 'iccidProfile1=[^&]*' | cut -d= -f2)
apnProfile1=$(echo "$QUERY_STRING" | grep -o 'apnProfile1=[^&]*' | cut -d= -f2)
pdpType1=$(echo "$QUERY_STRING" | grep -o 'pdpType1=[^&]*' | cut -d= -f2)
iccidProfile2=$(echo "$QUERY_STRING" | grep -o 'iccidProfile2=[^&]*' | cut -d= -f2)
apnProfile2=$(echo "$QUERY_STRING" | grep -o 'apnProfile2=[^&]*' | cut -d= -f2)
pdpType2=$(echo "$QUERY_STRING" | grep -o 'pdpType2=[^&]*' | cut -d= -f2)
# URL decode the values
iccidProfile1=$(urldecode "$iccidProfile1")
apnProfile1=$(urldecode "$apnProfile1")
pdpType1=$(urldecode "$pdpType1")
iccidProfile2=$(urldecode "$iccidProfile2")
apnProfile2=$(urldecode "$apnProfile2")
pdpType2=$(urldecode "$pdpType2")
echo "Content-type: application/json"
echo ""
# Validate required first profile
if [ -z "$iccidProfile1" ] || [ -z "$apnProfile1" ] || [ -z "$pdpType1" ]; then
echo '{"status": "error", "message": "Profile 1 is required"}'
exit 1
fi
if [ ! -d /etc/quecmanager/apn_profile ]; then
mkdir -p /etc/quecmanager/apn_profile
fi
# Create a configuration file to store APN profiles (as plain text)
cat > /etc/quecmanager/apn_profile/apn_config.txt << EOF
iccidProfile1=$iccidProfile1
apnProfile1=$apnProfile1
pdpType1=$pdpType1
EOF
# Add second profile only if ICCID is provided
if [ -n "$iccidProfile2" ]; then
cat >> /etc/quecmanager/apn_profile/apn_config.txt << EOF
iccidProfile2=$iccidProfile2
apnProfile2=$apnProfile2
pdpType2=$pdpType2
EOF
fi
# Create the apnProfiles.sh script
cat > /etc/quecmanager/apn_profile/apnProfiles.sh << 'EOF'
#!/bin/sh
# Function to read config values
get_config_value() {
local key=$1
grep "^${key}=" /etc/quecmanager/apn_profile/apn_config.txt | cut -d'=' -f2
}
# Read configuration
iccidProfile1=$(get_config_value "iccidProfile1")
apnProfile1=$(get_config_value "apnProfile1")
pdpType1=$(get_config_value "pdpType1")
iccidProfile2=$(get_config_value "iccidProfile2")
apnProfile2=$(get_config_value "apnProfile2")
pdpType2=$(get_config_value "pdpType2")
# Debug logging
DEBUG_LOG="/tmp/debug.log"
echo "Starting script at $(date)" > "$DEBUG_LOG"
CONFIG_FILE="/etc/quecManager.conf"
# Check config file
if [ ! -f "$CONFIG_FILE" ]; then
echo "Config file not found: $CONFIG_FILE" >> "$DEBUG_LOG"
echo '{"error": "Config file not found"}'
exit 1
fi
# Get AT_PORT with debug logging
AT_PORT=$(head -n 1 "$CONFIG_FILE" | cut -d'=' -f2 | tr -d ' \n\r' | sed 's|^dev/||')
echo "Raw config line: $(head -n 1 "$CONFIG_FILE")" >> "$DEBUG_LOG"
echo "Extracted AT_PORT: '$AT_PORT'" >> "$DEBUG_LOG"
# List available devices for debugging
ls -l /dev/smd* >> "$DEBUG_LOG" 2>&1
if [ -z "$AT_PORT" ]; then
echo "AT_PORT is empty" >> "$DEBUG_LOG"
echo '{"error": "Failed to read AT_PORT from config"}'
exit 1
fi
# Check if AT_PORT exists
if [ ! -c "/dev/$AT_PORT" ]; then
echo "AT_PORT device not found: /dev/$AT_PORT" >> "$DEBUG_LOG"
echo "Available smd devices:" >> "$DEBUG_LOG"
ls -l /dev/smd* >> "$DEBUG_LOG" 2>&1
echo '{"error": "AT_PORT device not found"}'
exit 1
fi
# Function to get current ICCID
get_current_iccid() {
local input_file="/tmp/inputICCID.txt"
local output_file="/tmp/outputICCID.txt"
echo "AT+ICCID" > "$input_file"
atinout "$input_file" "/dev/$AT_PORT" "$output_file"
iccid=$(cat "$output_file" | grep "+ICCID:" | cut -d' ' -f2)
rm -f "$input_file" "$output_file"
echo "$iccid"
}
# Function to set APN
set_apn() {
local pdp_type="$1"
local apn="$2"
local input_file="/tmp/inputAPN.txt"
local output_file="/tmp/outputAPN.txt"
echo "AT+CGDCONT=1,\"$pdp_type\",\"$apn\";+COPS=2;+COPS=0" > "$input_file"
atinout "$input_file" "/dev/$AT_PORT" "$output_file"
local result=$(cat "$output_file")
rm -f "$input_file" "$output_file"
if echo "$result" | grep -q "OK"; then
return 0
else
return 1
fi
}
# Get current ICCID
current_iccid=$(get_current_iccid)
success=false
# Check ICCID against profile 1 (required)
if [ "$current_iccid" = "$iccidProfile1" ]; then
if set_apn "$pdpType1" "$apnProfile1"; then
success=true
fi
# Check ICCID against profile 2 (optional)
elif [ -n "$iccidProfile2" ] && [ "$current_iccid" = "$iccidProfile2" ]; then
if set_apn "$pdpType2" "$apnProfile2"; then
success=true
fi
fi
if [ "$success" = "true" ]; then
echo "APN set successfully" > /tmp/apn_result.txt
else
echo "Failed to set APN" > /tmp/apn_result.txt
fi
EOF
# Make the script executable
chmod +x /etc/quecmanager/apn_profile/apnProfiles.sh
# Add to rc.local if not already present
if ! grep -q "/etc/quecmanager/apn_profile/apnProfiles.sh" /etc/rc.local; then
sed -i '/^exit 0/i /etc/quecmanager/apn_profile/apnProfiles.sh' /etc/rc.local
fi
# Run the script immediately
/etc/quecmanager/apn_profile/apnProfiles.sh
# Check the result
if [ -f /tmp/apn_result.txt ]; then
result=$(cat /tmp/apn_result.txt)
rm -f /tmp/apn_result.txt
if [ "$result" = "APN set successfully" ]; then
echo '{"status": "success", "message": "APN profiles saved and applied successfully"}'
else
echo '{"status": "error", "message": "APN profiles saved but failed to apply"}'
fi
else
echo '{"status": "error", "message": "Something went wrong while processing APN profiles"}'
fi

View File

@@ -1,38 +0,0 @@
#!/bin/sh
# handle_sms.sh - CGI script to handle SMS web requests
# Content type declaration for CGI
echo "Content-type: application/json"
echo ""
# Check if atinout and jq are installed
if ! command -v atinout &> /dev/null || ! command -v jq &> /dev/null; then
echo '{"error": "Required tools (atinout or jq) are not installed"}'
exit 1
fi
# Check if the device exists
if [ ! -c "/dev/smd7" ]; then
echo '{"error": "Device /dev/smd7 not found"}'
exit 1
fi
# # Fetch all SMS messages and update the JSON file
# Disabled until the atinout bug is fixed
# if ! echo "AT+CMGL=\"ALL\"" | atinout - /dev/smd7 - | jq -R -s '
# split("\n") |
# map(select(length > 0)) |
# map(
# select(startswith("+CMGL:") or (. != "OK" and . != "ERROR"))
# ) |
# {messages: .}
# ' > /tmp/sms_inbox.json; then
# echo '{"error": "Failed to fetch SMS messages"}'
# exit 1
# fi
# Return the contents of the JSON file
if [ -f "/tmp/sms_inbox.json" ]; then
cat /tmp/sms_inbox.json
else
echo '{"error": "SMS inbox file not found"}'
fi

View File

@@ -1,66 +0,0 @@
#!/bin/sh
echo "Content-type: application/json"
echo ""
# Initialize error flag
has_error=false
error_message=""
# Function to append to error message
append_error() {
if [ -z "$error_message" ]; then
error_message="$1"
else
error_message="$error_message; $1"
fi
has_error=true
}
# Remove the entire quecmanager directory
if [ -d "/etc/quecmanager/imei_profile/" ]; then
rm -rf /etc/quecmanager/imei_profile/
if [ $? -ne 0 ]; then
append_error "Failed to remove quecmanager directory"
fi
else
append_error "quecmanager directory not found"
fi
# Remove the line from rc.local
if [ -f "/etc/rc.local" ]; then
# Create a temporary file
temp_file=$(mktemp)
# Remove the imeiProfiles.sh line and copy to temp file
sed '/\/etc\/quecmanager\/imeiProfiles.sh/d' /etc/rc.local > "$temp_file"
# Check if sed command was successful
if [ $? -eq 0 ]; then
# Replace original file with modified version
mv "$temp_file" /etc/rc.local
if [ $? -ne 0 ]; then
append_error "Failed to update rc.local"
fi
else
append_error "Failed to modify rc.local"
rm -f "$temp_file"
fi
else
append_error "rc.local file not found"
fi
# Remove temporary files that might have been created
rm -f /tmp/imei_result.txt
rm -f /tmp/debug.log
rm -f /tmp/inputICCID.txt
rm -f /tmp/outputICCID.txt
rm -f /tmp/inputIMEI.txt
rm -f /tmp/outputIMEI.txt
# Return appropriate JSON response
if [ "$has_error" = true ]; then
echo "{\"status\": \"error\", \"message\": \"$error_message\"}"
else
echo "{\"status\": \"success\", \"message\": \"IMEI profiles and configuration successfully removed\"}"
fi

View File

@@ -1,39 +0,0 @@
#!/bin/sh
echo "Content-type: application/json"
echo ""
CONFIG_FILE="/etc/quecmanager/imei_profile/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 "}"

View File

@@ -1,209 +0,0 @@
#!/bin/sh
# Parse POST data
read -r QUERY_STRING
# Function to urldecode
urldecode() {
echo -e "$(echo "$1" | sed 's/+/ /g;s/%\([0-9A-F][0-9A-F]\)/\\x\1/g')"
}
# Extract values from POST data
iccidProfile1=$(echo "$QUERY_STRING" | grep -o 'iccidProfile1=[^&]*' | cut -d= -f2)
imeiProfile1=$(echo "$QUERY_STRING" | grep -o 'imeiProfile1=[^&]*' | cut -d= -f2)
iccidProfile2=$(echo "$QUERY_STRING" | grep -o 'iccidProfile2=[^&]*' | cut -d= -f2)
imeiProfile2=$(echo "$QUERY_STRING" | grep -o 'imeiProfile2=[^&]*' | cut -d= -f2)
# URL decode the values
iccidProfile1=$(urldecode "$iccidProfile1")
imeiProfile1=$(urldecode "$imeiProfile1")
iccidProfile2=$(urldecode "$iccidProfile2")
imeiProfile2=$(urldecode "$imeiProfile2")
echo "Content-type: application/json"
echo ""
# Validate required first profile
if [ -z "$iccidProfile1" ] || [ -z "$imeiProfile1" ]; then
echo '{"status": "error", "message": "Profile 1 is required"}'
exit 1
fi
# Check the directory if it exists, if not create it
if [ ! -d /etc/quecmanager/imei_profile ]; then
mkdir -p /etc/quecmanager/imei_profile
fi
# Create a configuration file to store IMEI profiles
cat >/etc/quecmanager/imei_profile/imei_config.txt <<EOF
iccidProfile1=$iccidProfile1
imeiProfile1=$imeiProfile1
EOF
# Add second profile only if ICCID is provided
if [ -n "$iccidProfile2" ]; then
cat >>/etc/quecmanager/imei_profile/imei_config.txt <<EOF
iccidProfile2=$iccidProfile2
imeiProfile2=$imeiProfile2
EOF
fi
# Create the imeiProfiles.sh script
cat >/etc/quecmanager/imei_profile/imeiProfiles.sh <<'EOF'
#!/bin/sh
# Function to read config values
get_config_value() {
local key=$1
grep "^${key}=" /etc/quecmanager/imei_profile/imei_config.txt | cut -d'=' -f2
}
# Read configuration
iccidProfile1=$(get_config_value "iccidProfile1")
imeiProfile1=$(get_config_value "imeiProfile1")
iccidProfile2=$(get_config_value "iccidProfile2")
imeiProfile2=$(get_config_value "imeiProfile2")
# Debug logging
DEBUG_LOG="/tmp/debug.log"
echo "Starting IMEI profile script at $(date)" > "$DEBUG_LOG"
CONFIG_FILE="/etc/quecManager.conf"
# Check config file
if [ ! -f "$CONFIG_FILE" ]; then
echo "Config file not found: $CONFIG_FILE" >> "$DEBUG_LOG"
echo '{"error": "Config file not found"}'
exit 1
fi
# Get AT_PORT with debug logging
AT_PORT=$(head -n 1 "$CONFIG_FILE" | cut -d'=' -f2 | tr -d ' \n\r' | sed 's|^dev/||')
echo "Raw config line: $(head -n 1 "$CONFIG_FILE")" >> "$DEBUG_LOG"
echo "Extracted AT_PORT: '$AT_PORT'" >> "$DEBUG_LOG"
if [ -z "$AT_PORT" ]; then
echo "AT_PORT is empty" >> "$DEBUG_LOG"
echo '{"error": "Failed to read AT_PORT from config"}'
exit 1
fi
# Check if AT_PORT exists
if [ ! -c "/dev/$AT_PORT" ]; then
echo "AT_PORT device not found: /dev/$AT_PORT" >> "$DEBUG_LOG"
echo '{"error": "AT_PORT device not found"}'
exit 1
fi
# Function to get current ICCID
get_current_iccid() {
local input_file="/tmp/inputICCID.txt"
local output_file="/tmp/outputICCID.txt"
echo "AT+ICCID" > "$input_file"
atinout "$input_file" "/dev/$AT_PORT" "$output_file"
iccid=$(cat "$output_file" | grep "+ICCID:" | cut -d' ' -f2)
rm -f "$input_file" "$output_file"
echo "$iccid"
}
# Function to get current IMEI
get_current_imei() {
local input_file="/tmp/inputCGSN.txt"
local output_file="/tmp/outputCGSN.txt"
echo "AT+CGSN" > "$input_file"
atinout "$input_file" "/dev/$AT_PORT" "$output_file"
# Extract IMEI from the response, removing any whitespace or newlines
imei=$(cat "$output_file" | grep -v "AT+CGSN" | grep -v "OK" | tr -d '\r\n[:space:]')
rm -f "$input_file" "$output_file"
echo "$imei"
}
# Function to set IMEI
set_imei() {
local imei="$1"
local input_file="/tmp/inputIMEI.txt"
local output_file="/tmp/outputIMEI.txt"
echo "AT+EGMR=1,7,\"$imei\";+QPOWD=1" > "$input_file"
atinout "$input_file" "/dev/$AT_PORT" "$output_file"
local result=$(cat "$output_file")
rm -f "$input_file" "$output_file"
if echo "$result" | grep -q "OK"; then
return 0
else
return 1
fi
}
# Get current ICCID and IMEI
current_iccid=$(get_current_iccid)
current_imei=$(get_current_imei)
success=false
echo "Current ICCID: $current_iccid" >> "$DEBUG_LOG"
echo "Current IMEI: $current_imei" >> "$DEBUG_LOG"
echo "Profile 1 - ICCID: $iccidProfile1, IMEI: $imeiProfile1" >> "$DEBUG_LOG"
echo "Profile 2 - ICCID: $iccidProfile2, IMEI: $imeiProfile2" >> "$DEBUG_LOG"
# Check ICCID against profile 1 (required)
if [ "$current_iccid" = "$iccidProfile1" ]; then
if [ "$current_imei" != "$imeiProfile1" ]; then
echo "ICCID matches profile 1, but IMEI needs updating" >> "$DEBUG_LOG"
if set_imei "$imeiProfile1"; then
success=true
fi
else
echo "ICCID and IMEI already match profile 1, no action needed" >> "$DEBUG_LOG"
success=true
fi
# Check ICCID against profile 2 (optional)
elif [ -n "$iccidProfile2" ] && [ "$current_iccid" = "$iccidProfile2" ]; then
if [ "$current_imei" != "$imeiProfile2" ]; then
echo "ICCID matches profile 2, but IMEI needs updating" >> "$DEBUG_LOG"
if set_imei "$imeiProfile2"; then
success=true
fi
else
echo "ICCID and IMEI already match profile 2, no action needed" >> "$DEBUG_LOG"
success=true
fi
fi
if [ "$success" = "true" ]; then
echo "IMEI check/update completed successfully" > /tmp/imei_result.txt
else
echo "Failed to check/update IMEI" > /tmp/imei_result.txt
fi
EOF
# Make the script executable
chmod +x /etc/quecmanager/imei_profile/imeiProfiles.sh
# Add to rc.local if not already present
if ! grep -q "/etc/quecmanager/imei_profile/imeiProfiles.sh" /etc/rc.local; then
sed -i '/^exit 0/i /etc/quecmanager/imei_profile/imeiProfiles.sh' /etc/rc.local
fi
# Run the script immediately
/etc/quecmanager/imei_profile/imeiProfiles.sh
# Check the result
if [ -f /tmp/imei_result.txt ]; then
result=$(cat /tmp/imei_result.txt)
rm -f /tmp/imei_result.txt
if [ "$result" = "IMEI set successfully" ]; then
echo '{"status": "success", "message": "IMEI profiles saved and applied successfully"}'
else
echo '{"status": "error", "message": "IMEI profiles saved but failed to apply"}'
fi
else
echo '{"status": "error", "message": "Something went wrong while processing IMEI profiles"}'
fi

View File

@@ -1,201 +0,0 @@
#!/bin/sh
# Configuration
CONFIG_FILE="/etc/cell_lock_schedule.conf"
STATUS_FILE="/tmp/cell_lock_status"
CELL_LOCK_SCRIPT="/usr/bin/set_cell_lock.sh"
# Function to create set_cell_lock.sh script
create_cell_lock_script() {
# Only create the script if it doesn't exist
if [ ! -f "$CELL_LOCK_SCRIPT" ]; then
cat >"$CELL_LOCK_SCRIPT" <<'EOL'
#!/bin/sh
ACTION=$1
LTE_PARAMS=$2
NR5G_PARAMS=$3
case "$ACTION" in
enable)
# Enable LTE lock if parameters exist
if [ -n "$LTE_PARAMS" ]; then
echo "AT+QNWLOCK=\"common/4g\",$LTE_PARAMS" | atinout - /dev/smd11 -
fi
# Enable NR5G lock if parameters exist
if [ -n "$NR5G_PARAMS" ]; then
echo "AT+QNWLOCK=\"common/5g\",$NR5G_PARAMS" | atinout - /dev/smd11 -
fi
;;
disable)
# Disable LTE lock
echo 'AT+QNWLOCK="common/4g",0' | atinout - /dev/smd11 -
# Disable NR5G lock
echo 'AT+QNWLOCK="common/5g",0' | atinout - /dev/smd11 -
;;
*)
echo "Invalid action"
exit 1
;;
esac
# Restart network registration to apply changes
echo "AT+COPS=2" | atinout - /dev/smd11 -
sleep 2
echo "AT+COPS=0" | atinout - /dev/smd11 -
exit 0
EOL
# Make the script executable
chmod +x "$CELL_LOCK_SCRIPT"
fi
}
# Function to remove set_cell_lock.sh script
remove_cell_lock_script() {
if [ -f "$CELL_LOCK_SCRIPT" ]; then
rm "$CELL_LOCK_SCRIPT"
fi
}
# Function to urldecode
urldecode() {
echo -e "$(echo "$1" | sed 's/+/ /g;s/%\([0-9A-F][0-9A-F]\)/\\x\1/g')"
}
# Function to convert HH:MM to cron format
convert_to_cron_time() {
echo "$1" | awk -F: '{print $2, $1}'
}
# Function to save configuration
save_config() {
echo "START_TIME=$1" >"$CONFIG_FILE"
echo "END_TIME=$2" >>"$CONFIG_FILE"
echo "ENABLED=1" >>"$CONFIG_FILE"
}
# Function to disable scheduling
disable_scheduling() {
if [ -f "$CONFIG_FILE" ]; then
sed -i 's/ENABLED=1/ENABLED=0/' "$CONFIG_FILE"
fi
# Remove any existing cron jobs
crontab -l | grep -v "set_cell_lock.sh" | crontab -
# Remove the set_cell_lock.sh script
remove_cell_lock_script
}
# Function to get current status
get_status() {
if [ -f "$CONFIG_FILE" ]; then
ENABLED=$(grep "ENABLED=" "$CONFIG_FILE" | cut -d'=' -f2)
START_TIME=$(grep "START_TIME=" "$CONFIG_FILE" | cut -d'=' -f2)
END_TIME=$(grep "END_TIME=" "$CONFIG_FILE" | cut -d'=' -f2)
echo "Status: 200 OK"
echo "Content-Type: application/json"
echo ""
echo "{\"enabled\":$ENABLED,\"start_time\":\"$START_TIME\",\"end_time\":\"$END_TIME\"}"
else
echo "Status: 200 OK"
echo "Content-Type: application/json"
echo ""
echo "{\"enabled\":0,\"start_time\":\"\",\"end_time\":\"\"}"
fi
}
# Handle POST requests
if [ "$REQUEST_METHOD" = "POST" ]; then
# Read POST data
read -r POST_DATA
# Check if disabling is requested
echo "$POST_DATA" | grep -q "disable=true"
if [ $? -eq 0 ]; then
disable_scheduling
echo "Status: 200 OK"
echo "Content-Type: application/json"
echo ""
echo "{\"status\":\"success\",\"message\":\"Scheduling disabled\"}"
exit 0
fi
# Extract start and end times
START_TIME=$(echo "$POST_DATA" | grep -o 'start_time=[^&]*' | cut -d'=' -f2)
END_TIME=$(echo "$POST_DATA" | grep -o 'end_time=[^&]*' | cut -d'=' -f2)
# Decode times
START_TIME=$(urldecode "$START_TIME")
END_TIME=$(urldecode "$END_TIME")
# Validate times
if [ -z "$START_TIME" ] || [ -z "$END_TIME" ]; then
echo "Status: 400 Bad Request"
echo "Content-Type: application/json"
echo ""
echo "{\"error\":\"Missing start or end time\"}"
exit 1
fi
# Create set_cell_lock.sh script
create_cell_lock_script
# Convert times to cron format
CRON_START=$(convert_to_cron_time "$START_TIME")
CRON_END=$(convert_to_cron_time "$END_TIME")
# Save configuration
save_config "$START_TIME" "$END_TIME"
# Check current cell lock status and get parameters
LTE_STATUS=$(echo 'AT+QNWLOCK="common/4g"' | atinout - /dev/smd11 -)
NR5G_STATUS=$(echo 'AT+QNWLOCK="common/5g"' | atinout - /dev/smd11 -)
# Extract LTE parameters if locked
LTE_PARAMS=$(echo "$LTE_STATUS" | grep -o '"common/4g",[^[:space:]]*' | cut -d',' -f2-)
NR5G_PARAMS=$(echo "$NR5G_STATUS" | grep -o '"common/5g",[^[:space:]]*' | cut -d',' -f2-)
# Create temporary file for new crontab
TEMP_CRON=$(mktemp)
# Get existing crontab entries (excluding our script)
crontab -l 2>/dev/null | grep -v "set_cell_lock.sh" >"$TEMP_CRON"
# Add new entries
echo "$CRON_START * * * $CELL_LOCK_SCRIPT enable \"$LTE_PARAMS\" \"$NR5G_PARAMS\"" >>"$TEMP_CRON"
echo "$CRON_END * * * $CELL_LOCK_SCRIPT disable" >>"$TEMP_CRON"
# Install new crontab
crontab "$TEMP_CRON"
rm "$TEMP_CRON"
echo "Status: 200 OK"
echo "Content-Type: application/json"
echo ""
echo "{\"status\":\"success\",\"message\":\"Scheduling enabled\"}"
exit 0
fi
# Parse query string for GET requests
if [ "$REQUEST_METHOD" = "GET" ]; then
QUERY_STRING=$(echo "$QUERY_STRING" | sed 's/&/\n/g')
for param in $QUERY_STRING; do
case "$param" in
status=*)
get_status
exit 0
;;
esac
done
fi
# If no valid request is made
echo "Status: 400 Bad Request"
echo "Content-Type: application/json"
echo ""
echo "{\"error\":\"Invalid request\"}"
exit 1

View File

@@ -1,195 +0,0 @@
#!/bin/sh
# Configuration
CONFIG_FILE="/etc/keep_alive_schedule.conf"
STATUS_FILE="/tmp/keep_alive_status"
SPEEDTEST_SCRIPT="/www/cgi-bin/home/speedtest/speedtest.sh"
# Function to convert HH:MM to minutes since midnight
time_to_minutes() {
echo "$1" | awk -F: '{print $1 * 60 + $2}'
}
# Function to validate time interval
validate_interval() {
START_TIME=$1
END_TIME=$2
INTERVAL_MINUTES=$3
# Convert times to minutes
START_MINUTES=$(time_to_minutes "$START_TIME")
END_MINUTES=$(time_to_minutes "$END_TIME")
# Calculate duration between start and end time
if [ $END_MINUTES -lt $START_MINUTES ]; then
# Handle case where end time is on the next day
DURATION=$((1440 - START_MINUTES + END_MINUTES))
else
DURATION=$((END_MINUTES - START_MINUTES))
fi
# Check if interval is longer than duration
if [ $INTERVAL_MINUTES -gt $DURATION ]; then
return 1
fi
return 0
}
# Function to generate cron time expression
generate_cron_time() {
START_TIME=$1
END_TIME=$2
INTERVAL=$3
START_HOUR=$(echo "$START_TIME" | cut -d: -f1 | sed 's/^0//')
START_MIN=$(echo "$START_TIME" | cut -d: -f2)
END_HOUR=$(echo "$END_TIME" | cut -d: -f1 | sed 's/^0//')
END_MIN=$(echo "$END_TIME" | cut -d: -f2)
# If end time is less than start time, it means we cross midnight
if [ $(time_to_minutes "$END_TIME") -lt $(time_to_minutes "$START_TIME") ]; then
# Create two cron entries for before and after midnight
echo "*/$INTERVAL $START_HOUR-23 * * * $SPEEDTEST_SCRIPT"
echo "*/$INTERVAL 0-$((END_HOUR - 1)) * * * $SPEEDTEST_SCRIPT"
else
echo "*/$INTERVAL $START_HOUR-$((END_HOUR - 1)) * * * $SPEEDTEST_SCRIPT"
fi
}
# Function to urldecode
urldecode() {
echo -e "$(echo "$1" | sed 's/+/ /g;s/%\([0-9A-F][0-9A-F]\)/\\x\1/g')"
}
# Function to save configuration
save_config() {
echo "START_TIME=$1" >"$CONFIG_FILE"
echo "END_TIME=$2" >>"$CONFIG_FILE"
echo "INTERVAL=$3" >>"$CONFIG_FILE"
echo "ENABLED=1" >>"$CONFIG_FILE"
}
# Function to disable scheduling
disable_scheduling() {
if [ -f "$CONFIG_FILE" ]; then
sed -i 's/ENABLED=1/ENABLED=0/' "$CONFIG_FILE"
fi
# Remove any existing cron jobs
crontab -l | grep -v "$SPEEDTEST_SCRIPT" | crontab -
}
# Function to get current status
get_status() {
if [ -f "$CONFIG_FILE" ]; then
ENABLED=$(grep "ENABLED=" "$CONFIG_FILE" | cut -d'=' -f2)
START_TIME=$(grep "START_TIME=" "$CONFIG_FILE" | cut -d'=' -f2)
END_TIME=$(grep "END_TIME=" "$CONFIG_FILE" | cut -d'=' -f2)
INTERVAL=$(grep "INTERVAL=" "$CONFIG_FILE" | cut -d'=' -f2)
echo "Status: 200 OK"
echo "Content-Type: application/json"
echo ""
echo "{\"enabled\":$ENABLED,\"start_time\":\"$START_TIME\",\"end_time\":\"$END_TIME\",\"interval\":$INTERVAL}"
else
echo "Status: 200 OK"
echo "Content-Type: application/json"
echo ""
echo "{\"enabled\":0,\"start_time\":\"\",\"end_time\":\"\",\"interval\":0}"
fi
}
# Handle POST requests
if [ "$REQUEST_METHOD" = "POST" ]; then
# Read POST data
read -r POST_DATA
# Check if disabling is requested
echo "$POST_DATA" | grep -q "disable=true"
if [ $? -eq 0 ]; then
disable_scheduling
echo "Status: 200 OK"
echo "Content-Type: application/json"
echo ""
echo "{\"status\":\"success\",\"message\":\"Scheduling disabled\"}"
exit 0
fi
# Extract times and interval
START_TIME=$(echo "$POST_DATA" | grep -o 'start_time=[^&]*' | cut -d'=' -f2)
END_TIME=$(echo "$POST_DATA" | grep -o 'end_time=[^&]*' | cut -d'=' -f2)
INTERVAL=$(echo "$POST_DATA" | grep -o 'interval=[^&]*' | cut -d'=' -f2)
# Decode times
START_TIME=$(urldecode "$START_TIME")
END_TIME=$(urldecode "$END_TIME")
INTERVAL=$(urldecode "$INTERVAL")
# Validate times
if [ -z "$START_TIME" ] || [ -z "$END_TIME" ] || [ -z "$INTERVAL" ]; then
echo "Status: 400 Bad Request"
echo "Content-Type: application/json"
echo ""
echo "{\"error\":\"Missing start time, end time, or interval\"}"
exit 1
fi
# Validate interval is a number
if ! echo "$INTERVAL" | grep -q '^[0-9]\+$'; then
echo "Status: 400 Bad Request"
echo "Content-Type: application/json"
echo ""
echo "{\"error\":\"Interval must be a number in minutes\"}"
exit 1
fi
# Validate interval
if ! validate_interval "$START_TIME" "$END_TIME" "$INTERVAL"; then
echo "Status: 400 Bad Request"
echo "Content-Type: application/json"
echo ""
echo "{\"error\":\"Interval is longer than the time between start and end time\"}"
exit 1
fi
# Create temporary file for new crontab
TEMP_CRON=$(mktemp)
# Get existing crontab entries (excluding our script)
crontab -l 2>/dev/null | grep -v "$SPEEDTEST_SCRIPT" >"$TEMP_CRON"
# Generate and add cron entries
generate_cron_time "$START_TIME" "$END_TIME" "$INTERVAL" >>"$TEMP_CRON"
# Install new crontab
crontab "$TEMP_CRON"
rm "$TEMP_CRON"
# Save configuration
save_config "$START_TIME" "$END_TIME" "$INTERVAL"
echo "Status: 200 OK"
echo "Content-Type: application/json"
echo ""
echo "{\"status\":\"success\",\"message\":\"Keep-alive scheduling enabled\"}"
exit 0
fi
# Parse query string for GET requests
if [ "$REQUEST_METHOD" = "GET" ]; then
QUERY_STRING=$(echo "$QUERY_STRING" | sed 's/&/\n/g')
for param in $QUERY_STRING; do
case "$param" in
status=*)
get_status
exit 0
;;
esac
done
fi
# If no valid request is made
echo "Status: 400 Bad Request"
echo "Content-Type: application/json"
echo ""
echo "{\"error\":\"Invalid request\"}"
exit 1

View File

@@ -1,61 +0,0 @@
#!/bin/sh
# Configuration and log directories
CONFIG_DIR="/etc/quecmanager/quecwatch"
QUECWATCH_SCRIPT="${CONFIG_DIR}/quecwatch.sh"
RCLOCAL="/etc/rc.local"
LOG_DIR="/tmp/log/quecwatch"
DEBUG_LOG_FILE="${LOG_DIR}/debug.log"
# Log directory for cleaning process
CLEANUP_LOG_FILE="${LOG_DIR}/cleanup.log"
# Ensure log directory exists
mkdir -p "${LOG_DIR}"
# Function to log cleanup events
log_cleanup() {
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $1" >> "${CLEANUP_LOG_FILE}"
}
# Default response headers
echo "Content-type: application/json"
echo ""
# Cleanup function
cleanup_quecwatch() {
# Start logging cleanup process
log_cleanup "Starting QuecWatch cleanup process"
# Stop any running QuecWatch processes
log_cleanup "Stopping QuecWatch processes"
pkill -f "${QUECWATCH_SCRIPT}" >> "${CLEANUP_LOG_FILE}" 2>&1
# Remove QuecWatch script from rc.local
if [ -f "${RCLOCAL}" ]; then
log_cleanup "Removing QuecWatch entries from rc.local"
sed -i '\|/etc/quecmanager/quecwatch/quecwatch.sh|d' "${RCLOCAL}" >> "${CLEANUP_LOG_FILE}" 2>&1
fi
# Remove configuration directory
if [ -d "${CONFIG_DIR}" ]; then
log_cleanup "Removing configuration directory: ${CONFIG_DIR}"
rm -rf "${CONFIG_DIR}" >> "${CLEANUP_LOG_FILE}" 2>&1
fi
# Remove log directory
if [ -d "${LOG_DIR}" ]; then
log_cleanup "Removing log directory: ${LOG_DIR}"
rm -rf "${LOG_DIR}" >> "${CLEANUP_LOG_FILE}" 2>&1
fi
log_cleanup "QuecWatch cleanup completed successfully"
# Optional: Output JSON response
echo '{"status": "success", "message": "QuecWatch disabled and removed"}'
}
# Execute cleanup
cleanup_quecwatch
exit 0

View File

@@ -1,320 +0,0 @@
#!/bin/sh
# Read POST data
read -r QUERY_STRING
# Function to urldecode
urldecode() {
echo -e "$(echo "$1" | sed 's/+/ /g;s/%\([0-9A-F][0-9A-F]\)/\\x\1/g')"
}
# Configuration directory
CONFIG_DIR="/etc/quecmanager/quecwatch"
QUECWATCH_CONFIG="${CONFIG_DIR}/quecwatch.conf"
QUECWATCH_SCRIPT="${CONFIG_DIR}/quecwatch.sh"
RCLOCAL="/etc/rc.local"
LOG_DIR="/tmp/log/quecwatch"
DEBUG_LOG_FILE="${LOG_DIR}/debug.log"
# Ensure log directory exists
mkdir -p "${LOG_DIR}"
# Extract values from POST data
action=$(echo "$QUERY_STRING" | grep -o 'action=[^&]*' | cut -d= -f2)
ping_target=$(echo "$QUERY_STRING" | grep -o 'ping_target=[^&]*' | cut -d= -f2)
ping_interval=$(echo "$QUERY_STRING" | grep -o 'ping_interval=[^&]*' | cut -d= -f2)
ping_failures=$(echo "$QUERY_STRING" | grep -o 'ping_failures=[^&]*' | cut -d= -f2)
max_retries=$(echo "$QUERY_STRING" | grep -o 'max_retries=[^&]*' | cut -d= -f2)
connection_refresh=$(echo "$QUERY_STRING" | grep -o 'connection_refresh=[^&]*' | cut -d= -f2)
auto_sim_failover=$(echo "$QUERY_STRING" | grep -o 'auto_sim_failover=[^&]*' | cut -d= -f2)
sim_failover_schedule=$(echo "$QUERY_STRING" | grep -o 'sim_failover_schedule=[^&]*' | cut -d= -f2)
# URL decode the values
action=$(urldecode "$action")
ping_target=$(urldecode "$ping_target")
ping_interval=$(urldecode "$ping_interval")
ping_failures=$(urldecode "$ping_failures")
max_retries=$(urldecode "$max_retries")
connection_refresh=$(urldecode "$connection_refresh")
auto_sim_failover=$(urldecode "$auto_sim_failover")
sim_failover_schedule=$(urldecode "$sim_failover_schedule")
# Default response headers
echo "Content-type: application/json"
echo ""
# Validate inputs
if [ -z "$ping_target" ]; then
echo '{"status": "error", "message": "Ping target is required"}'
exit 1
fi
# Initialize configuration function
initialize_config() {
# Create config directory if not exists
mkdir -p "${CONFIG_DIR}"
# Write configuration with defaults and user-provided values
cat >"${QUECWATCH_CONFIG}" <<EOL
# QuecWatch Configuration File
# Ping Target (IP or domain to ping)
PING_TARGET=${ping_target}
# Interval between ping checks (in seconds)
PING_INTERVAL=${ping_interval:-30}
# Number of consecutive ping failures before taking action
PING_FAILURES=${ping_failures:-3}
# Maximum number of retry attempts
MAX_RETRIES=${max_retries:-5}
# Current retry count (should start at 0)
CURRENT_RETRIES=0
# Enable/Disable Connection Refresh
CONNECTION_REFRESH=${connection_refresh:-false}
# Number of connection refresh attempts
REFRESH_COUNT=${connection_refresh:+3}
# Enable/Disable Auto SIM Failover
AUTO_SIM_FAILOVER=${auto_sim_failover:-false}
# Schedule for checking initial SIM (in minutes)
# 0 means no scheduled check
SIM_FAILOVER_SCHEDULE=${sim_failover_schedule:-0}
# Indicate that QuecWatch is enabled
ENABLED=true
EOL
chmod 644 "${QUECWATCH_CONFIG}"
}
# Generate monitoring script function
generate_monitoring_script() {
cat >"${QUECWATCH_SCRIPT}" <<'EOL'
#!/bin/sh
# Load configuration
. /etc/quecmanager/quecwatch/quecwatch.conf
# Log directory
LOG_DIR="/tmp/log/quecwatch"
mkdir -p "${LOG_DIR}"
# Function to log events
log_event() {
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $1" >> "${LOG_DIR}/quecwatch.log"
}
# Function to update retry count in config
update_retry_count() {
local new_retry_count=$1
sed -i "s/CURRENT_RETRIES=[0-9]*/CURRENT_RETRIES=${new_retry_count}/" /etc/quecmanager/quecwatch/quecwatch.conf
# Reload config to ensure latest values
. /etc/quecmanager/quecwatch/quecwatch.conf
}
# Function to get current SIM slot
get_current_sim() {
echo AT+QUIMSLOT? | atinout - /dev/smd11 /tmp/log/quecwatch/current_sim.txt
grep "+QUIMSLOT:" /tmp/log/quecwatch/current_sim.txt | awk '{print $2}'
}
# Function to switch SIM card
switch_sim_card() {
log_event "Attempting to switch SIM card"
# Get current SIM slot
current_sim_slot=$(get_current_sim)
# Toggle between SIM slots (assuming 2 SIM slots)
if [ "${current_sim_slot}" = "1" ]; then
new_sim_slot=2
else
new_sim_slot=1
fi
log_event "Switching from SIM slot ${current_sim_slot} to SIM slot ${new_sim_slot}"
echo "AT+QUIMSLOT=${new_sim_slot}" | atinout - /dev/smd11 -
sleep 10 # Give more time for SIM switch and network registration
return 0
}
# Function to check internet connectivity
check_internet() {
ping -c 3 ${PING_TARGET} > /dev/null 2>&1
return $?
}
# Function to perform connection recovery
perform_connection_recovery() {
local recovery_attempted=0
local recovery_successful=0
# Try Connection Refresh if enabled
if [ "${CONNECTION_REFRESH}" = "true" ] && [ "${retry_trigger}" -eq 1 ] && [ "${REFRESH_COUNT}" -gt 0 ]; then
log_event "Attempting connection refresh"
echo AT+COPS=2 | atinout - /dev/smd11 -
sleep 2
echo AT+COPS=0 | atinout - /dev/smd11 -
sleep 5
if check_internet; then
log_event "Connection refresh successful"
recovery_successful=1
return 0
fi
REFRESH_COUNT=$((REFRESH_COUNT - 1))
sed -i "s/REFRESH_COUNT=.*/REFRESH_COUNT=${REFRESH_COUNT}/" /etc/quecmanager/quecwatch/quecwatch.conf
recovery_attempted=1
fi
[ ${recovery_successful} -eq 1 ] && return 0 || return 1
}
# Store initial SIM slot only if auto SIM failover is enabled
initial_sim_slot=""
if [ "${AUTO_SIM_FAILOVER}" = "true" ]; then
initial_sim_slot=$(get_current_sim)
log_event "Auto SIM failover enabled. Initial SIM slot: ${initial_sim_slot}"
fi
# Main loop
failure_count=0
retry_trigger=0
sim_failover_interval=0
while true; do
# Check internet connectivity
if ! check_internet; then
failure_count=$((failure_count + 1))
log_event "Ping failed. Failure count: ${failure_count}"
# Check if failure threshold is reached
if [ ${failure_count} -ge ${PING_FAILURES} ]; then
failure_count=0
retry_trigger=$((retry_trigger + 1))
update_retry_count ${retry_trigger}
log_event "Failure threshold reached. Retry trigger: ${retry_trigger}"
# Check if retry threshold is reached
if [ ${retry_trigger} -ge ${MAX_RETRIES} ]; then
# Only attempt SIM failover if enabled
if [ "${AUTO_SIM_FAILOVER}" = "true" ]; then
log_event "Max retries exhausted. Auto SIM failover is enabled. Attempting SIM failover."
switch_sim_card
if check_internet; then
log_event "SIM failover successful"
retry_trigger=0
failure_count=0
update_retry_count 0
else
log_event "SIM failover failed. Performing system reboot."
reboot
fi
else
# If auto SIM failover is not enabled, follow original behavior
log_event "Max retries exhausted. Auto SIM failover is disabled. Removing QuecWatch."
sed -i '\|/etc/quecmanager/quecwatch/quecwatch.sh|d' /etc/rc.local
reboot
exit 0
fi
else
# Attempt connection recovery
if perform_connection_recovery; then
retry_trigger=0
failure_count=0
update_retry_count 0
else
log_event "Recovery failed. Performing system reboot."
reboot
fi
fi
fi
else
# Reset failure count and retry trigger if connection is good
failure_count=0
retry_trigger=0
update_retry_count 0
log_event "Modem is connected to the internet"
# Only check SIM schedule if auto SIM failover is enabled
if [ "${AUTO_SIM_FAILOVER}" = "true" ] && [ "${SIM_FAILOVER_SCHEDULE}" -gt 0 ]; then
current_sim_slot=$(get_current_sim)
# Only proceed with schedule check if we're on the backup SIM
if [ -n "${initial_sim_slot}" ] && [ "${current_sim_slot}" != "${initial_sim_slot}" ]; then
sim_failover_interval=$((sim_failover_interval + 1))
# Check if schedule interval has passed
if [ $((sim_failover_interval * PING_INTERVAL)) -ge $((SIM_FAILOVER_SCHEDULE * 60)) ]; then
log_event "Scheduled check: Attempting to switch back to initial SIM ${initial_sim_slot}"
# Switch to initial SIM
echo "AT+QUIMSLOT=${initial_sim_slot}" | atinout - /dev/smd11 -
sleep 10
# Check if initial SIM works
if check_internet; then
log_event "Initial SIM restored successfully"
retry_trigger=0
failure_count=0
update_retry_count 0
else
log_event "Initial SIM still not working. Switching back to backup SIM."
echo "AT+QUIMSLOT=${current_sim_slot}" | atinout - /dev/smd11 -
sleep 10
fi
# Reset interval counter
sim_failover_interval=0
fi
fi
fi
fi
# Wait for specified interval before next check
sleep ${PING_INTERVAL}
done
EOL
chmod +x "${QUECWATCH_SCRIPT}"
# Run the script
"${QUECWATCH_SCRIPT}" &
}
# Enable QuecWatch
enable_quecwatch() {
# Initialize configuration
initialize_config
# Generate monitoring script
generate_monitoring_script
# Add to rc.local if not already present
if ! grep -q "${QUECWATCH_SCRIPT}" "${RCLOCAL}"; then
[ -f "${RCLOCAL}" ] || touch "${RCLOCAL}"
chmod +x "${RCLOCAL}"
sed -i '$i'"${QUECWATCH_SCRIPT} &" "${RCLOCAL}"
fi
# Output success JSON
echo '{"status": "success", "message": "QuecWatch enabled", "config": "'${QUECWATCH_CONFIG}'"}'
}
# Log debug information
{
echo "Timestamp: $(date)"
echo "Script Path: $0"
echo "Ping Target: $ping_target"
echo "Ping Interval: $ping_interval"
echo "Ping Failures: $ping_failures"
echo "Max Retries: $max_retries"
echo "Connection Refresh: $connection_refresh"
echo "Auto SIM Failover: $auto_sim_failover"
echo "SIM Failover Schedule: $sim_failover_schedule"
} >>"$DEBUG_LOG_FILE" 2>&1
# Enable QuecWatch
enable_quecwatch
exit 0

View File

@@ -1,79 +0,0 @@
#!/bin/sh
# Set headers for JSON response
echo "Content-type: application/json"
echo ""
# Configuration file path
CONFIG_FILE="/etc/quecmanager/quecwatch/quecwatch.conf"
# Check if configuration file exists
if [ ! -f "$CONFIG_FILE" ]; then
echo '{"status": "inactive", "message": "QuecWatch is not configured"}'
exit 0
fi
# Function to safely get config value
get_config_value() {
grep "^$1=" "$CONFIG_FILE" | cut -d'=' -f2
}
# Check if QuecWatch is enabled
enabled=$(get_config_value "ENABLED")
if [ "$enabled" != "true" ]; then
echo '{"status": "inactive", "message": "QuecWatch is disabled"}'
exit 0
fi
# Fetch configuration values
ping_target=$(get_config_value "PING_TARGET")
ping_interval=$(get_config_value "PING_INTERVAL")
ping_failures=$(get_config_value "PING_FAILURES")
max_retries=$(get_config_value "MAX_RETRIES")
current_retries=$(get_config_value "CURRENT_RETRIES")
connection_refresh=$(get_config_value "CONNECTION_REFRESH")
refresh_count=$(get_config_value "REFRESH_COUNT")
# New configuration options
mobile_data_reconnect=$(get_config_value "MOBILE_DATA_RECONNECT")
auto_sim_failover=$(get_config_value "AUTO_SIM_FAILOVER")
sim_failover_schedule=$(get_config_value "SIM_FAILOVER_SCHEDULE")
# Default values if not set
mobile_data_reconnect=${mobile_data_reconnect:-false}
auto_sim_failover=${auto_sim_failover:-false}
sim_failover_schedule=${sim_failover_schedule:-30}
# Check monitoring script existence
QUECWATCH_SCRIPT="/etc/quecmanager/quecwatch/quecwatch.sh"
if [ ! -f "$QUECWATCH_SCRIPT" ]; then
echo '{"status": "error", "message": "Monitoring script is missing"}'
exit 0
fi
# Check log file for recent activity
LOG_FILE="/tmp/log/quecwatch/quecwatch.log"
last_log=""
if [ -f "$LOG_FILE" ]; then
last_log=$(tail -n 1 "$LOG_FILE")
fi
# Prepare JSON response
cat <<EOF
{
"status": "active",
"config": {
"pingTarget": "${ping_target}",
"pingInterval": ${ping_interval},
"pingFailures": ${ping_failures},
"maxRetries": ${max_retries},
"currentRetries": ${current_retries},
"connectionRefresh": ${connection_refresh},
"refreshCount": ${refresh_count:-0},
"mobileDataReconnect": ${mobile_data_reconnect},
"autoSimFailover": ${auto_sim_failover},
"simFailoverSchedule": ${sim_failover_schedule}
},
"lastActivity": "${last_log}"
}
EOF

View File

@@ -1,144 +0,0 @@
#!/bin/sh
# Set content-type for JSON response
echo "Content-type: application/json"
echo ""
# Function to output error in JSON format
output_error() {
echo "{\"error\": \"$1\"}"
exit 1
}
# Define command sets
define_command_sets() {
COMMAND_SET_1='AT+QUIMSLOT? AT+CNUM AT+COPS? AT+CIMI AT+ICCID AT+CGSN AT+CPIN? AT+CGDCONT? AT+CREG? AT+CFUN? AT+QENG="servingcell" AT+QTEMP AT+CGCONTRDP AT+QCAINFO AT+QRSRP AT+QMAP="WWAN" AT+C5GREG=2;+C5GREG? AT+CGREG=2;+CGREG? AT+QRSRQ AT+QSINR'
COMMAND_SET_2='AT+CGDCONT? AT+CGCONTRDP AT+QNWPREFCFG="mode_pref" AT+QNWPREFCFG="nr5g_disable_mode" AT+QUIMSLOT?'
COMMAND_SET_3='AT+CGMI AT+CGMM AT+QGMR AT+CNUM AT+CIMI AT+ICCID AT+CGSN AT+QMAP="LANIP" AT+QMAP="WWAN" AT+QGETCAPABILITY'
COMMAND_SET_4='AT+QMAP="MPDN_RULE" AT+QMAP="DHCPV4DNS" AT+QCFG="usbnet"'
COMMAND_SET_5='AT+QRSRP AT+QRSRQ AT+QSINR AT+QCAINFO AT+QSPN'
COMMAND_SET_6='AT+CEREG=2;+CEREG? AT+C5GREG=2;+C5GREG? AT+CPIN? AT+CGDCONT? AT+CGCONTRDP AT+QMAP="WWAN" AT+QRSRP AT+QTEMP AT+QNETRC?'
COMMAND_SET_7='AT+QNWPREFCFG="policy_band" AT+QNWPREFCFG="lte_band";+QNWPREFCFG="nsa_nr5g_band";+QNWPREFCFG="nr5g_band"'
}
# Define the lock file
LOCK_FILE="/tmp/home_data.lock"
# Acquire the lock (wait if needed)
exec 200>$LOCK_FILE
flock -x 200 || output_error "Unable to acquire lock"
# Temporary files for input/output and AT port
INPUT_FILE="/tmp/input_$$.txt"
OUTPUT_FILE="/tmp/output_$$.txt"
# Debug logging
DEBUG_LOG="/tmp/debug.log"
echo "Starting script at $(date)" > "$DEBUG_LOG"
CONFIG_FILE="/etc/quecManager.conf"
# Check config file
if [ ! -f "$CONFIG_FILE" ]; then
echo "Config file not found: $CONFIG_FILE" >> "$DEBUG_LOG"
output_error "Config file not found"
fi
# Get AT_PORT with debug logging
AT_PORT=$(head -n 1 "$CONFIG_FILE" | cut -d'=' -f2 | tr -d ' \n\r' | sed 's|^dev/||')
echo "Raw config line: $(head -n 1 "$CONFIG_FILE")" >> "$DEBUG_LOG"
echo "Extracted AT_PORT: '$AT_PORT'" >> "$DEBUG_LOG"
if [ -z "$AT_PORT" ]; then
echo "AT_PORT is empty" >> "$DEBUG_LOG"
output_error "Failed to read AT_PORT from config"
fi
# Check if AT_PORT exists
if [ ! -c "/dev/$AT_PORT" ]; then
echo "AT_PORT device not found: /dev/$AT_PORT" >> "$DEBUG_LOG"
echo "Available smd devices:" >> "$DEBUG_LOG"
ls -l /dev/smd* >> "$DEBUG_LOG" 2>&1
output_error "AT_PORT device not found"
fi
# Function to escape JSON strings (handling quotes and newlines)
escape_json() {
echo "$1" | sed ':a;N;$!ba;s/\n/\\n/g; s/"/\\"/g'
}
# Function to process AT commands
process_commands() {
local commands="$1"
local json_response="["
for cmd in $commands; do
echo "Processing command: $cmd" >> "$DEBUG_LOG"
# Write the command to the input file
echo "$cmd" > "$INPUT_FILE"
# Run the command using atinout with full path to device
if ! atinout "$INPUT_FILE" "/dev/$AT_PORT" "$OUTPUT_FILE" 2>> "$DEBUG_LOG"; then
echo "Command failed: $cmd" >> "$DEBUG_LOG"
OUTPUT="Error executing command"
elif [ ! -f "$OUTPUT_FILE" ]; then
echo "Output file not created for command: $cmd" >> "$DEBUG_LOG"
OUTPUT="No output file"
else
OUTPUT=$(cat "$OUTPUT_FILE" 2>> "$DEBUG_LOG" || echo "Error reading output")
echo "Command output: $OUTPUT" >> "$DEBUG_LOG"
fi
# Escape special characters for JSON
ESCAPED_OUTPUT=$(escape_json "$OUTPUT")
# Append the response
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
echo "$json_response"
}
# Main execution
define_command_sets
# Get command set from query string
COMMAND_SET=$(echo "$QUERY_STRING" | grep -o 'set=[1-7]' | cut -d'=' -f2)
# Select the appropriate command set
case "$COMMAND_SET" in
1) COMMANDS="$COMMAND_SET_1";;
2) COMMANDS="$COMMAND_SET_2";;
3) COMMANDS="$COMMAND_SET_3";;
4) COMMANDS="$COMMAND_SET_4";;
5) COMMANDS="$COMMAND_SET_5";;
6) COMMANDS="$COMMAND_SET_6";;
7) COMMANDS="$COMMAND_SET_7";;
*) COMMANDS="$COMMAND_SET_1";; # Default to set 1 if no valid set specified
esac
# Process the selected commands and output the response
JSON_RESPONSE=$(process_commands "$COMMANDS")
echo "$JSON_RESPONSE" >> "$DEBUG_LOG"
echo "$JSON_RESPONSE"
# Clean up temporary files
rm -f "$INPUT_FILE" "$OUTPUT_FILE"
# Release the lock
flock -u 200
echo "Script completed at $(date)" >> "$DEBUG_LOG"

View File

@@ -1,14 +0,0 @@
#!/bin/sh
# Set the content type to JSON
echo "Content-Type: application/json"
echo ""
# Ping 8.8.8.8 with 2 packets and capture the result
if ping -c 2 8.8.8.8 > /dev/null 2>&1; then
# Ping was successful
echo '{"connection": "ACTIVE"}'
else
# Ping failed
echo '{"connection": "INACTIVE"}'
fi

View File

@@ -1,20 +0,0 @@
#!/bin/sh
# Set the content type to JSON
echo "Content-Type: application/json"
echo ""
# Run ethtool on eth0 and capture the output
ethtool_output=$(ethtool eth0)
# Extract Link Speed
speed=$(echo "$ethtool_output" | grep "Speed:" | awk '{print $2}')
# Extract Link Status
link_status=$(echo "$ethtool_output" | grep "Link detected:" | awk '{print $3}')
# Extract Auto-negotiation status
auto_negotiation=$(echo "$ethtool_output" | grep "Auto-negotiation:" | awk '{print $2}')
# Create JSON output
echo "{\"link_speed\": \"$speed\", \"link_status\": \"$link_status\", \"auto_negotiation\": \"$auto_negotiation\"}"

View File

@@ -1,8 +0,0 @@
#!/bin/sh
# Set content type to JSON
echo "Content-Type: application/json"
echo
# Read the JSON file and get only the last entry using jq
jq 'last' /tmp/signal_graphs/data_usage.json

View File

@@ -1,119 +0,0 @@
#!/bin/sh
# Set common headers
echo "Content-Type: application/json"
echo "Access-Control-Allow-Origin: *"
echo "Cache-Control: no-cache, no-store, must-revalidate"
echo ""
# Lock file path
LOCK_FILE="/tmp/hw_details.lock"
LOCK_TIMEOUT=10 # Maximum wait time in seconds
# Function to acquire lock
acquire_lock() {
local start_time=$(date +%s)
while [ -e "$LOCK_FILE" ]; do
# Check if lock is stale (older than LOCK_TIMEOUT seconds)
if [ -f "$LOCK_FILE" ]; then
local lock_time=$(stat -c %Y "$LOCK_FILE" 2>/dev/null)
local current_time=$(date +%s)
if [ $((current_time - lock_time)) -gt $LOCK_TIMEOUT ]; then
rm -f "$LOCK_FILE"
break
fi
fi
# Check if we've waited too long
if [ $(($(date +%s) - start_time)) -gt $LOCK_TIMEOUT ]; then
error_response "Timeout waiting for lock"
exit 1
fi
sleep 0.1
done
# Create lock file with current PID
echo $$ > "$LOCK_FILE"
}
# Function to release lock
release_lock() {
rm -f "$LOCK_FILE"
}
# Function to handle errors and return JSON
error_response() {
echo "{\"error\": \"$1\"}"
exit 1
}
# Function to cleanup on exit
cleanup() {
release_lock
exit $?
}
# Set trap for cleanup
trap cleanup EXIT INT TERM
# Function to get memory information
get_memory_info() {
free_output=$(free -b)
memory_info=$(echo "$free_output" | awk '/Mem:/ {print "{\"total\": " $2 ", \"used\": " $3 ", \"available\": " $7 "}"}')
echo "$memory_info"
}
# Function to get ethernet information
get_ethernet_info() {
interface=${1:-eth0}
# Check if ethtool is installed
if ! which ethtool >/dev/null 2>&1; then
error_response "ethtool not found"
fi
# Check if interface exists
if ! ip link show "$interface" >/dev/null 2>&1; then
error_response "Interface $interface not found"
fi
# Run ethtool and capture output
ethtool_output=$(ethtool "$interface" 2>/dev/null) || error_response "Failed to get ethernet information"
# Extract values using sed instead of grep -P
speed=$(echo "$ethtool_output" | sed -n 's/.*Speed: \([^[:space:]]*\).*/\1/p' || echo "Unknown")
link_status=$(echo "$ethtool_output" | sed -n 's/.*Link detected: \(yes\|no\).*/\1/p' || echo "unknown")
auto_negotiation=$(echo "$ethtool_output" | sed -n 's/.*Auto-negotiation: \(on\|off\).*/\1/p' || echo "unknown")
# Output JSON
echo "{\"link_speed\":\"$speed\",\"link_status\":\"$link_status\",\"auto_negotiation\":\"$auto_negotiation\"}"
}
# Main execution
# Acquire lock before proceeding
acquire_lock
# Parse query string for type and interface
type=$(echo "$QUERY_STRING" | sed -n 's/.*type=\([^&]*\).*/\1/p')
interface=$(echo "$QUERY_STRING" | sed -n 's/.*interface=\([^&]*\).*/\1/p')
# Default interface if not specified
[ -z "$interface" ] && interface="eth0"
# Convert type to lowercase using tr
type=$(echo "$type" | tr '[:upper:]' '[:lower:]')
# Check type parameter and call appropriate function
case "$type" in
"memory")
get_memory_info
;;
"eth")
get_ethernet_info "$interface"
;;
*)
error_response "Invalid type. Use 'memory' or 'eth'"
;;
esac
# Lock will be automatically released by the cleanup trap

View File

@@ -1,30 +0,0 @@
#!/bin/sh
# Ensure the script outputs proper CGI headers
echo "Content-Type: application/json"
echo ""
# Directory where JSON files are stored (adjust as needed)
JSON_DIR="/www/signal_graphs/"
# Function to safely read JSON file
read_json_file() {
local file="$1"
if [ -f "$file" ]; then
cat "$file"
else
echo "[]" # Return empty array if file doesn't exist
fi
}
# Collect signal metrics from JSON files
RSRP=$(read_json_file "${JSON_DIR}/rsrp.json")
RSRQ=$(read_json_file "${JSON_DIR}/rsrq.json")
SINR=$(read_json_file "${JSON_DIR}/sinr.json")
# Combine metrics into a single JSON object
printf '{
"rsrp": %s,
"rsrq": %s,
"sinr": %s
}' "$RSRP" "$RSRQ" "$SINR"

View File

@@ -1,15 +0,0 @@
#!/bin/sh
# Set the content type to JSON
echo "Content-Type: application/json"
echo ""
# Run free command and capture the output, using -b for bytes
free_output=$(free -b)
# Extract memory information using awk
# Skip the header, take the Mem: line, and extract total, used, and available
memory_info=$(echo "$free_output" | awk '/Mem:/ {print "{\"total\": " $2 ", \"used\": " $3 ", \"available\": " $7 "}"}')
# Output the JSON
echo "$memory_info"

View File

@@ -1,24 +0,0 @@
#!/bin/sh
# Set the content type to JSON
echo "Content-Type: application/json"
echo ""
# Ping 8.8.8.8 with 5 packets and capture the full output
ping_result=$(ping -c 5 8.8.8.8)
# Check if ping was successful
if [ $? -eq 0 ]; then
# Extract the average latency using awk
avg_latency=$(echo "$ping_result" | awk '/avg/ {split($4, a, "/"); print int(a[2])}')
# If average latency was extracted, return it
if [ ! -z "$avg_latency" ]; then
echo "{\"connection\": \"ACTIVE\", \"latency\": $avg_latency}"
else
echo '{"connection": "ACTIVE", "latency": 0}'
fi
else
# Ping failed
echo '{"connection": "INACTIVE", "latency": 0}'
fi

View File

@@ -1,11 +0,0 @@
#!/bin/sh
export HOME=/tmp/home
# Create named pipe for speedtest output if it doesn't exist
[ ! -p /tmp/realtime_spd.json ] && mkfifo /tmp/realtime_spd.json
# Run speedtest in background
/usr/bin/speedtest --accept-license -f json -p yes --progress-update-interval=100 > /tmp/realtime_spd.json
# Remove named pipe
rm /tmp/realtime_spd.json

View File

@@ -1,13 +0,0 @@
#!/bin/sh
echo "Content-Type: text/event-stream"
echo "Cache-Control: no-cache"
echo "Connection: keep-alive"
echo ""
# Use cat to read from the FIFO
cat /tmp/realtime_spd.json | while read line; do
echo "data: $line"
echo
sleep 0.1
done

View File

@@ -1,10 +0,0 @@
#!/bin/sh
# /www/cgi-bin/start_speedtest.sh
echo "Content-Type: application/json"
echo ""
# Run speedtest in background
/www/cgi-bin/home/speedtest/speedtest.sh
# Immediately return a success response
echo '{"status":"started"}'

View File

@@ -1,178 +0,0 @@
#!/bin/sh
# Configuration
LOGDIR="/www/signal_graphs"
MAX_ENTRIES=10
INTERVAL=15
QSCAN_FILE="$LOGDIR/qscan.json"
LOCK_FILE="/tmp/signal_logging.lock"
PAUSE_FILE="/tmp/signal_logging.pause"
# Ensure the directory exists
mkdir -p "$LOGDIR"
# Modified clean_atinout_output function - less aggressive cleaning
clean_atinout_output() {
# Keep everything between the command and OK, including the actual response
sed '1d' | sed '/^OK$/d' | tr -d '\r' | grep -v '^$' | head -n1
}
# Function to perform cell scan and output JSON response for CGI
perform_cell_scan() {
# Print CGI headers first
printf "Content-Type: application/json\n\n"
# Create pause file to stop continuous logging
touch "$PAUSE_FILE"
# Wait for any ongoing logging to complete
sleep 2
# Perform cell scan sequence
echo "AT+COPS=2" | atinout - /dev/smd7 -
sleep 2
# Run QSCAN and save output to temporary file
echo "AT+QSCAN=3,1" | atinout - /dev/smd7 "$QSCAN_OUT"
sleep 2
# Process QSCAN output and convert to JSON
if [ -f "$QSCAN_OUT" ]; then
# Extract the relevant part and convert to JSON format
sed -n '2,/^OK$/p' < "$QSCAN_OUT" | sed '$d' | tr -d '\r' | \
jq -R -s 'split("\n") | map(select(length > 0))' > "$QSCAN_FILE"
fi
# Re-enable network registration
echo "AT+COPS=0" | atinout - /dev/smd7 -
sleep 2
# Clean up temporary file
rm -f "$QSCAN_OUT"
# Remove pause file to resume logging
rm -f "$PAUSE_FILE"
# Return QSCAN results as JSON
if [ -f "$QSCAN_FILE" ]; then
printf '{"status":"success","data":%s}\n' "$(cat "$QSCAN_FILE")"
else
printf '{"status":"error","message":"No scan results available"}\n'
fi
}
# Function to log signal metric
log_signal_metric() {
[ -f "$PAUSE_FILE" ] && return
local COMMAND="$1"
local FILENAME="$2"
local LOGFILE="$LOGDIR/$FILENAME"
# Ensure log directory exists
mkdir -p "$(dirname "$LOGFILE")"
# Get current timestamp
TIMESTAMP=$(date "+%Y-%m-%d %H:%M:%S")
# Add debug logging
logger -t signal_metrics "Running command: $COMMAND"
# Run the AT command and capture its output, then clean it
SIGNAL_OUTPUT=$(echo "$COMMAND" | atinout - /dev/smd7 - | clean_atinout_output)
# Log the raw output for debugging
logger -t signal_metrics "Raw output for $COMMAND: $SIGNAL_OUTPUT"
# Ensure the file exists and is a valid JSON array
[ ! -s "$LOGFILE" ] && echo "[]" > "$LOGFILE"
# Use jq to update the JSON file
jq --arg dt "$TIMESTAMP" \
--arg out "$SIGNAL_OUTPUT" \
'. + [{"datetime": $dt, "output": $out}] | .[-'"$MAX_ENTRIES"':]' \
"$LOGFILE" > "${LOGFILE}.tmp" && mv "${LOGFILE}.tmp" "$LOGFILE"
}
# Function to log data usage
log_data_usage() {
[ -f "$PAUSE_FILE" ] && return
local LOGFILE="$LOGDIR/data_usage.json"
# Ensure log directory exists
mkdir -p "$(dirname "$LOGFILE")"
# Get current timestamp
TIMESTAMP=$(date "+%Y-%m-%d %H:%M:%S")
# Run the AT command and capture its output
DATA_OUTPUT=$(echo "AT+QGDCNT?;+QGDNRCNT?" | atinout - /dev/smd7 - | clean_atinout_output)
# Ensure the file exists and is a valid JSON array
[ ! -s "$LOGFILE" ] && echo "[]" > "$LOGFILE"
# Use jq to update the JSON file
jq --arg dt "$TIMESTAMP" \
--arg out "$DATA_OUTPUT" \
'. + [{"datetime": $dt, "output": $out}] | .[-'"$MAX_ENTRIES"':]' \
"$LOGFILE" > "${LOGFILE}.tmp" && mv "${LOGFILE}.tmp" "$LOGFILE"
}
# Main CGI request handler
handle_cgi_request() {
# Get query string from REQUEST_URI or QUERY_STRING
local QUERY=""
if [ -n "$REQUEST_URI" ]; then
QUERY=$(echo "$REQUEST_URI" | grep -o '[?&]request=[^&]*' | cut -d= -f2)
elif [ -n "$QUERY_STRING" ]; then
QUERY=$(echo "$QUERY_STRING" | grep -o 'request=[^&]*' | cut -d= -f2)
fi
case "$QUERY" in
"cellScan")
perform_cell_scan
;;
*)
printf "Content-Type: application/json\n\n"
printf '{"status":"error","message":"Invalid request"}\n'
;;
esac
}
# Function to start continuous logging
start_continuous_logging() {
# Check if another instance is running
if [ -f "$LOCK_FILE" ]; then
logger -t signal_metrics "Another instance is already running"
exit 1
fi
# Create lock file
touch "$LOCK_FILE"
# Cleanup on exit
trap 'rm -f "$LOCK_FILE" "$PAUSE_FILE"; exit 0' INT TERM
# Log start to system log
logger -t signal_metrics "Starting continuous signal metrics logging"
# Continuous logging loop
while true; do
if [ ! -f "$PAUSE_FILE" ]; then
log_signal_metric "AT+QRSRP" "rsrp.json"
log_signal_metric "AT+QRSRQ" "rsrq.json"
log_signal_metric "AT+QSINR" "sinr.json"
log_data_usage
fi
sleep "$INTERVAL"
done
}
# Check if script is being run as CGI or directly
if [ -n "$REQUEST_URI" ] || [ -n "$QUERY_STRING" ]; then
handle_cgi_request
else
start_continuous_logging
fi

View File

@@ -1,52 +0,0 @@
#!/bin/sh
# Set Content-Type for CGI script
echo "Content-type: application/json"
echo ""
# Read POST data
read POST_DATA
# Debug log
DEBUG_LOG="/tmp/password_change.log"
# Extract the passwords from POST data
OLD_PASSWORD=$(echo "$POST_DATA" | sed -n 's/^.*oldPassword=\([^&]*\).*$/\1/p')
NEW_PASSWORD=$(echo "$POST_DATA" | sed -n 's/^.*newPassword=\([^&]*\).*$/\1/p')
# URL-decode the passwords
OLD_PASSWORD=$(echo "$OLD_PASSWORD" | sed 's/+/ /g;s/%\(..\)/\\x\1/g' | xargs -0 printf "%b")
NEW_PASSWORD=$(echo "$NEW_PASSWORD" | sed 's/+/ /g;s/%\(..\)/\\x\1/g' | xargs -0 printf "%b")
# User to change password for
USER="root"
# Verify old password first
USER_SHADOW_ENTRY=$(grep "^$USER:" /etc/shadow)
if [ -z "$USER_SHADOW_ENTRY" ]; then
echo '{"state":"failed", "message":"User not found"}'
exit 1
fi
# Extract current password hash and salt
USER_HASH=$(echo "$USER_SHADOW_ENTRY" | cut -d: -f2)
SALT=$(echo "$USER_HASH" | cut -d'$' -f3)
# Generate hash from old password
OLD_GENERATED_HASH=$(echo "$OLD_PASSWORD" | openssl passwd -1 -salt "$SALT" -stdin)
# Verify old password
if [ "$OLD_GENERATED_HASH" != "$USER_HASH" ]; then
echo '{"state":"failed", "message":"Current password is incorrect"}'
exit 1
fi
# Change password using passwd command
# We need to pass both the new password and its confirmation
(echo "$NEW_PASSWORD"; echo "$NEW_PASSWORD") | passwd $USER 2>> $DEBUG_LOG
if [ $? -eq 0 ]; then
echo '{"state":"success", "message":"Password changed successfully"}'
else
echo '{"state":"failed", "message":"Failed to change password"}'
fi

View File

@@ -1,38 +0,0 @@
#!/bin/sh
# Set the content type to JSON
echo "Content-Type: application/json"
echo ""
# Configuration file path
CONFIG_FILE="/etc/quecManager.conf"
# Check if the config file exists
if [ ! -f "$CONFIG_FILE" ]; then
echo '{"error": "Configuration file not found"}'
exit 1
fi
# Initialize variables
AT_PORT=""
AT_PORT_CUSTOM=""
DATA_REFRESH_RATE=""
# Read the config file line by line and extract values
while IFS='=' read -r key value; do
# Remove leading/trailing whitespace
key=$(echo "$key" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
value=$(echo "$value" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
case "$key" in
"AT_port") AT_PORT="$value" ;;
"AT_port_custom") AT_PORT_CUSTOM="$value" ;;
"data_refresh_rate") DATA_REFRESH_RATE="$value" ;;
esac
done <"$CONFIG_FILE"
# Output JSON
echo "{"
echo " \"AT_port\": \"$AT_PORT\","
echo " \"AT_port_custom\": \"$AT_PORT_CUSTOM\","
echo " \"data_refresh_rate\": $DATA_REFRESH_RATE"
echo "}"

View File

@@ -1,64 +0,0 @@
#!/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

View File

@@ -1,11 +0,0 @@
#!/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\"}"

Some files were not shown because too many files have changed in this diff Show More