mirror of
https://github.com/iiab/iiab.git
synced 2025-03-09 15:40:17 +00:00
Merge pull request #2950 from holta/ordering
@jvonau's ODBC compiling for FreePBX CDR + linting, explanations & small mods
This commit is contained in:
commit
6280dd8b24
8 changed files with 101 additions and 35 deletions
|
@ -20,11 +20,11 @@
|
||||||
|
|
||||||
asterisk_url: http://downloads.asterisk.org/pub/telephony/asterisk
|
asterisk_url: http://downloads.asterisk.org/pub/telephony/asterisk
|
||||||
asterisk_src_file: asterisk-18-current.tar.gz
|
asterisk_src_file: asterisk-18-current.tar.gz
|
||||||
asterisk_src_dir: /opt/iiab/asterisk
|
asterisk_src_dir: "{{ iiab_base }}/asterisk" # /opt/iiab
|
||||||
|
|
||||||
freepbx_url: http://mirror.freepbx.org/modules/packages/freepbx/7.4
|
freepbx_url: http://mirror.freepbx.org/modules/packages/freepbx/7.4
|
||||||
freepbx_src_file: freepbx-16.0-latest.tgz # Beta as of 2021-06-21 but looking great! Does NOT support PHP < 7.4 (you've been warned!) Please review https://github.com/iiab/iiab/blob/master/roles/pbx/README.rst
|
freepbx_src_file: freepbx-16.0-latest.tgz # Beta as of 2021-06-21 but looking great! Does NOT support PHP < 7.4 (you've been warned!) Please review https://github.com/iiab/iiab/blob/master/roles/pbx/README.rst
|
||||||
freepbx_src_dir: /opt/iiab/freepbx
|
freepbx_src_dir: "{{ iiab_base }}/freepbx"
|
||||||
freepbx_install_dir: /var/www/html/freepbx
|
freepbx_install_dir: /var/www/html/freepbx
|
||||||
|
|
||||||
asterisk_db_host: localhost
|
asterisk_db_host: localhost
|
||||||
|
@ -35,4 +35,4 @@ asterisk_db_cdrdbname: asteriskcdrdb
|
||||||
|
|
||||||
chan_dongle_url: https://github.com/wdoekes/asterisk-chan-dongle/archive
|
chan_dongle_url: https://github.com/wdoekes/asterisk-chan-dongle/archive
|
||||||
chan_dongle_src_file: master.zip
|
chan_dongle_src_file: master.zip
|
||||||
chan_dongle_src_dir: /opt/iiab/chan_dongle
|
chan_dongle_src_dir: "{{ iiab_base }}/chan_dongle"
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
# 2021-08-16 README.adoc, with screenshots:
|
||||||
|
# https://github.com/iiab/iiab/tree/master/roles/pbx#pbx-readme
|
||||||
|
|
||||||
|
|
||||||
# 2021-08-05: Asterisk's own install_prereq (below) handles essentially all of these
|
# 2021-08-05: Asterisk's own install_prereq (below) handles essentially all of these
|
||||||
# - name: Asterisk - Install dependencies
|
# - name: Asterisk - Install dependencies
|
||||||
# include_tasks: asterisk_dependencies.yml
|
# include_tasks: asterisk_dependencies.yml
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
# "Official" recipe: https://wiki.freepbx.org/display/FOP/Installing+FreePBX+16+on+Debian+10.9
|
# 2021-08-16 README.adoc, with screenshots:
|
||||||
# Comprehensive & recent recipe for RPi: http://mghadam.blogspot.com/2021/03/install-asterisk-18-freepbx-15-on.html
|
# https://github.com/iiab/iiab/tree/master/roles/pbx#pbx-readme
|
||||||
# Quirky but still useful for comparison: https://computingforgeeks.com/how-to-install-asterisk-16-with-freepbx-15-on-ubuntu-debian/
|
|
||||||
# 2012-2017: http://www.raspberry-asterisk.org
|
|
||||||
|
|
||||||
|
|
||||||
# 2021-08-04: Non-native systemd service 'asterisk.service' (redirects via
|
# 2021-08-04: Non-native systemd service 'asterisk.service' (redirects via
|
||||||
|
@ -21,7 +19,7 @@
|
||||||
enabled: no
|
enabled: no
|
||||||
|
|
||||||
|
|
||||||
- name: FreePBX - Install wget, git, unixodbc, sudo, net-tools, cron, sox + ~12 PHP dependencies (run 'php -m' or 'php -i' to verify PHP modules)
|
- name: FreePBX - Install 24 packages = 7 (wget, git, unixodbc, sudo, net-tools, cron, sox) + 12 PHP dependencies (run 'php -m' or 'php -i' to verify PHP modules) + 5 for CDR ODBC (cmake, make, gcc, libssl-dev, unixodbc-dev)
|
||||||
package:
|
package:
|
||||||
name:
|
name:
|
||||||
- wget
|
- wget
|
||||||
|
@ -48,6 +46,11 @@
|
||||||
- php{{ php_version }}-snmp
|
- php{{ php_version }}-snmp
|
||||||
- php{{ php_version }}-xml # Likewise installed in mediawiki/tasks/install.yml, moodle/tasks/install.yml, nextcloud/tasks/install.yml, wordpress/tasks/install.yml -- AND REGARDLESS dragged in later by Admin Console's use of php-pear for roles/cmdsrv/tasks/main.yml -- run 'php -m | grep -i xml' which in the end shows {libxml, SimpleXML, xml, xmlreader, xmlwriter}
|
- php{{ php_version }}-xml # Likewise installed in mediawiki/tasks/install.yml, moodle/tasks/install.yml, nextcloud/tasks/install.yml, wordpress/tasks/install.yml -- AND REGARDLESS dragged in later by Admin Console's use of php-pear for roles/cmdsrv/tasks/main.yml -- run 'php -m | grep -i xml' which in the end shows {libxml, SimpleXML, xml, xmlreader, xmlwriter}
|
||||||
- php{{ php_version }}-zip # Likewise installed in moodle/tasks/install.yml, nextcloud/tasks/install.yml, wordpress/tasks/install.yml
|
- php{{ php_version }}-zip # Likewise installed in moodle/tasks/install.yml, nextcloud/tasks/install.yml, wordpress/tasks/install.yml
|
||||||
|
- cmake
|
||||||
|
- make
|
||||||
|
- gcc
|
||||||
|
- libssl-dev
|
||||||
|
- unixodbc-dev
|
||||||
state: latest
|
state: latest
|
||||||
|
|
||||||
# For PHP >= 8.0: phpX.Y-json is baked into PHP itself.
|
# For PHP >= 8.0: phpX.Y-json is baked into PHP itself.
|
||||||
|
@ -130,20 +133,24 @@
|
||||||
name: "{{ asterisk_db_dbname }}" # asterisk
|
name: "{{ asterisk_db_dbname }}" # asterisk
|
||||||
encoding: utf8
|
encoding: utf8
|
||||||
collation: utf8_general_ci
|
collation: utf8_general_ci
|
||||||
# login_host: "{{ asterisk_db_host }}"
|
login_host: "{{ asterisk_db_host }}"
|
||||||
# login_user: root
|
login_user: "{{ asterisk_db_user }}"
|
||||||
# login_password: "{{ mysql_root_password }}"
|
login_password: "{{ asterisk_db_password }}"
|
||||||
state: present
|
state: present
|
||||||
|
|
||||||
- name: FreePBX - Add cdr MySQL db ({{ asterisk_db_cdrdbname }})
|
- name: FreePBX - Add CDR MySQL db ({{ asterisk_db_cdrdbname }})
|
||||||
mysql_db:
|
mysql_db:
|
||||||
name: "{{ asterisk_db_cdrdbname }}" # asteriskcdrdb
|
name: "{{ asterisk_db_cdrdbname }}" # asteriskcdrdb
|
||||||
encoding: utf8
|
encoding: utf8
|
||||||
collation: utf8_general_ci
|
collation: utf8_general_ci
|
||||||
login_host: "{{ asterisk_db_host }}"
|
login_host: "{{ asterisk_db_host }}"
|
||||||
|
login_user: "{{ asterisk_db_user }}"
|
||||||
|
login_password: "{{ asterisk_db_password }}"
|
||||||
state: present
|
state: present
|
||||||
|
|
||||||
|
|
||||||
|
# 2021-08-16: DOES NGINX NEED THE NEXT 2 STANZAS? (If not, should 'when: not pbx_try_nginx' be added?)
|
||||||
|
|
||||||
- name: FreePBX - Create new php sessions dir /var/lib/php/asterisk_sessions/ - SEE 'php_value session.save_path /var/lib/php/asterisk_sessions/' IN pbx/templates/freepbx.conf.j2
|
- name: FreePBX - Create new php sessions dir /var/lib/php/asterisk_sessions/ - SEE 'php_value session.save_path /var/lib/php/asterisk_sessions/' IN pbx/templates/freepbx.conf.j2
|
||||||
file:
|
file:
|
||||||
path: /var/lib/php/asterisk_sessions/
|
path: /var/lib/php/asterisk_sessions/
|
||||||
|
@ -168,6 +175,34 @@
|
||||||
create: yes
|
create: yes
|
||||||
|
|
||||||
|
|
||||||
|
- name: FreePBX - git clone https://github.com/mariadb-corporation/mariadb-connector-odbc to /usr/src/mariadb-connector-odbc
|
||||||
|
git:
|
||||||
|
repo: https://github.com/mariadb-corporation/mariadb-connector-odbc
|
||||||
|
dest: /usr/src/mariadb-connector-odbc
|
||||||
|
version: master
|
||||||
|
force: yes
|
||||||
|
depth: 1
|
||||||
|
|
||||||
|
- name: FreePBX - Run scripts/mk-odbc-connector to build mariadb-connector-odbc, creating /usr/local/lib/mariadb/libmaodbc.so
|
||||||
|
command: "{{ iiab_dir }}/scripts/mk-odbc-connector"
|
||||||
|
args:
|
||||||
|
creates: /usr/local/lib/mariadb/libmaodbc.so
|
||||||
|
|
||||||
|
# http://mghadam.blogspot.com/2021/03/install-asterisk-18-freepbx-15-on.html
|
||||||
|
- name: FreePBX - Install /etc/odbc.ini, /etc/odbcinst.ini from template (root:root, 0644 by default)
|
||||||
|
template:
|
||||||
|
src: "{{ item.src }}"
|
||||||
|
dest: "{{ item.dest }}"
|
||||||
|
with_items:
|
||||||
|
- { src: odbc.ini.j2, dest: /etc/odbc.ini }
|
||||||
|
- { src: odbcinst.ini, dest: /etc/odbcinst.ini }
|
||||||
|
|
||||||
|
- name: FreePBX - Install /etc/asterisk/cdr_mysql.conf from template (root:root, 0644 by default)
|
||||||
|
template:
|
||||||
|
src: cdr_mysql.conf.j2
|
||||||
|
dest: /etc/asterisk/cdr_mysql.conf
|
||||||
|
|
||||||
|
|
||||||
- name: FreePBX - 2-step install - won't run if {{ freepbx_install_dir }} already exists - CAN TAKE 3-12 MIN OR LONGER!
|
- name: FreePBX - 2-step install - won't run if {{ freepbx_install_dir }} already exists - CAN TAKE 3-12 MIN OR LONGER!
|
||||||
command: "{{ item }}"
|
command: "{{ item }}"
|
||||||
args:
|
args:
|
||||||
|
@ -175,14 +210,14 @@
|
||||||
creates: "{{ freepbx_install_dir }}" # /var/www/html/freepbx
|
creates: "{{ freepbx_install_dir }}" # /var/www/html/freepbx
|
||||||
with_items:
|
with_items:
|
||||||
- ./start_asterisk start
|
- ./start_asterisk start
|
||||||
- ./install -n --webroot {{ freepbx_install_dir }} --dbuser {{ asterisk_db_user }} --dbpass {{ asterisk_db_password }} --dbname {{ asterisk_db_dbname }} --cdrdbname {{ asterisk_db_cdrdbname }}
|
- ./install -n --webroot {{ freepbx_install_dir }} --dbuser {{ asterisk_db_user }} --dbpass {{ asterisk_db_password }}
|
||||||
|
# - ./install -n --webroot {{ freepbx_install_dir }} --dbuser {{ asterisk_db_user }} --dbpass {{ asterisk_db_password }} --dbname {{ asterisk_db_dbname }} --cdrdbname {{ asterisk_db_cdrdbname }}
|
||||||
|
|
||||||
- name: "Run 'fwconsole stop' and 'killall -9 safe_asterisk' to stop both Asterisk processes -- this avoids \"Unable to run Pre-Asterisk hooks, because Asterisk is already running\" in 'journalctl -u freepbx' logs"
|
- name: FreePBX - Run 'fwconsole stop', 'killall -9 safe_asterisk' to stop both main Asterisk processes - this avoids "Unable to run Pre-Asterisk hooks, because Asterisk is already running" in 'journalctl -u freepbx' logs
|
||||||
command: "{{ item }}"
|
command: "{{ item }}"
|
||||||
with_items:
|
with_items:
|
||||||
- fwconsole stop
|
- fwconsole stop
|
||||||
- killall -9 safe_asterisk # 2021-08-08: Stronger medicine needed for 64-bit Ubuntu Server 21.04 on RPi 4. Originally from @jvonau's PR #2912.
|
- killall -9 safe_asterisk # 2021-08-08: Stronger medicine needed for 64-bit Ubuntu Server 21.04 on RPi 4. Originally from @jvonau's PR #2912.
|
||||||
- killall -9 "PM2 v4.5.0: God" # 2021-08-09: Missed by fwconsole (does this matter?)
|
|
||||||
# - killall -9 asterisk # 2021-08-05: Also from @jvonau's PR #2912, to brute force this. In the end, above 'fwconsole stop' works more gracefully.
|
# - killall -9 asterisk # 2021-08-05: Also from @jvonau's PR #2912, to brute force this. In the end, above 'fwconsole stop' works more gracefully.
|
||||||
# - ./start_asterisk stop # Buggy!
|
# - ./start_asterisk stop # Buggy!
|
||||||
# - /usr/sbin/asterisk -rx "core stop gracefully"
|
# - /usr/sbin/asterisk -rx "core stop gracefully"
|
||||||
|
@ -193,7 +228,11 @@
|
||||||
# - fwconsole ma delete firewall
|
# - fwconsole ma delete firewall
|
||||||
# - fwconsole reload
|
# - fwconsole reload
|
||||||
# - fwconsole restart
|
# - fwconsole restart
|
||||||
ignore_errors: yes # 2021-08-08: For things like 'killall -9 safe_asterisk' that fail when process doesn't exist
|
ignore_errors: yes # 2021-08-08: As 'killall -9 safe_asterisk' will fail when process doesn't exist (on many OS's!)
|
||||||
|
|
||||||
|
- name: "FreePBX - Run 'killall -9 \"PM2 v4.5.0: God\"' for good measure"
|
||||||
|
command: 'killall -9 "PM2 v4.5.0: God"' # 2021-08-09: Missed by above 'fwconsole stop' (does this matter?)
|
||||||
|
ignore_errors: yes # 2021-08-16: As 'killall -9 "PM2 v4.5.0: God"' will fail if process doesn't exist (e.g. if version number changes, etc)
|
||||||
|
|
||||||
# 2021-08-06: This stanza works, but above is more graceful. (FYI PRs #2908,
|
# 2021-08-06: This stanza works, but above is more graceful. (FYI PRs #2908,
|
||||||
# #2912, #2913 didn't quite work -- whereas this PR #2915 at least worked!)
|
# #2912, #2913 didn't quite work -- whereas this PR #2915 at least worked!)
|
||||||
|
@ -205,25 +244,21 @@
|
||||||
# state: restarted
|
# state: restarted
|
||||||
|
|
||||||
|
|
||||||
- name: FreePBX - Install /etc/odbc.ini from template (root:root, 0644 by default) for CDR 'asteriskcdrdb' - in future consider compiling ODBC driver for aarch64 per http://mghadam.blogspot.com/2021/03/install-asterisk-18-freepbx-15-on.html ?
|
|
||||||
template:
|
|
||||||
src: odbc.ini
|
|
||||||
dest: /etc/
|
|
||||||
|
|
||||||
- name: FreePBX - Install /etc/systemd/system/freepbx.service from template (root:root, 0644 by default)
|
- name: FreePBX - Install /etc/systemd/system/freepbx.service from template (root:root, 0644 by default)
|
||||||
template:
|
template:
|
||||||
src: freepbx.service
|
src: freepbx.service
|
||||||
dest: /etc/systemd/system/
|
dest: /etc/systemd/system/
|
||||||
|
|
||||||
|
# Default module list https://github.com/iiab/iiab/pull/2916#issuecomment-894601522
|
||||||
- name: FreePBX - Run 'fwconsole ma upgradeall' on installed FreePBX modules, e.g. 16 default modules (of about 70 total) - CAN TAKE 2 MIN OR LONGER!
|
- name: FreePBX - Run 'fwconsole ma upgradeall' on installed FreePBX modules, e.g. 16 default modules (of about 70 total) - CAN TAKE 1 MIN OR LONGER!
|
||||||
command: fwconsole ma upgradeall
|
command: fwconsole ma upgradeall
|
||||||
|
|
||||||
- name: FreePBX - Run 'fwconsole set CHECKREFERER 0' (0 means false) - if pbx_try_nginx - so 'Submit' button definitively works at http://box/freepbx >> Settings >> Advanced Settings -- FYI you can run 'fwconsole set -l' or 'fwconsole set CHECKREFERER' to view FreePBX settings -- FYI /etc/freepbx.conf can completely override FreePBX's stored settings if nec
|
- name: FreePBX - Run 'fwconsole set CHECKREFERER 0' (0 means false) - if pbx_try_nginx - so 'Submit' button definitively works at http://box/freepbx >> Settings >> Advanced Settings -- FYI you can run 'fwconsole set -l' or 'fwconsole set CHECKREFERER' to view FreePBX settings -- FYI /etc/freepbx.conf can completely override FreePBX's stored settings if nec
|
||||||
command: fwconsole set CHECKREFERER 0 # Or/later run 'fwconsole set CHECKREFERER 1' (1 means true) to restore FreePBX's default strict checking.
|
command: fwconsole set CHECKREFERER 0 # Or/later run 'fwconsole set CHECKREFERER 1' (1 means true) to restore FreePBX's default strict checking.
|
||||||
when: pbx_try_nginx
|
when: pbx_try_nginx
|
||||||
|
|
||||||
# - name: Add "$amp_conf['CHECKREFERER'] = false;" to /etc/freepbx.conf #2931 - if pbx_try_nginx"
|
|
||||||
|
# - name: FreePBX - Add "$amp_conf['CHECKREFERER'] = false;" to /etc/freepbx.conf #2931 - if pbx_try_nginx"
|
||||||
# lineinfile:
|
# lineinfile:
|
||||||
# path: /etc/freepbx.conf
|
# path: /etc/freepbx.conf
|
||||||
# insertbefore: '^\?>$' # Match exact line '?>' -- BOTTOM OF FILE NEC!
|
# insertbefore: '^\?>$' # Match exact line '?>' -- BOTTOM OF FILE NEC!
|
||||||
|
@ -254,8 +289,8 @@
|
||||||
# For 'pbx_try_nginx: True' -- FreePBX's initial page (Admin user registration)
|
# For 'pbx_try_nginx: True' -- FreePBX's initial page (Admin user registration)
|
||||||
# tries to set up a cron job but fails:
|
# tries to set up a cron job but fails:
|
||||||
# "Exception: Trying to edit user asterisk, when I'm running as www-data"
|
# "Exception: Trying to edit user asterisk, when I'm running as www-data"
|
||||||
# 2021-08-10: Hacking /etc/freepbx.conf WAS NOT TESTED PROPERLY -- AS VARS MUST
|
# 2021-08-10: Hacking /etc/freepbx.conf WAS NOT TESTED PROPERLY -- some vars MAY
|
||||||
# BE NEAR BOTTOM OF FILE: github.com/iiab/iiab/pull/2916#issuecomment-894585322
|
# need to be NEAR BOTTOM: github.com/iiab/iiab/pull/2916#issuecomment-894585322
|
||||||
# - name: "2021-08-06: Try \"$amp_conf['AMPASTERISKWEBUSER'] = 'www-data';\" in /etc/freepbx.conf for #2916 registration cron fix ?'"
|
# - name: "2021-08-06: Try \"$amp_conf['AMPASTERISKWEBUSER'] = 'www-data';\" in /etc/freepbx.conf for #2916 registration cron fix ?'"
|
||||||
# lineinfile:
|
# lineinfile:
|
||||||
# path: /etc/freepbx.conf
|
# path: /etc/freepbx.conf
|
||||||
|
|
6
roles/pbx/templates/cdr_mysql.conf.j2
Normal file
6
roles/pbx/templates/cdr_mysql.conf.j2
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
[global]
|
||||||
|
hostname = localhost
|
||||||
|
dbname = {{ asterisk_db_cdrdbname }}
|
||||||
|
user = {{ asterisk_db_password }}
|
||||||
|
password = {{ asterisk_db_password }}
|
||||||
|
userfield = 1
|
|
@ -1,8 +0,0 @@
|
||||||
[MySQL-asteriskcdrdb]
|
|
||||||
Description=MySQL connection to 'asteriskcdrdb' database
|
|
||||||
driver=MySQL
|
|
||||||
server=localhost
|
|
||||||
database=asteriskcdrdb
|
|
||||||
Port=3306
|
|
||||||
Socket=/var/run/mysqld/mysqld.sock
|
|
||||||
option=3
|
|
8
roles/pbx/templates/odbc.ini.j2
Normal file
8
roles/pbx/templates/odbc.ini.j2
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
[MySQL-asteriskcdrdb]
|
||||||
|
Description = MySQL connection to 'asteriskcdrdb' database
|
||||||
|
driver = MySQL
|
||||||
|
server = localhost
|
||||||
|
database = {{ asterisk_db_cdrdbname }}
|
||||||
|
Port = 3306
|
||||||
|
Socket = /var/run/mysqld/mysqld.sock
|
||||||
|
option = 3
|
4
roles/pbx/templates/odbcinst.ini
Normal file
4
roles/pbx/templates/odbcinst.ini
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
[MySQL]
|
||||||
|
Description = ODBC for MySQL (MariaDB)
|
||||||
|
Driver = /usr/local/lib/mariadb/libmaodbc.so
|
||||||
|
FileUsage = 1
|
17
scripts/mk-odbc-connector
Executable file
17
scripts/mk-odbc-connector
Executable file
|
@ -0,0 +1,17 @@
|
||||||
|
#!/bin/bash
|
||||||
|
ARCH=$(uname -m)
|
||||||
|
mkdir /usr/src/mariadb-connector-odbc/build
|
||||||
|
cd /usr/src/mariadb-connector-odbc/build
|
||||||
|
if [ -f /etc/rpi-issue ]; then
|
||||||
|
DM_DIR=/usr/lib/arm-linux-gnueabihf cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCONC_WITH_UNIT_TESTS=Off -DCMAKE_C_FLAGS_RELWITHDEBINFO="-I/usr/include/mariadb -L/usr/lib"
|
||||||
|
else
|
||||||
|
DM_DIR=/usr/lib/$ARCH-linux-gnu cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCONC_WITH_UNIT_TESTS=Off -DCMAKE_C_FLAGS_RELWITHDEBINFO="-I/usr/include/mariadb" -DWITH_SSL=OPENSSL -DCMAKE_INSTALL_PREFIX=/usr/local
|
||||||
|
fi
|
||||||
|
make
|
||||||
|
make install
|
||||||
|
|
||||||
|
cat << EOF > /etc/ld.so.conf.d/99-iiab.conf
|
||||||
|
/usr/local/lib/mariadb/
|
||||||
|
EOF
|
||||||
|
|
||||||
|
ldconfig
|
Loading…
Add table
Add a link
Reference in a new issue