voice-client: name ubus object voice.asterisk

This commit is contained in:
Sukru Senli 2018-02-25 11:52:36 +01:00
parent 93ae51f1ba
commit dc181b0b75

View file

@ -4,36 +4,11 @@
case "$1" in
list)
echo '{ "registry_status" : {}, "status" : {}, "lines" : {}, "codecs" : {} }'
echo '{ "status" : {}, "lines" : {}, "codecs" : {} }'
;;
call)
case "$2" in
registry_status)
[ -e /var/run/asterisk/asterisk.ctl ] || {
echo "{}"
return
}
asterisk -x 'sip show registry' | tail -n +2 | grep -v "SIP registrations" > /tmp/asterisk.status
json_init
json_add_array "registry"
while read -r line
do
json_add_object ""
json_add_string name "$(echo $line | cut -d':' -f1)"
json_add_string username "$(echo $line | awk '{print$3}')"
json_add_string refresh "$(echo $line | awk '{print$4}')"
json_add_string state "$(echo $line | grep -q 'Auth' && cat /tmp/sip_reg.status | awk '{print$5" "$6}' || echo $line | awk '{print$5}')"
regtime="$(echo $line | grep -q 'Auth' || echo $line | awk '{print$6" "$7" "$8" "$9" "$NF}')"
json_add_string reg_time "$regtime"
json_select ..
done < /tmp/asterisk.status
rm -f /tmp/asterisk.status
json_dump
;;
status)
[ -e /var/run/asterisk/asterisk.ctl ] || {
echo "{}"
@ -83,8 +58,10 @@ case "$1" in
;;
lines)
json_init
json_add_int num_subchannels 2
subchannels=$(asterisk -x 'brcm show status' 2>/dev/null | grep Subchannel | sort -u | wc -l)
[ $subchannels -eq 0 ] && subchannels=2
json_init
json_add_int num_subchannels $subchannels
json_add_int num_lines $(db -q get hw.board.VoicePorts)
json_dump
@ -101,6 +78,31 @@ case "$1" in
json_dump
;;
call_log)
[ -e /var/run/asterisk/asterisk.ctl ] || {
echo "{}"
return
}
asterisk -x 'cdr show active' > /tmp/asterisk.call_log
json_init
json_add_array "call_log"
while read -r line
do
json_add_object ""
json_add_string uniqueid "1518532478.0"
json_add_string time "2018-02-13 15:34:38"
json_add_int duration 15
json_add_string disposition "ANSWERED"
json_add_string direction "OUTGOING"
json_add_string from "0123456789"
json_add_string to "9876543210"
json_select ..
done < /tmp/asterisk.call_log
rm -f /tmp/asterisk.call_log
json_dump
;;
esac
;;
esac