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)
|
||||
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_add_array "calls"
|
||||
|
||||
@ -92,11 +92,11 @@ JSON
|
||||
json_add_array "voicemails"
|
||||
|
||||
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')
|
||||
local id=$(basename "$txtfile" .txt)
|
||||
local caller=$(grep "^callerid=" "$txtfile" 2>/dev/null | cut -d'=' -f2)
|
||||
local date=$(grep "^origdate=" "$txtfile" 2>/dev/null | cut -d'=' -f2)
|
||||
local duration=$(grep "^duration=" "$txtfile" 2>/dev/null | cut -d'=' -f2)
|
||||
ext=$(echo "$txtfile" | sed -n 's|.*/\([0-9]*\)/msg.*|\1|p')
|
||||
id=$(basename "$txtfile" .txt)
|
||||
caller=$(grep "^callerid=" "$txtfile" 2>/dev/null | cut -d'=' -f2)
|
||||
date=$(grep "^origdate=" "$txtfile" 2>/dev/null | cut -d'=' -f2)
|
||||
duration=$(grep "^duration=" "$txtfile" 2>/dev/null | cut -d'=' -f2)
|
||||
|
||||
json_add_object
|
||||
json_add_string "extension" "$ext"
|
||||
@ -112,8 +112,8 @@ JSON
|
||||
;;
|
||||
trunk_status)
|
||||
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)
|
||||
local registered=0
|
||||
output=$(lxc-attach -n voip -- asterisk -rx "pjsip show registrations" 2>/dev/null)
|
||||
registered=0
|
||||
echo "$output" | grep -q "Registered" && registered=1
|
||||
|
||||
json_init
|
||||
@ -125,40 +125,40 @@ JSON
|
||||
fi
|
||||
;;
|
||||
install)
|
||||
local output=$($VOIPCTL install 2>&1)
|
||||
local rc=$?
|
||||
output=$($VOIPCTL install 2>&1)
|
||||
rc=$?
|
||||
json_init
|
||||
json_add_boolean "success" "$((rc == 0))"
|
||||
json_add_string "output" "$output"
|
||||
json_dump
|
||||
;;
|
||||
start)
|
||||
local output=$($VOIPCTL start 2>&1)
|
||||
local rc=$?
|
||||
output=$($VOIPCTL start 2>&1)
|
||||
rc=$?
|
||||
json_init
|
||||
json_add_boolean "success" "$((rc == 0))"
|
||||
json_add_string "output" "$output"
|
||||
json_dump
|
||||
;;
|
||||
stop)
|
||||
local output=$($VOIPCTL stop 2>&1)
|
||||
local rc=$?
|
||||
output=$($VOIPCTL stop 2>&1)
|
||||
rc=$?
|
||||
json_init
|
||||
json_add_boolean "success" "$((rc == 0))"
|
||||
json_add_string "output" "$output"
|
||||
json_dump
|
||||
;;
|
||||
restart)
|
||||
local output=$($VOIPCTL restart 2>&1)
|
||||
local rc=$?
|
||||
output=$($VOIPCTL restart 2>&1)
|
||||
rc=$?
|
||||
json_init
|
||||
json_add_boolean "success" "$((rc == 0))"
|
||||
json_add_string "output" "$output"
|
||||
json_dump
|
||||
;;
|
||||
reload)
|
||||
local output=$($VOIPCTL reload 2>&1)
|
||||
local rc=$?
|
||||
output=$($VOIPCTL reload 2>&1)
|
||||
rc=$?
|
||||
json_init
|
||||
json_add_boolean "success" "$((rc == 0))"
|
||||
json_add_string "output" "$output"
|
||||
@ -171,8 +171,8 @@ JSON
|
||||
json_get_var name name
|
||||
json_get_var password password
|
||||
|
||||
local output=$($VOIPCTL ext add "$number" "$name" "$password" 2>&1)
|
||||
local rc=$?
|
||||
output=$($VOIPCTL ext add "$number" "$name" "$password" 2>&1)
|
||||
rc=$?
|
||||
|
||||
json_init
|
||||
json_add_boolean "success" "$((rc == 0))"
|
||||
@ -184,8 +184,8 @@ JSON
|
||||
json_load "$input"
|
||||
json_get_var number number
|
||||
|
||||
local output=$($VOIPCTL ext del "$number" 2>&1)
|
||||
local rc=$?
|
||||
output=$($VOIPCTL ext del "$number" 2>&1)
|
||||
rc=$?
|
||||
|
||||
json_init
|
||||
json_add_boolean "success" "$((rc == 0))"
|
||||
@ -198,8 +198,8 @@ JSON
|
||||
json_get_var number number
|
||||
json_get_var password password
|
||||
|
||||
local output=$($VOIPCTL ext passwd "$number" "$password" 2>&1)
|
||||
local rc=$?
|
||||
output=$($VOIPCTL ext passwd "$number" "$password" 2>&1)
|
||||
rc=$?
|
||||
|
||||
json_init
|
||||
json_add_boolean "success" "$((rc == 0))"
|
||||
@ -212,8 +212,8 @@ JSON
|
||||
json_get_var from_ext from_ext
|
||||
json_get_var to_number to_number
|
||||
|
||||
local output=$($VOIPCTL call "$from_ext" "$to_number" 2>&1)
|
||||
local rc=$?
|
||||
output=$($VOIPCTL call "$from_ext" "$to_number" 2>&1)
|
||||
rc=$?
|
||||
|
||||
json_init
|
||||
json_add_boolean "success" "$((rc == 0))"
|
||||
@ -225,8 +225,8 @@ JSON
|
||||
json_load "$input"
|
||||
json_get_var channel channel
|
||||
|
||||
local output=$($VOIPCTL hangup "$channel" 2>&1)
|
||||
local rc=$?
|
||||
output=$($VOIPCTL hangup "$channel" 2>&1)
|
||||
rc=$?
|
||||
|
||||
json_init
|
||||
json_add_boolean "success" "$((rc == 0))"
|
||||
@ -234,8 +234,8 @@ JSON
|
||||
json_dump
|
||||
;;
|
||||
trunk_test)
|
||||
local output=$($VOIPCTL trunk test 2>&1)
|
||||
local rc=$?
|
||||
output=$($VOIPCTL trunk test 2>&1)
|
||||
rc=$?
|
||||
|
||||
json_init
|
||||
json_add_boolean "success" "$((rc == 0))"
|
||||
@ -248,8 +248,8 @@ JSON
|
||||
json_get_var extension extension
|
||||
json_get_var msg_id msg_id
|
||||
|
||||
local output=$($VOIPCTL vm delete "$extension" "$msg_id" 2>&1)
|
||||
local rc=$?
|
||||
output=$($VOIPCTL vm delete "$extension" "$msg_id" 2>&1)
|
||||
rc=$?
|
||||
|
||||
json_init
|
||||
json_add_boolean "success" "$((rc == 0))"
|
||||
@ -260,8 +260,8 @@ JSON
|
||||
$VOIPCTL rec status
|
||||
;;
|
||||
rec_enable)
|
||||
local output=$($VOIPCTL rec enable 2>&1)
|
||||
local rc=$?
|
||||
output=$($VOIPCTL rec enable 2>&1)
|
||||
rc=$?
|
||||
|
||||
json_init
|
||||
json_add_boolean "success" "$((rc == 0))"
|
||||
@ -269,8 +269,8 @@ JSON
|
||||
json_dump
|
||||
;;
|
||||
rec_disable)
|
||||
local output=$($VOIPCTL rec disable 2>&1)
|
||||
local rc=$?
|
||||
output=$($VOIPCTL rec disable 2>&1)
|
||||
rc=$?
|
||||
|
||||
json_init
|
||||
json_add_boolean "success" "$((rc == 0))"
|
||||
@ -289,8 +289,8 @@ JSON
|
||||
json_load "$input"
|
||||
json_get_var filename filename
|
||||
|
||||
local output=$($VOIPCTL rec delete "$filename" 2>&1)
|
||||
local rc=$?
|
||||
output=$($VOIPCTL rec delete "$filename" 2>&1)
|
||||
rc=$?
|
||||
|
||||
json_init
|
||||
json_add_boolean "success" "$((rc == 0))"
|
||||
@ -302,18 +302,18 @@ JSON
|
||||
json_load "$input"
|
||||
json_get_var filename filename
|
||||
|
||||
local path=$($VOIPCTL rec download "$filename" 2>&1)
|
||||
local rc=$?
|
||||
path=$($VOIPCTL rec download "$filename" 2>&1)
|
||||
rc=$?
|
||||
|
||||
json_init
|
||||
if [ $rc -eq 0 ]; then
|
||||
json_add_boolean "success" 1
|
||||
json_add_string "path" "$path"
|
||||
# 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
|
||||
# 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"
|
||||
fi
|
||||
else
|
||||
@ -328,8 +328,8 @@ JSON
|
||||
json_get_var days days
|
||||
|
||||
[ -z "$days" ] && days=30
|
||||
local output=$($VOIPCTL rec cleanup "$days" 2>&1)
|
||||
local rc=$?
|
||||
output=$($VOIPCTL rec cleanup "$days" 2>&1)
|
||||
rc=$?
|
||||
|
||||
json_init
|
||||
json_add_boolean "success" "$((rc == 0))"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user