fix(luci-app-voip): Remove invalid 'local' keywords from RPCD handler
- Shell 'local' keyword only works inside functions, not case statements - Remove all 'local' declarations to fix RPCD handler execution - Fixes "not in a function" error when calling trunk_test and other methods Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
c137296dcd
commit
701558f611
@ -66,7 +66,7 @@ JSON
|
|||||||
;;
|
;;
|
||||||
calls)
|
calls)
|
||||||
if lxc-info -n voip -s 2>/dev/null | grep -q "RUNNING"; then
|
if lxc-info -n voip -s 2>/dev/null | grep -q "RUNNING"; then
|
||||||
local output=$(lxc-attach -n voip -- asterisk -rx "core show channels concise" 2>/dev/null)
|
output=$(lxc-attach -n voip -- asterisk -rx "core show channels concise" 2>/dev/null)
|
||||||
json_init
|
json_init
|
||||||
json_add_array "calls"
|
json_add_array "calls"
|
||||||
|
|
||||||
@ -92,11 +92,11 @@ JSON
|
|||||||
json_add_array "voicemails"
|
json_add_array "voicemails"
|
||||||
|
|
||||||
find /srv/voip/voicemail/default -name "msg*.txt" 2>/dev/null | while read -r txtfile; do
|
find /srv/voip/voicemail/default -name "msg*.txt" 2>/dev/null | while read -r txtfile; do
|
||||||
local ext=$(echo "$txtfile" | sed -n 's|.*/\([0-9]*\)/msg.*|\1|p')
|
ext=$(echo "$txtfile" | sed -n 's|.*/\([0-9]*\)/msg.*|\1|p')
|
||||||
local id=$(basename "$txtfile" .txt)
|
id=$(basename "$txtfile" .txt)
|
||||||
local caller=$(grep "^callerid=" "$txtfile" 2>/dev/null | cut -d'=' -f2)
|
caller=$(grep "^callerid=" "$txtfile" 2>/dev/null | cut -d'=' -f2)
|
||||||
local date=$(grep "^origdate=" "$txtfile" 2>/dev/null | cut -d'=' -f2)
|
date=$(grep "^origdate=" "$txtfile" 2>/dev/null | cut -d'=' -f2)
|
||||||
local duration=$(grep "^duration=" "$txtfile" 2>/dev/null | cut -d'=' -f2)
|
duration=$(grep "^duration=" "$txtfile" 2>/dev/null | cut -d'=' -f2)
|
||||||
|
|
||||||
json_add_object
|
json_add_object
|
||||||
json_add_string "extension" "$ext"
|
json_add_string "extension" "$ext"
|
||||||
@ -112,8 +112,8 @@ JSON
|
|||||||
;;
|
;;
|
||||||
trunk_status)
|
trunk_status)
|
||||||
if lxc-info -n voip -s 2>/dev/null | grep -q "RUNNING"; then
|
if lxc-info -n voip -s 2>/dev/null | grep -q "RUNNING"; then
|
||||||
local output=$(lxc-attach -n voip -- asterisk -rx "pjsip show registrations" 2>/dev/null)
|
output=$(lxc-attach -n voip -- asterisk -rx "pjsip show registrations" 2>/dev/null)
|
||||||
local registered=0
|
registered=0
|
||||||
echo "$output" | grep -q "Registered" && registered=1
|
echo "$output" | grep -q "Registered" && registered=1
|
||||||
|
|
||||||
json_init
|
json_init
|
||||||
@ -125,40 +125,40 @@ JSON
|
|||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
install)
|
install)
|
||||||
local output=$($VOIPCTL install 2>&1)
|
output=$($VOIPCTL install 2>&1)
|
||||||
local rc=$?
|
rc=$?
|
||||||
json_init
|
json_init
|
||||||
json_add_boolean "success" "$((rc == 0))"
|
json_add_boolean "success" "$((rc == 0))"
|
||||||
json_add_string "output" "$output"
|
json_add_string "output" "$output"
|
||||||
json_dump
|
json_dump
|
||||||
;;
|
;;
|
||||||
start)
|
start)
|
||||||
local output=$($VOIPCTL start 2>&1)
|
output=$($VOIPCTL start 2>&1)
|
||||||
local rc=$?
|
rc=$?
|
||||||
json_init
|
json_init
|
||||||
json_add_boolean "success" "$((rc == 0))"
|
json_add_boolean "success" "$((rc == 0))"
|
||||||
json_add_string "output" "$output"
|
json_add_string "output" "$output"
|
||||||
json_dump
|
json_dump
|
||||||
;;
|
;;
|
||||||
stop)
|
stop)
|
||||||
local output=$($VOIPCTL stop 2>&1)
|
output=$($VOIPCTL stop 2>&1)
|
||||||
local rc=$?
|
rc=$?
|
||||||
json_init
|
json_init
|
||||||
json_add_boolean "success" "$((rc == 0))"
|
json_add_boolean "success" "$((rc == 0))"
|
||||||
json_add_string "output" "$output"
|
json_add_string "output" "$output"
|
||||||
json_dump
|
json_dump
|
||||||
;;
|
;;
|
||||||
restart)
|
restart)
|
||||||
local output=$($VOIPCTL restart 2>&1)
|
output=$($VOIPCTL restart 2>&1)
|
||||||
local rc=$?
|
rc=$?
|
||||||
json_init
|
json_init
|
||||||
json_add_boolean "success" "$((rc == 0))"
|
json_add_boolean "success" "$((rc == 0))"
|
||||||
json_add_string "output" "$output"
|
json_add_string "output" "$output"
|
||||||
json_dump
|
json_dump
|
||||||
;;
|
;;
|
||||||
reload)
|
reload)
|
||||||
local output=$($VOIPCTL reload 2>&1)
|
output=$($VOIPCTL reload 2>&1)
|
||||||
local rc=$?
|
rc=$?
|
||||||
json_init
|
json_init
|
||||||
json_add_boolean "success" "$((rc == 0))"
|
json_add_boolean "success" "$((rc == 0))"
|
||||||
json_add_string "output" "$output"
|
json_add_string "output" "$output"
|
||||||
@ -171,8 +171,8 @@ JSON
|
|||||||
json_get_var name name
|
json_get_var name name
|
||||||
json_get_var password password
|
json_get_var password password
|
||||||
|
|
||||||
local output=$($VOIPCTL ext add "$number" "$name" "$password" 2>&1)
|
output=$($VOIPCTL ext add "$number" "$name" "$password" 2>&1)
|
||||||
local rc=$?
|
rc=$?
|
||||||
|
|
||||||
json_init
|
json_init
|
||||||
json_add_boolean "success" "$((rc == 0))"
|
json_add_boolean "success" "$((rc == 0))"
|
||||||
@ -184,8 +184,8 @@ JSON
|
|||||||
json_load "$input"
|
json_load "$input"
|
||||||
json_get_var number number
|
json_get_var number number
|
||||||
|
|
||||||
local output=$($VOIPCTL ext del "$number" 2>&1)
|
output=$($VOIPCTL ext del "$number" 2>&1)
|
||||||
local rc=$?
|
rc=$?
|
||||||
|
|
||||||
json_init
|
json_init
|
||||||
json_add_boolean "success" "$((rc == 0))"
|
json_add_boolean "success" "$((rc == 0))"
|
||||||
@ -198,8 +198,8 @@ JSON
|
|||||||
json_get_var number number
|
json_get_var number number
|
||||||
json_get_var password password
|
json_get_var password password
|
||||||
|
|
||||||
local output=$($VOIPCTL ext passwd "$number" "$password" 2>&1)
|
output=$($VOIPCTL ext passwd "$number" "$password" 2>&1)
|
||||||
local rc=$?
|
rc=$?
|
||||||
|
|
||||||
json_init
|
json_init
|
||||||
json_add_boolean "success" "$((rc == 0))"
|
json_add_boolean "success" "$((rc == 0))"
|
||||||
@ -212,8 +212,8 @@ JSON
|
|||||||
json_get_var from_ext from_ext
|
json_get_var from_ext from_ext
|
||||||
json_get_var to_number to_number
|
json_get_var to_number to_number
|
||||||
|
|
||||||
local output=$($VOIPCTL call "$from_ext" "$to_number" 2>&1)
|
output=$($VOIPCTL call "$from_ext" "$to_number" 2>&1)
|
||||||
local rc=$?
|
rc=$?
|
||||||
|
|
||||||
json_init
|
json_init
|
||||||
json_add_boolean "success" "$((rc == 0))"
|
json_add_boolean "success" "$((rc == 0))"
|
||||||
@ -225,8 +225,8 @@ JSON
|
|||||||
json_load "$input"
|
json_load "$input"
|
||||||
json_get_var channel channel
|
json_get_var channel channel
|
||||||
|
|
||||||
local output=$($VOIPCTL hangup "$channel" 2>&1)
|
output=$($VOIPCTL hangup "$channel" 2>&1)
|
||||||
local rc=$?
|
rc=$?
|
||||||
|
|
||||||
json_init
|
json_init
|
||||||
json_add_boolean "success" "$((rc == 0))"
|
json_add_boolean "success" "$((rc == 0))"
|
||||||
@ -234,8 +234,8 @@ JSON
|
|||||||
json_dump
|
json_dump
|
||||||
;;
|
;;
|
||||||
trunk_test)
|
trunk_test)
|
||||||
local output=$($VOIPCTL trunk test 2>&1)
|
output=$($VOIPCTL trunk test 2>&1)
|
||||||
local rc=$?
|
rc=$?
|
||||||
|
|
||||||
json_init
|
json_init
|
||||||
json_add_boolean "success" "$((rc == 0))"
|
json_add_boolean "success" "$((rc == 0))"
|
||||||
@ -248,8 +248,8 @@ JSON
|
|||||||
json_get_var extension extension
|
json_get_var extension extension
|
||||||
json_get_var msg_id msg_id
|
json_get_var msg_id msg_id
|
||||||
|
|
||||||
local output=$($VOIPCTL vm delete "$extension" "$msg_id" 2>&1)
|
output=$($VOIPCTL vm delete "$extension" "$msg_id" 2>&1)
|
||||||
local rc=$?
|
rc=$?
|
||||||
|
|
||||||
json_init
|
json_init
|
||||||
json_add_boolean "success" "$((rc == 0))"
|
json_add_boolean "success" "$((rc == 0))"
|
||||||
@ -260,8 +260,8 @@ JSON
|
|||||||
$VOIPCTL rec status
|
$VOIPCTL rec status
|
||||||
;;
|
;;
|
||||||
rec_enable)
|
rec_enable)
|
||||||
local output=$($VOIPCTL rec enable 2>&1)
|
output=$($VOIPCTL rec enable 2>&1)
|
||||||
local rc=$?
|
rc=$?
|
||||||
|
|
||||||
json_init
|
json_init
|
||||||
json_add_boolean "success" "$((rc == 0))"
|
json_add_boolean "success" "$((rc == 0))"
|
||||||
@ -269,8 +269,8 @@ JSON
|
|||||||
json_dump
|
json_dump
|
||||||
;;
|
;;
|
||||||
rec_disable)
|
rec_disable)
|
||||||
local output=$($VOIPCTL rec disable 2>&1)
|
output=$($VOIPCTL rec disable 2>&1)
|
||||||
local rc=$?
|
rc=$?
|
||||||
|
|
||||||
json_init
|
json_init
|
||||||
json_add_boolean "success" "$((rc == 0))"
|
json_add_boolean "success" "$((rc == 0))"
|
||||||
@ -289,8 +289,8 @@ JSON
|
|||||||
json_load "$input"
|
json_load "$input"
|
||||||
json_get_var filename filename
|
json_get_var filename filename
|
||||||
|
|
||||||
local output=$($VOIPCTL rec delete "$filename" 2>&1)
|
output=$($VOIPCTL rec delete "$filename" 2>&1)
|
||||||
local rc=$?
|
rc=$?
|
||||||
|
|
||||||
json_init
|
json_init
|
||||||
json_add_boolean "success" "$((rc == 0))"
|
json_add_boolean "success" "$((rc == 0))"
|
||||||
@ -302,18 +302,18 @@ JSON
|
|||||||
json_load "$input"
|
json_load "$input"
|
||||||
json_get_var filename filename
|
json_get_var filename filename
|
||||||
|
|
||||||
local path=$($VOIPCTL rec download "$filename" 2>&1)
|
path=$($VOIPCTL rec download "$filename" 2>&1)
|
||||||
local rc=$?
|
rc=$?
|
||||||
|
|
||||||
json_init
|
json_init
|
||||||
if [ $rc -eq 0 ]; then
|
if [ $rc -eq 0 ]; then
|
||||||
json_add_boolean "success" 1
|
json_add_boolean "success" 1
|
||||||
json_add_string "path" "$path"
|
json_add_string "path" "$path"
|
||||||
# Also provide base64 content for small files
|
# Also provide base64 content for small files
|
||||||
local size=$(stat -c%s "$path" 2>/dev/null || echo 0)
|
size=$(stat -c%s "$path" 2>/dev/null || echo 0)
|
||||||
if [ "$size" -lt 5000000 ]; then
|
if [ "$size" -lt 5000000 ]; then
|
||||||
# Base64 encode files under 5MB
|
# Base64 encode files under 5MB
|
||||||
local b64=$(base64 -w 0 "$path" 2>/dev/null)
|
b64=$(base64 -w 0 "$path" 2>/dev/null)
|
||||||
json_add_string "content" "$b64"
|
json_add_string "content" "$b64"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
@ -328,8 +328,8 @@ JSON
|
|||||||
json_get_var days days
|
json_get_var days days
|
||||||
|
|
||||||
[ -z "$days" ] && days=30
|
[ -z "$days" ] && days=30
|
||||||
local output=$($VOIPCTL rec cleanup "$days" 2>&1)
|
output=$($VOIPCTL rec cleanup "$days" 2>&1)
|
||||||
local rc=$?
|
rc=$?
|
||||||
|
|
||||||
json_init
|
json_init
|
||||||
json_add_boolean "success" "$((rc == 0))"
|
json_add_boolean "success" "$((rc == 0))"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user