mirror of
https://github.com/openwrt/telephony.git
synced 2025-12-21 19:14:34 +04:00
Adds a new UCI config section that allows the user to define accounts from which the init script will create the /etc/baresip/accounts file. Using UCI has the big benefit, that changes in the config can be recognized by reload_config which will restart baresip automatically. Example /etc/config/baresip: -- config baresip main option enable 1 option options '' config account option user '+49123456789' option password '' option server 'tel.t-online.de' option transport 'tls' option mediaenc 'srtp' config account option user '12' option password '7282ce22eee6d91193a1d5014398356x' option server '172.27.0.97' option transport 'udp' option append 'answerdelay=0;rwait=90;mwi=no' option ignore 1 -- The basic account options user,password,server,mediaenc and tansport can be set directly. All other custom baresip account options can be append to the account string using the 'append' option. Signed-off-by: Daniel Danzberger <dd@embedd.com>
63 lines
1.2 KiB
Bash
63 lines
1.2 KiB
Bash
#!/bin/sh /etc/rc.common
|
|
# Copyright (C) 2017 OpenWrt.org
|
|
|
|
START=92
|
|
USE_PROCD=1
|
|
PROG=/usr/bin/baresip
|
|
ACCOUNTS=
|
|
|
|
add_account()
|
|
{
|
|
local user password server transport append ignore mediaenc
|
|
local acc
|
|
|
|
uci_validate_section baresip account "${1}" \
|
|
'ignore:bool:0' \
|
|
'user:string' \
|
|
'password:string' \
|
|
'server:string' \
|
|
'transport:string:udp' \
|
|
'mediaenc:string' \
|
|
'append:string'
|
|
|
|
[ "$ignore" = "0" ] || return
|
|
|
|
acc="<sip:${user}@${server};transport=${transport}>"
|
|
[ -n "$mediaenc" ] && acc="${acc};mediaenc=${mediaenc}"
|
|
[ -n "$password" ] && acc="${acc};auth_pass=${password}"
|
|
[ -n "$append" ] && acc="${acc};${append}"
|
|
|
|
ACCOUNTS="${ACCOUNTS}${acc}\n"
|
|
}
|
|
|
|
start_service()
|
|
{
|
|
local enable options
|
|
|
|
uci_validate_section baresip baresip main \
|
|
'enable:bool:0' \
|
|
'options:string'
|
|
|
|
[ "$enable" = "0" ] && return
|
|
|
|
config_load baresip
|
|
config_foreach add_account account
|
|
printf "$ACCOUNTS" > /etc/baresip/accounts
|
|
|
|
procd_open_instance
|
|
procd_set_param command $PROG -f /etc/baresip $options
|
|
procd_set_param user baresip
|
|
procd_set_param respawn
|
|
procd_close_instance
|
|
}
|
|
|
|
service_triggers()
|
|
{
|
|
procd_add_reload_trigger baresip
|
|
}
|
|
|
|
reload_service()
|
|
{
|
|
/etc/init.d/baresip restart
|
|
}
|