Skip to content

Commit

Permalink
Allow configuration of SIP dial-in
Browse files Browse the repository at this point in the history
  • Loading branch information
dkobras committed Jul 27, 2020
1 parent 7aafcb3 commit 1d84d33
Show file tree
Hide file tree
Showing 6 changed files with 115 additions and 0 deletions.
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ To get up _BigBlueButton_ up and running the following variables can be configur
* `bbb_install_webhooks`: Install the bbb-webhooks package, useful to integrate bbb into other web applications (Default: `True`).
* `bbb_install_greenlight`: Install the Greenlight frontend (Default: `False`)

To configure optional SIP dial-in, define a dict `bbb_sip_providers` (Default: unset) to supply information about each SIP provider. Each key in the dict
corresponds to a provider config. Its value is another dict where each key maps to a parameter of the same name in the BBB SIP configuration. At least
`username`, `password` (for the SIP credentials), `proxy` (FQDN of the SIP gateway), and extension (dial-in number) have to be set. The default dial-in
number for display in human-readable format should be supplied in `bbb_sip_default_dialin`. A verbose dial-in message can be supplied in
`bbb_sip_welcome_footer` (defaults to the message example given in the BBB SIP documentation).

In order to deploy a basic setup of the _Greenlight_ frontend alongside _BigBlueButton_, the following variables can be set:

* `bbb_greenlight_image`: Docker image to run for Greenlight (Default: `bigbluebutton/greenlight:v2`)
Expand Down Expand Up @@ -68,5 +74,23 @@ In order to deploy a basic setup of the _Greenlight_ frontend alongside _BigBlue
bbb_install_check: True
bbb_configure_ssl: True
bbb_ssl_email: [email protected]
bbb_sip_default_dialin: "+613-555-1234"
bbb_sip_welcome_footer: "<br/><br/>dial %%DIALNUM%%, then enter %%CONFNUM%% as conference PIN."
bbb_sip_providers:
sipprovider1:
username: "123456789"
password: "topsecret"
extension: "6135551234"
proxy: sip.example.com
register: "true"
context: "public"
sipprovider2:
username: "11114444"
password: "changeme"
extension: "8005554321"
proxy: sip.example.org
register: "true"
context: "public"
```
12 changes: 12 additions & 0 deletions tasks/firewall.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,18 @@
tags:
- bbb_configure_ufw

- name: Allow connections from SIP gateways in firewall
ufw:
rule: allow
from: "{{ lookup('dig', item[0]) }}"
port: "5060,5080"
proto: "{{ item[1] }}"
comment: "SIP gateway"
loop: "{{ bbb_sip_providers.values() | map(attribute='proxy') | product(['tcp', 'udp']) | list }}"
when: bbb_sip_providers is defined
tags:
- bbb_configure_ufw

- name: Enable firewall rules
ufw:
state: enabled
Expand Down
4 changes: 4 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,10 @@
when: bbb_configure_ssl == True
- include_tasks: ssl.yml
when: bbb_configure_ssl == True
- include_tasks: sip.yml
when: bbb_sip_providers is defined
tags:
- bbb-sip

- name: Restart BigBlueButton
command: bbb-conf --restart
Expand Down
53 changes: 53 additions & 0 deletions tasks/sip.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
- name: Create external SIP provider configuration for FreeSWITCH
template:
src: templates/sip_provider.xml.j2
dest: /opt/freeswitch/conf/sip_profiles/external/{{ item.key }}.xml
owner: freeswitch
group: daemon
backup: yes
loop: "{{ bbb_sip_providers | dict2items }}"
register: sip_profile_config
no_log: true
tags:
- bbb-add-sip-provider-config

- name: Create dialplan for SIP provider
template:
src: templates/sip_dialplan.xml.j2
dest: /opt/freeswitch/conf/dialplan/{{ item.value.context | default("public") }}/{{ item.key }}.xml
owner: freeswitch
group: daemon
backup: yes
loop: "{{ bbb_sip_providers | dict2items }}"
register: sip_dialin_config
no_log: true
tags:
- bbb-add-sip-provider-config

- name: Restart FreeSWITCH to activate SIP changes
systemd:
name: freeswitch
state: restarted
when:
sip_profile_config.changed or sip_dialin_config.changed
tags:
- bbb-add-sip-provider-config

- name: Configure default dial-in number
replace:
path: "/usr/share/bbb-web/WEB-INF/classes/bigbluebutton.properties"
regexp: '^defaultDialAccessNumber=.*'
replace: 'defaultDialAccessNumber={{ bbb_sip_default_dialin | default("+" + (bbb_sip_providers.values() | first).extension) }}'
backup: yes
tags:
- bbb-add-sip-dialin-config

- name: Configure dial-in numbers in welcome footer
replace:
path: "/usr/share/bbb-web/WEB-INF/classes/bigbluebutton.properties"
regexp: '^defaultWelcomeMessageFooter=.*'
replace: 'defaultWelcomeMessageFooter={{ bbb_sip_welcome_footer | default("<br><br>To join this meeting by phone, dial:<br> %%DIALNUM%%<br>Then enter %%CONFNUM%% as the conference PIN number.") }}'
backup: yes
tags:
- bbb-add-sip-dialin-config
15 changes: 15 additions & 0 deletions templates/sip_dialplan.xml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<extension name="from_{{ item.key }}">
<condition field="destination_number" expression="^{{ item.value.destination_number | default(item.value.extension) }}">
<action application="answer"/>
<action application="sleep" data="1000"/>
<action application="play_and_get_digits" data="5 5 3 7000 # conference/conf-pin.wav ivr/ivr-that_was_an_invalid_entry.wav pin \d+"/>
<action application="transfer" data="SEND_TO_CONFERENCE XML public"/>
</condition>
</extension>
<extension name="check_if_conference_active">
<condition field="${conference ${pin} list}" expression="/sofia/g" />
<condition field="destination_number" expression="^SEND_TO_CONFERENCE$">
<action application="set" data="bbb_authorized=true"/>
<action application="transfer" data="${pin} XML default"/>
</condition>
</extension>
7 changes: 7 additions & 0 deletions templates/sip_provider.xml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<include>
<gateway name="{{ item.value.gateway | default(item.key) }}">
{% for param in item.value | dict2items %}
<param name="{{ param.key }}" value="{{ param.value }}"/>
{% endfor %}
</gateway>
</include>

0 comments on commit 1d84d33

Please sign in to comment.