Commit dd03ae48 authored by Yalu Zhang's avatar Yalu Zhang

Asterisk: improve scripts to generate asterisk configuration files from UCI

- Change asterisk config directory from /etc/asterisk to /var/etc/asterisk
- Remove some config templates. Some of them are unused and others can be generated on the fly
- Refine the scripts
- Fix some errors
- Other general improvements
parent 8d1577ed
......@@ -348,7 +348,7 @@ endef
define Package/$(PKG_NAME)/install/conffile
$(INSTALL_DIR) $(1)/etc/asterisk
$(CP) $(PKG_INSTALL_DIR)/etc/asterisk/$(2) $(1)/etc/asterisk/
@echo "Skip installing $(PKG_INSTALL_DIR)/etc/asterisk/$(2) to $(1)/etc/asterisk/"
endef
define Package/$(PKG_NAME)/install/lib
......@@ -487,7 +487,6 @@ define Package/$(PKG_NAME)/conffiles
/etc/asterisk/stasis.conf
/etc/asterisk/udptl.conf
/etc/asterisk/users.conf
/etc/default/asterisk
/etc/init.d/asterisk
endef
......@@ -511,21 +510,24 @@ define Package/$(PKG_NAME)/install
$(foreach m,$(AST_CFG_FILES),$(call Package/$(PKG_NAME)/install/conffile,$(1),$(m));)
$(foreach m,$(AST_EMB_MODULES),$(call Package/$(PKG_NAME)/install/module,$(1),$(m));)
$(INSTALL_DIR) $(1)/usr/share/asterisk/sounds/
$(INSTALL_DIR) $(1)/etc/default
$(INSTALL_DATA) ./files/asterisk.default $(1)/etc/default/asterisk
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/asterisk.init $(1)/etc/init.d/asterisk
# res_crypto is not referenced for now and it causes asterisk crash. So remove it
$(RM) -f $(1)/usr/lib/asterisk/modules/res_crypto.so
# iopsys extenstions
@echo "Replace all asterisk configuration samples with iopsys templates"
$(INSTALL_DIR) $(1)/etc/asterisk
$(RM) -f $(1)/etc/asterisk/*
$(CP) ./files/iopsys/* $(1)/
ifeq ($(PLATFORM),INTEL)
mv $(1)/etc/asterisk_templates/tapi.conf.TEMPLATE $(1)/etc/asterisk_templates/chan_telephony.conf.TEMPLATE
$(RM) $(1)/etc/asterisk_templates/brcm.conf.TEMPLATE
mv $(1)/etc/asterisk/tapi.conf $(1)/etc/asterisk/chan_telephony.conf
$(RM) $(1)/etc/asterisk/brcm.conf
else ifeq ($(PLATFORM),BROADCOM)
mv $(1)/etc/asterisk_templates/brcm.conf.TEMPLATE $(1)/etc/asterisk_templates/chan_telephony.conf.TEMPLATE
$(RM) $(1)/etc/asterisk_templates/tapi.conf.TEMPLATE
mv $(1)/etc/asterisk/brcm.conf $(1)/etc/asterisk/chan_telephony.conf
$(RM) $(1)/etc/asterisk/tapi.conf
endif
endef
define Package/$(PKG_NAME)-sounds
......
......@@ -3,13 +3,11 @@
START=99
USE_PROCD=1
APP=asterisk
OPTIONS=
DEST=
DEFAULT=$DEST/etc/default/$APP
BIN_FILE=$DEST/usr/sbin/$APP
PID_FILE=$DEST/var/run/$APP/$APP.pid
SERVICE_PID_FILE="/var/run/asterisk/asterisk.pid" \
DEFAULT=/etc/default/asterisk
SERVICE_PID_FILE="/var/run/asterisk/asterisk"
BIN_FILE=/usr/sbin/asterisk
OPTIONS="-C /var/etc/asterisk/asterisk.conf"
RUNNING_DIRS="/var/run/asterisk /var/spool/asterisk /var/lib/asterisk/keys /var/log/asterisk/cdr-csv /usr/lib/asterisk/moh"
. /lib/voice/config_asterisk.sh
......@@ -17,13 +15,9 @@ start_service() {
generate_asterisk_config_files
/sbin/voice-monitor &
[ -f $DEFAULT ] && . $DEFAULT
[ -d $DEST/var/run/asterisk ] || mkdir -p $DEST/var/run/asterisk
[ -d $DEST/var/log/asterisk ] || mkdir -p $DEST/var/log/asterisk
[ -d $DEST/var/spool/asterisk ] || mkdir -p $DEST/var/spool/asterisk
[ -d $DEST/var/lib/asterisk ] || mkdir -p $DEST/var/lib/asterisk
[ -d $DEST/var/lib/asterisk/keys ] || mkdir -p $DEST/var/lib/asterisk/keys
[ -d $DEST/var/log/asterisk/cdr-csv ] || mkdir -p $DEST/var/log/asterisk/cdr-csv
for dir in $RUNNING_DIRS; do
[ -d $dir ] || mkdir -p $dir
done
service_start $BIN_FILE $OPTIONS
}
......@@ -31,6 +25,7 @@ start_service() {
stop_service() {
/sbin/voice-monitor stop
service_stop $BIN_FILE
pidof asterisk > /dev/null && killall asterisk
}
reload_service() {
......@@ -39,17 +34,13 @@ reload_service() {
# turn off voice led; asterisk will turn it on if there is a registered account
ubus call led.voice1 set '{"state":"off"}'
# FXS channel module must be reloaded before sip module. Otherwise some attributes like
# line's registration state which is updated by SIP module through callback might be
# reset.
$BIN_FILE -rx "config reload $ASTERISKDIR/indications.conf"
$BIN_FILE -rx "telephony reload"
$BIN_FILE -rx "config reload $ASTERISKDIR/sip.conf"
$BIN_FILE -x "telephony reload"
$BIN_FILE -x "sip reload"
sleep 1
$BIN_FILE -rx "core reload"
$BIN_FILE -rx "dialplan reload"
$BIN_FILE -x "core reload"
}
service_triggers() {
procd_add_reload_trigger $(getUciConfig)
procd_add_reload_trigger $VOICE_UCI
}
[directories](!)
astetcdir => /etc/asterisk
[directories]
astetcdir => /var/etc/asterisk
astmoddir => /usr/lib/asterisk/modules
astvarlibdir => /var/lib/asterisk
astdbdir => /var/lib/asterisk
......@@ -74,7 +74,7 @@ documentation_language = en_US ; Set the language you want documentation
hideconnect = yes ; Hide messages displayed when a remote console
; connects and disconnects.
;lockconfdir = no ; Protect the directory containing the
; configuration files (/etc/asterisk) with a
; configuration files with a
; lock.
;stdexten = gosub ; How to invoke the extensions.conf stdexten.
; macro - Invoke the stdexten using a macro as
......
;------------------------------------------------------------------------------
; Allows customized handling of outgoing calls.
;
; extensions_macro.conf
; - The called extension is stored in DIAL_EXTEN and may be altered
;
; - If enabled, this macro will be called before an outbound call is placed
; but after matching any local or special extensions
;
; - Control will be handed back to normal call handler at the end of this
; macro unless the call is ended with Hangup() or similar.
;------------------------------------------------------------------------------
[macro-custom-outgoing]
;Example macro, will playback monkeys if calling extension 1234
exten => s,1, GotoIf($["${DIAL_EXTEN}" = "1234"]?monkeys:continue)
exten => s,n(monkeys), Playback(tt-monkeys)
exten => s,n, Hangup()
exten => s,n(continue), NoOp(Continue with normal outgoing call to ${DIAL_EXTEN})
;------------------------------------------------------------------------------
; Allows customized handling of incoming calls.
; NOTE: any extension matching _[0-9a-zA-Z]. will end up here. Make sure
; to handle extensions in a secure way - follw best practices.
;
; - The called extension is stored in MACRO_EXTEN
;
; - If enabled, this macro will be called before normal call handling begins
;
; - Control will be handed back to normal call handler at the end of this
; macro unless the call is ended with Hangup() or similar.
;------------------------------------------------------------------------------
[macro-custom-incoming]
; Example macro, will play a beep before continuing normal call procedure
exten => s,1,Answer()
exten => s,n,NoOp(Custom handling for incoming call to extension ${MACRO_EXTEN})
exten => s,n,Playback(beep)
;------------------------------------------------------------------------------
; Allows customized actions when other party hangs up, for example
; playing a beep or busy tone to indicate that call is ended.
;------------------------------------------------------------------------------
[macro-custom-hangup]
exten => s,1,Playtones(busy)
exten => s,n,Wait(10)
exten => s,n,Hangup()
; Manage Call Forwarding on busy/no answer/immediate in asterisk.
;
; Macros to set up call forwarding via an extension (normally *21* or similar).
......
......@@ -55,7 +55,7 @@ tlsbindaddr=0.0.0.0
tlsdontverifyserver=no
tlscipher=|TLSCIPHER|
tlsclientmethod=|TLSCLIENTMETHOD|
tlscafile=/etc/asterisk/ssl/ca.pem
tlscafile=/var/etc/asterisk/ssl/ca.pem
transport=udp|TCPTRANSPORT||TLSTRANSPORT|
......
[plc]
genericplc = |PLC| ;Enables packet loss concealment [yes/no]
[general]
enable=|ENABLE|
refreshinterval=|REFRESHINTERVAL|
[telline_dialtone]
;Hints to set dialtone according to sip reg status
[|PROVIDER|-direct]
; extensions that will be dialled immediately when they are matched
; useful for fixed length number series
;------------------------------------------------------------------------------
; Allows customized handling of outgoing calls.
;
; - The called extension is stored in DIAL_EXTEN and may be altered
;
; - If enabled, this macro will be called before an outbound call is placed
; but after matching any local or special extensions
;
; - Control will be handed back to normal call handler at the end of this
; macro unless the call is ended with Hangup() or similar.
;------------------------------------------------------------------------------
[macro-custom-outgoing]
;Example macro, will playback monkeys if calling extension 1234
exten => s,1, GotoIf($["${DIAL_EXTEN}" = "1234"]?monkeys:continue)
exten => s,n(monkeys), Playback(tt-monkeys)
exten => s,n, Hangup()
exten => s,n(continue), NoOp(Continue with normal outgoing call to ${DIAL_EXTEN})
;------------------------------------------------------------------------------
; Allows customized handling of incoming calls.
; NOTE: any extension matching _[0-9a-zA-Z]. will end up here. Make sure
; to handle extensions in a secure way - follw best practices.
;
; - The called extension is stored in MACRO_EXTEN
;
; - If enabled, this macro will be called before normal call handling begins
;
; - Control will be handed back to normal call handler at the end of this
; macro unless the call is ended with Hangup() or similar.
;------------------------------------------------------------------------------
[macro-custom-incoming]
; Example macro, will play a beep before continuing normal call procedure
exten => s,1,Answer()
exten => s,n,NoOp(Custom handling for incoming call to extension ${MACRO_EXTEN})
exten => s,n,Playback(beep)
;------------------------------------------------------------------------------
; Allows customized actions when other party hangs up, for example
; playing a beep or busy tone to indicate that call is ended.
;------------------------------------------------------------------------------
[macro-custom-hangup]
exten => s,1,Playtones(busy)
exten => s,n,Wait(10)
exten => s,n,Hangup()
[call_line]
; Incoming calls will end up in this context when a local line should be dialled
exten => |CONTACT_USER|,1, Set(__TRANSFER_CONTEXT=transfer_${CHANNEL(peername)})
exten => |CONTACT_USER|,n, Dial(|LINES|,,F(hangup,h,2),20)
exten => |CONTACT_USER|,n, Goto(s-${DIALSTATUS},1)
exten => |CONTACT_USER|,n, Hangup()
exten => |CONTACT_USER|,n(busy),Macro(callhandler-noanswer,${CHANNEL(peername)})
exten => s-BUSY,1, Goto(|CONTACT_USER|,busy)
exten => s-NOANSWER,1, Goto(|CONTACT_USER|,busy)
\ No newline at end of file
;
; Configuration file for the res_stun_monitor module
;
[general]
;
; ---- STUN Server configuration ---
; Setting the 'stunaddr' option to a valid address enables the STUN monitor.
;
stunaddr = |SERVER|
stunrefresh = 30
register => |TRANSPORT|://|USER|@|DOMAIN|:|SECRET||AUTHUSER|@|PROVIDER||PORT|/|CONTACT_USER|
#exec echo 'register => |TRANSPORT|://|USER|@|DOMAIN|:'$(/usr/bin/voicesec -d /usr/lib/asterisk/voicesec_|PROVIDER|)'|AUTHUSER|@|PROVIDER||PORT|/|CONTACT_USER|'
. /lib/voice/utils.sh
rtpstart=$(uci -q get $(getUciConfig).SIP.rtpstart)
rtpstart=$(uci -q get $VOICE_UCI_CONFIG.SIP.rtpstart)
rtpstart=${rtpstart:-10000}
rtpend=$(uci -q get $(getUciConfig).SIP.rtpend)
rtpend=$(uci -q get $VOICE_UCI_CONFIG.SIP.rtpend)
rtpend=${rtpend:-20000}
iptables -I zone_wan_input -m udp -p udp --dport $rtpstart:$rtpend -m comment --comment "!fw3: Allow-RTP" -j ACCEPT
......@@ -4,7 +4,7 @@
[ "$ACTION" = "ifup" -a "$(uci -q get network.$INTERFACE.is_lan)" != "1" ] || exit 0
config_load $(getUciConfig)
config_load $VOICE_UCI_CONFIG
config_get bindintf SIP bindintf
[ -n "$bindintf" -a "$INTERFACE" != "$bindintf" ] && exit 0
......@@ -17,5 +17,5 @@ if [ -n "$bindintf" ]; then
fi
bindaddr="${bindaddr:-::}"
sed -i "s/bindaddr=.*/bindaddr=$bindaddr/g" /etc/asterisk/sip.conf
sed -i "s/bindaddr=.*/bindaddr=$bindaddr/g" $ASTERISK_CONF_DIR/sip.conf
[ -e /var/run/asterisk/asterisk.ctl ] && asterisk -rx "sip reload"
......@@ -3,30 +3,30 @@
. /lib/voice/utils.sh
# Add call filter section
uci -q get $(getUciConfig).call_filter0 >/dev/null || {
uci -q get $VOICE_UCI_CONFIG.call_filter0 >/dev/null || {
uci -q batch <<-EOT
add $(getUciConfig) call_filter
rename $(getUciConfig).@call_filter[-1]=call_filter0
set $(getUciConfig).call_filter0.block_foreign=0
set $(getUciConfig).call_filter0.block_special_rate=0
set $(getUciConfig).call_filter0.block_outgoing=0
set $(getUciConfig).call_filter0.block_incoming=0
commit $(getUciConfig)
add $VOICE_UCI_CONFIG call_filter
rename $VOICE_UCI_CONFIG.@call_filter[-1]=call_filter0
set $VOICE_UCI_CONFIG.call_filter0.block_foreign=0
set $VOICE_UCI_CONFIG.call_filter0.block_special_rate=0
set $VOICE_UCI_CONFIG.call_filter0.block_outgoing=0
set $VOICE_UCI_CONFIG.call_filter0.block_incoming=0
commit $VOICE_UCI_CONFIG
EOT
}
# Add ringing schedule section
uci -q get $(getUciConfig).RINGING_STATUS >/dev/null || {
uci -q get $VOICE_UCI_CONFIG.RINGING_STATUS >/dev/null || {
uci -q batch <<-EOT
add $(getUciConfig) ringing_status
rename $(getUciConfig).@ringing_status[-1]=RINGING_STATUS
set $(getUciConfig).RINGING_STATUS.status=0
set $(getUciConfig).RINGING_STATUS.enabled=0
set $(getUciConfig).RINGING_STATUS.shouldring=1
commit $(getUciConfig)
add $VOICE_UCI_CONFIG ringing_status
rename $VOICE_UCI_CONFIG.@ringing_status[-1]=RINGING_STATUS
set $VOICE_UCI_CONFIG.RINGING_STATUS.status=0
set $VOICE_UCI_CONFIG.RINGING_STATUS.enabled=0
set $VOICE_UCI_CONFIG.RINGING_STATUS.shouldring=1
commit $VOICE_UCI_CONFIG
EOT
}
......@@ -41,11 +41,11 @@ uci -q batch <<-EOT
EOT
# If dtmfmode is set to the obsolete compatability change to auto
sed -i 's/dtmfmode\s*=\s*compatibility/dtmfmode=auto/' /etc/asterisk/sip.conf
sed -i 's/dtmfmode\s*=\s*compatibility/dtmfmode=auto/' $ASTERISK_CONF_DIR/sip.conf
if [ "$(uci get $(getUciConfig).SIP.dtmfmode)" == "compatibility" ]; then
uci set $(getUciConfig).SIP.dtmfmode="auto"
uci commit $(getUciConfig)
if [ "$(uci get $VOICE_UCI_CONFIG.SIP.dtmfmode)" == "compatibility" ]; then
uci set $VOICE_UCI_CONFIG.SIP.dtmfmode="auto"
uci commit $VOICE_UCI_CONFIG
fi
exit 0
......@@ -3,12 +3,12 @@
. /lib/voice/utils.sh
if [ $2 != '?' ]; then
for tel_line in `uci show $(getUciConfig) | grep telline | grep $1 | cut -d . -f 2`; do
sed -i "/\[$tel_line\]/,/^\[/ s/\(callwaiting=\)[0-9]/\1$2/" /etc/asterisk/chan_telephony.conf
for tel_line in `uci show $VOICE_UCI_CONFIG | grep telline | grep $1 | cut -d . -f 2`; do
sed -i "/\[$tel_line\]/,/^\[/ s/\(callwaiting=\)[0-9]/\1$2/" $ASTERISK_CONF_DIR/chan_telephony.conf
done
else
for tel_line in `uci show $(getUciConfig) | grep telline | grep $1 | cut -d . -f 2`; do
status=`sed -n "/\[$tel_line\]/,/^\[/ s/callwaiting=\([0-9]\)/\1/p" /etc/asterisk/chan_telephony.conf`
for tel_line in `uci show $VOICE_UCI_CONFIG | grep telline | grep $1 | cut -d . -f 2`; do
status=`sed -n "/\[$tel_line\]/,/^\[/ s/callwaiting=\([0-9]\)/\1/p" $ASTERISK_CONF_DIR/chan_telephony.conf`
echo $status
exit 0
done
......
#!/bin/sh
# Utilities for voice
getUciConfig() {
echo "asterisk"
}
VOICE_UCI_CONFIG=asterisk
ASTERISK_CONF_DIR=/var/etc/asterisk
getSerial() {
sn=$(uci -q get /lib/db/config/hw.board.serial_number)
......
......@@ -10,12 +10,12 @@ fi
[ "$1" == "stop" ] && exit
ACCOUNTENABLED=0
for peer in $(uci show $(getUciConfig) | grep sip_service_provider | awk -F[.,=] '{print$2}'); do
[ "$(uci -q get $(getUciConfig).$peer.enabled)" == "1" ] && ACCOUNTENABLED=1
for peer in $(uci show $VOICE_UCI_CONFIG | grep sip_service_provider | awk -F[.,=] '{print$2}'); do
[ "$(uci -q get $VOICE_UCI_CONFIG.$peer.enabled)" == "1" ] && ACCOUNTENABLED=1
done
if [ $ACCOUNTENABLED -eq 0 ]; then
ubus call led.voice set '{"state":"off"}'
ubus call led.voice1 set '{"state":"off"}'
exit
fi
......@@ -54,10 +54,10 @@ while read event ; do
json_get_var status status
if [ "$status" == "Registered" ]; then
REGISTERED=1
[ $OFFHOOK -eq 0 ] && ubus call led.voice set '{"state":"ok"}'
[ $OFFHOOK -eq 0 ] && ubus call led.voice1 set '{"state":"ok"}'
else
REGISTERED=0
[ $OFFHOOK -eq 0 ] && ubus call led.voice set '{"state":"error"}'
[ $OFFHOOK -eq 0 ] && ubus call led.voice1 set '{"state":"error"}'
fi
elif json_select asterisk.endpoint >/dev/null; then
json_get_var event event
......@@ -65,14 +65,14 @@ while read event ; do
case $event in
OFFHOOK)
OFFHOOK=1
ubus call led.voice set '{"state":"notice"}'
ubus call led.voice1 set '{"state":"notice"}'
;;
ONHOOK)
OFFHOOK=0
if [ $REGISTERED -eq 1 ]; then
ubus call led.voice set '{"state":"ok"}'
ubus call led.voice1 set '{"state":"ok"}'
else
ubus call led.voice set '{"state":"error"}'
ubus call led.voice1 set '{"state":"error"}'
fi
;;
*)
......
......@@ -25,7 +25,7 @@ case "$1" in
json_init
json_add_object "sip"
for peer in $(uci show $(getUciConfig) | grep sip_service_provider | awk -F[.,=] '{print$2}'); do
for peer in $(uci show $VOICE_UCI_CONFIG | grep sip_service_provider | awk -F[.,=] '{print$2}'); do
asterisk -x 'sip show registry' | grep $peer: > /tmp/sip_reg.status
asterisk -x "sip show peer $peer" > /tmp/sip_peer.status
json_add_object "$peer"
......@@ -49,7 +49,7 @@ case "$1" in
json_select ..
json_add_object "tel"
for line in $(uci show $(getUciConfig) | grep tel_line | awk -F[.,=] '{print$2}'); do
for line in $(uci show $VOICE_UCI_CONFIG | grep tel_line | awk -F[.,=] '{print$2}'); do
json_add_object "$line"
linestate="ONHOOK"
len_line=${#line}
......@@ -76,10 +76,10 @@ case "$1" in
;;
codecs)
json_init
for codec in $(uci show $(getUciConfig) | grep supported_codec | awk -F[.,=] '{print$2}'); do
for codec in $(uci show $VOICE_UCI_CONFIG | grep supported_codec | awk -F[.,=] '{print$2}'); do
json_add_object "$codec"
json_add_string name "$(uci -q get $(getUciConfig).$codec.name)"
bitrate=$(uci -q get $(getUciConfig).$codec.bitrate)
json_add_string name "$(uci -q get $VOICE_UCI_CONFIG.$codec.name)"
bitrate=$(uci -q get $VOICE_UCI_CONFIG.$codec.bitrate)
[ -n "$bitrate" ] && json_add_int bitrate $bitrate
json_select ..
done
......@@ -106,14 +106,14 @@ case "$1" in
[ -z "$from" ] && [ -z "$to" ] && continue
account="$(echo $line | cut -d',' -f4)"
actok=0
uci show $(getUciConfig) | grep sip_service_provider | grep -wq "$account" && actok=1
uci show $VOICE_UCI_CONFIG | grep sip_service_provider | grep -wq "$account" && actok=1
[ "$account" == "call_line" ] && actok=1
[ $actok -eq 0 ] && continue
timestart="$(echo $line | awk -F',' '{print $(NF-8)}')"
timend="$(echo $line | awk -F',' '{print $(NF-6)}')"
startdate=$(date -u -d "$timestart" +"%s")
enddate=$(date -u -d "$timend" +"%s")
uci show $(getUciConfig) | grep user | grep -wq "$from" && direction="OUTGOING" || direction="INCOMING"
uci show $VOICE_UCI_CONFIG | grep user | grep -wq "$from" && direction="OUTGOING" || direction="INCOMING"
json_add_object ""
json_add_string uniqueid "$uniqueid"
json_add_string time "$timestart"
......
......@@ -66,8 +66,8 @@ set_ringing_schedule() {
if [ $daymatch -eq 1 -a $current_time -gt ${start/:/} -a $current_time -lt ${stop/:/} ]; then
timematch=1
uci -q set $(getUciConfig).RINGING_STATUS.shouldring="$status"
uci commit $(getUciConfig)
uci -q set $VOICE_UCI_CONFIG.RINGING_STATUS.shouldring="$status"
uci commit $VOICE_UCI_CONFIG
fi
echo "$start_min $start_hour * * $dayns ringing $sta # Ringing_Schedule" >> /etc/crontabs/root
......@@ -81,13 +81,13 @@ ringing_schedule() {
sed -i "/Ringing_Schedule/ d" /etc/crontabs/root
config_load $(getUciConfig)
config_load $VOICE_UCI_CONFIG
config_get_bool schedule RINGING_STATUS enabled "0"
if [ $schedule == "0" ]; then
uci -q set $(getUciConfig).RINGING_STATUS.shouldring="1"
uci commit $(getUciConfig)
uci -q set $VOICE_UCI_CONFIG.RINGING_STATUS.shouldring="1"
uci commit $VOICE_UCI_CONFIG
return
fi
......@@ -97,23 +97,23 @@ ringing_schedule() {
if [ $timematch -eq 0 ]; then
[ $sched_status == "1" ] && revstatus="0" || revstatus="1"
uci -q set $(getUciConfig).RINGING_STATUS.shouldring="$revstatus"
uci commit $(getUciConfig)
uci -q set $VOICE_UCI_CONFIG.RINGING_STATUS.shouldring="$revstatus"
uci commit $VOICE_UCI_CONFIG
fi
}
ringing_onoff() {
local status="$1"
[ "$status" == "on" ] && status="1" || status="0"
local cursta="$(uci -q get $(getUciConfig).RINGING_STATUS.shouldring)"
local cursta="$(uci -q get $VOICE_UCI_CONFIG.RINGING_STATUS.shouldring)"
cursta="${cursta:-1}"
if [ "$status" == "$cursta" ]; then
return
fi
uci -q set $(getUciConfig).RINGING_STATUS.shouldring="$status"
uci commit $(getUciConfig)
uci -q set $VOICE_UCI_CONFIG.RINGING_STATUS.shouldring="$status"
uci commit $VOICE_UCI_CONFIG
/etc/init.d/asterisk reload
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment