Updated Ubuntu installer to support up to 24.04 LTS (#436)

- Added optional applications.sh scripts.
- Added call_recordings.php script for wav - mp3 conversion.
- Updated ubuntu\resources\fusionpbx\config.conf to add entry for setting the event socket password and a comment at the top to direct admins to where they can find more configuration options for this file.
- Updated config.sh to add switch_token entry and some version changes to make the installer Ubuntu 24.04 compatible.  
- Added on the Optional applications.
- Updated environment.sh to include setting the PATH just in case.
- Updated finish.sh to include output of database username and password to save a few steps when setting up.
- Added freeswitch-acl.conf from the Debian side as more security is important.
- Updated jail.local to include freeswitch-acl as well as turning several items on by default (security should always be the default).
- Updated install.sh to include some missing dependencies (nginx and build-essential)
- Updated php.sh, and nginx.sh to include 8.1, 8.2 and 8.3
- Swapped plocate for mlocate in dependency install in ubuntu\resources\switch\source-release.sh
- uncommented ./bootstrap.sh -j line for git compatibility
- removed duplicate $switch_version from sed commands, added sed command to disable mod_av.
- Added environment.sh include to switch.sh
- Added monit files for freeswitch perms etc.
This commit is contained in:
Chad Sheridan 2024-08-30 20:06:50 -04:00 committed by GitHub
parent d0322070ff
commit 4fc59b5e5e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
15 changed files with 335 additions and 32 deletions

View File

@ -23,6 +23,8 @@ apt-get install -y systemd-sysv
apt-get install -y ca-certificates
apt-get install -y dialog
apt-get install -y nano
apt-get install -y nginx
apt-get install -y build-essential
#SNMP
apt-get install -y snmpd
@ -47,6 +49,9 @@ resources/nginx.sh
#Postgres
resources/postgresql.sh
#Optional Applications
resources/applications.sh
#FreeSWITCH
resources/switch.sh

View File

@ -0,0 +1,29 @@
#!/bin/sh
#move to script directory so all relative paths work
cd "$(dirname "$0")"
#includes
. ./config.sh
#optional applications
cd /var/www/fusionpbx/app
if [ .$application_transcribe = .'true' ]; then
git clone https://github.com/fusionpbx/fusionpbx-app-transcribe.git transcribe
fi
if [ .$application_speech = .'true' ]; then
git clone https://github.com/fusionpbx/fusionpbx-app-speech.git speech
fi
if [ .$application_device_logs = .'true' ]; then
git clone https://github.com/fusionpbx/fusionpbx-app-device_logs.git device_logs
fi
if [ .$application_dialplan_tools = .'true' ]; then
git clone https://github.com/fusionpbx/fusionpbx-app-dialplan_tools.git dialplan_tools
fi
if [ .$application_edit = .'true' ]; then
git clone https://github.com/fusionpbx/fusionpbx-app-dialplan_tools.git edit
fi
if [ .$application_sip_trunks = .'true' ]; then
git clone https://github.com/fusionpbx/fusionpbx-app-sip_trunks.git sip_trunks
fi
chown -R www-data:www-data /var/www/fusionpbx

View File

@ -1,30 +1,39 @@
# FusionPBX Settings
domain_name=ip_address # hostname, ip_address or a custom value
system_username=admin # default username admin
system_password=random # random or a custom value
system_branch=5.2 # master, 5.2
domain_name=ip_address # hostname, ip_address or a custom value
system_username=admin # default username admin
system_password=random # random or a custom value
system_branch=5.2 # master, 5.2
# FreeSWITCH Settings
switch_branch=stable # master, stable
switch_source=true # true or false
switch_package=false # true or false
switch_version=1.10.11 # only for source
switch_tls=true # true or false
switch_branch=stable # master, stable
switch_source=true # true (source compile) or false (binary package)
switch_package=false # true (binary package) or false (source compile)
switch_version=1.10.11 # which source code to download, only for source
switch_tls=true # true or false
switch_token= # Get the auth token from https://signalwire.com
# Signup or Login -> Profile -> Personal Auth Token
# Sofia-Sip Settings
sofia_version=1.13.17 # release-version for sofia-sip to use
sofia_version=1.13.17 # release-version for sofia-sip to use
# Database Settings
database_name=fusionpbx # Database name (safe characters A-Z, a-z, 0-9)
database_username=fusionpbx # Database username (safe characters A-Z, a-z, 0-9)
database_password=random # random or a custom value (safe characters A-Z, a-z, 0-9)
database_repo=system # PostgreSQL official, system, 2ndquadrant
database_version=13 # requires repo official
database_host=127.0.0.1 # hostname or IP address
database_port=5432 # port number
database_backup=false # true or false
database_name=fusionpbx # Database name (safe characters A-Z, a-z, 0-9)
database_username=fusionpbx # Database username (safe characters A-Z, a-z, 0-9)
database_password=random # random or a custom value (safe characters A-Z, a-z, 0-9)
database_repo=official # PostgreSQL official, system
database_version=16 # requires repo official
database_host=127.0.0.1 # hostname or IP address
database_port=5432 # port number
database_backup=false # true or false
# General Settings
php_version=7.4 # PHP version 5.6 or 7.0, 7.1, 7.2
letsencrypt_folder=true # true or false
php_version=8.1 # PHP version 5.6 or 7.0, 7.1, 7.2
letsencrypt_folder=true # true or false
# Optional Applications
application_transcribe=true # Speech to Text
application_speech=true # Text to Speech
application_device_logs=true # Log device provision requests
application_dialplan_tools=false # Add additional dialplan applications
application_edit=false # Editor for XML, Provision, Scripts, and PHP
application_sip_trunks=false # Registration based SIP trunks

View File

@ -13,6 +13,9 @@ cpu_name=$(uname -m)
cpu_architecture='unknown'
cpu_mode='unknown'
#set the environment path
export PATH=$PATH:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
#check what the CPU and OS are
if [ .$cpu_name = .'armv7l' ]; then
# RaspberryPi 3 is actually armv8l but current Raspbian reports the cpu as armv7l and no Raspbian 64Bit has been released at this time

View File

@ -0,0 +1,20 @@
# Fail2Ban configuration file
#
[Definition]
# Option: failregex
# Notes.: regex to match the password failures messages in the logfile. The
# host must be matched by a group named "host". The tag "<HOST>" can
# be used for standard IP/hostname matching and is only an alias for
# (?:::f{4,6}:)?(?P<host>[\w\-.^_]+)
# Values: TEXT
#
#2021-02-03 16:27:57.292697 [WARNING] sofia_reg.c:2353 IP 62.210.78.91 Rejected by register acl "domains"
failregex = \[WARNING\] sofia_reg.c:\d+ IP <HOST> Rejected by register acl
# Option: ignoreregex
# Notes.: regex to ignore. If this regex matches, the line is ignored.
# Values: TEXT
#
ignoreregex =

View File

@ -22,6 +22,18 @@ findtime = 600
bantime = 3600
# sendmail-whois[name=FreeSwitch, dest=root, sender=fail2ban@example.org] #no smtp server installed
[freeswitch-acl]
enabled = false
port = 5060:5091
protocol = all
filter = freeswitch-acl
logpath = /var/log/freeswitch/freeswitch.log
#logpath = /usr/local/freeswitch/log/freeswitch.log
action = iptables-allports[name=freeswitch-acl, protocol=all]
maxretry = 900
findtime = 60
bantime = 86400
[freeswitch-ip]
enabled = false
port = 5060:5091
@ -30,7 +42,7 @@ filter = freeswitch-ip
logpath = /var/log/freeswitch/freeswitch.log
#logpath = /usr/local/freeswitch/log/freeswitch.log
action = iptables-allports[name=freeswitch-ip, protocol=all]
maxretry = 1
maxretry = 3
findtime = 30
bantime = 86400
@ -42,7 +54,7 @@ filter = auth-challenge-ip
logpath = /var/log/freeswitch/freeswitch.log
#logpath = /usr/local/freeswitch/log/freeswitch.log
action = iptables-allports[name=auth-challenge-ip, protocol=all]
maxretry = 1
maxretry = 3
findtime = 30
bantime = 86400

View File

@ -122,6 +122,8 @@ echo " Use a web browser to login."
echo " domain name: https://$domain_name"
echo " username: $user_name"
echo " password: $user_password"
echo " database username: $database_username"
echo " database password: $database_password"
echo ""
echo " The domain name in the browser is used by default as part of the authentication."
echo " If you need to login to a different domain then use username@domain."

View File

@ -18,7 +18,7 @@ document.root = /var/www/fusionpbx
project.path =
temp.dir = /tmp
php.dir = /usr/bin
php.bin = php
php.bin = php
#cache settings
cache.method = file
@ -34,6 +34,15 @@ switch.storage.dir = /var/lib/freeswitch/storage
switch.voicemail.dir = /var/lib/freeswitch/storage/voicemail
switch.scripts.dir = /usr/share/freeswitch/scripts
#optional settings
# If you change switch.event_socket.password here, you MUST change it in /etc/freeswitch/autoload_configs/event_socket.conf.xml
# Additionally you must update/create an /etc/fs_cli.conf file with at minimum the following lines (uncommented)
# [default]
# host => 127.0.0.1
# port => 8021
# password => <whatever you set the password below to>
#switch.event_socket.password = ClueCon
#switch xml handler
xml_handler.fs_path = false
xml_handler.reg_as_number_alias = false

View File

@ -0,0 +1,158 @@
<?php
/*
Call Recordings Maintenance
- Convert WAV to MP3
- Reduce the file size
- Move recordings
- Move the recording from the source to a destination directory.
At the top of the file need to define or set the destination_directory...
In my case I put the file in /usr/src and then run manually like this.
/usr/bin/php /usr/src/fusionpbx-install.sh/debian/resources/maintenance/call_recordings.php
Debian
crontab -e
0 * * * * /usr/bin/php /usr/src/fusionpbx-install.sh/debian/resources/maintenance/call_recordings.php > /dev/null 2>&1
*/
//add the document root to the included path
if (defined('STDIN')) {
$config_glob = glob("{/usr/local/etc,/etc}/fusionpbx/config.conf", GLOB_BRACE);
$conf = parse_ini_file($config_glob[0]);
set_include_path($conf['document.root']);
}
else {
exit;
}
//set pre-defined variables
$debug = true;
$action = 'convert'; //convert, move or both
$audio_format = 'wav';
$preferred_command = 'lame'; //mpg123, lame
//includes files
require_once "resources/require.php";
//create the database connection
$database = new database;
//use settings object instead of session
$settings = new settings(['database' => $database]);
//set the source and destination paths
$source_path = $settings->get('switch','recordings', '');
//set the destination_path
if ($action == 'move' || $action == 'both') {
$destination_path = $settings->get('call_recordings','destination_path', null);
}
//make sure the directory exists
if ($action == 'move' || $action == 'both') {
system('mkdir -p '.$destination_path);
}
//get the xml cdr call recordings.
$sql = "select xml_cdr_uuid, domain_uuid, domain_name, ";
$sql .= "record_path, record_name, direction, start_stamp, ";
$sql .= "caller_id_name, caller_id_number from v_xml_cdr ";
//$sql .= "where start_stamp > NOW() - INTERVAL '7 days' ";
$sql .= "where true ";
if ($action == 'convert' || $action == 'both') {
$sql .= "and record_name like '%.wav' ";
}
if ($action == 'move' || $action == 'both') {
$sql .= "and length(record_path) > 0 ";
$sql .= "and substr(record_path, 1, length(:source_path)) = :source_path ";
$parameters['source_path'] = $source_path;
}
$sql .= "order by start_stamp desc ";
if ($debug) { echo $sql."\n"; }
$call_recordings = $database->select($sql, $parameters, 'all');
unset($parameters);
//process the changes
foreach ($call_recordings as $row) {
//set the record_name
$record_name = $row['record_name'];
//set the source_path
$source_path = realpath($row['record_path']);
//get the file name without the file extension
$path_parts = pathinfo($source_path.'/'.$record_name);
//convert the audio file from wav to mp3
if ($action == 'convert' || $action == 'both') {
if ($debug) {
if (!file_exists($source_path."/".$record_name)) {
//echo "file not found: ".$source_path."/".$record_name."\n";
}
else {
echo "found file: ".$source_path."/".$record_name."\n";
}
}
if (file_exists($source_path."/".$record_name)) {
//build the run the mpg123 command
if ($preferred_command == 'mpg123' && !file_exists($source_path."/".$path_parts['filename'].".mp3")) {
$command = "mpg123 -w ".$source_path."/".$record_name." ".$source_path."/".$path_parts['filename'].".mp3\n";
if ($debug) { echo $command."\n"; }
system($command);
}
//build the run the mpg123 command
if ($preferred_command == 'lame' && !file_exists($source_path."/".$path_parts['filename'].".mp3")) {
$command = "lame -b 128 ".$source_path."/".$record_name." ".$source_path."/".$path_parts['filename'].".mp3\n";
if ($debug) { echo $command."\n"; }
system($command);
}
//update the record name to use the new file extension
if (file_exists($source_path."/".$path_parts['filename'].".mp3")) {
//make sure the mp3 file exists and then delete the wav file
unlink($source_path."/".$path_parts['filename'].".wav");
//set the record_name with the new file extension
$record_name = $path_parts['filename'].".mp3";
}
}
}
//move the files
if ($action == 'move' || $action == 'both') {
//get break down the date to year, month and day
$start_time = strtotime($row['start_stamp']);
$start_year = date("Y", $start_time);
$start_month = date("M", $start_time);
$start_day = date("d", $start_time);
//move the recording from the old to the new directory
$old_path = realpath($row['record_path']);
$new_path = realpath($destination_path).'/'.$row['domain_name'].'/archive/'.$start_year.'/'.$start_month.'/'.$start_day;
if (!file_exists($new_path)) { system('mkdir -p '.$new_path); }
$command = "mv ".$old_path."/".$record_name." ".$new_path."/".$record_name;
if ($debug) { echo $command."\n"; }
system($command);
}
//update the database to the new directory
$sql = "update v_xml_cdr set \n";
if ($action == 'move' || $action == 'both') {
$sql .= "record_path = '".$new_path."' \n";
}
if ($action == 'convert' || $action == 'both') {
$sql .= "record_name = '".$path_parts['filename'].".mp3'\n";
}
$sql .= "where xml_cdr_uuid = '".$row['xml_cdr_uuid']."';\n";
if ($debug) { echo $sql."\n"; }
$database->execute($sql);
}
?>

View File

@ -0,0 +1,3 @@
check process freeswitch with pidfile /run/freeswitch/freeswitch.pid
start program = "/usr/src/fusionpbx-install.sh/debian/resources/monit/./shell.sh"
stop program = "/usr/bin/freeswitch -stop"

View File

@ -0,0 +1,5 @@
#!/bin/sh
mkdir -p /var/run/freeswitch
chown -R www-data:www-data /var/run/freeswitch
/usr/bin/freeswitch -nc -u www-data -g www-data -nonat

View File

@ -41,6 +41,15 @@ fi
if [ ."$php_version" = ."7.4" ]; then
sed -i /etc/nginx/sites-available/fusionpbx -e 's#unix:.*;#unix:/var/run/php/php7.4-fpm.sock;#g'
fi
if [ ."$php_version" = ."8.1" ]; then
sed -i /etc/nginx/sites-available/fusionpbx -e 's#unix:.*;#unix:/var/run/php/php8.1-fpm.sock;#g'
fi
if [ ."$php_version" = ."8.2" ]; then
sed -i /etc/nginx/sites-available/fusionpbx -e 's#unix:.*;#unix:/var/run/php/php8.2-fpm.sock;#g'
fi
if [ ."$php_version" = ."8.3" ]; then
sed -i /etc/nginx/sites-available/fusionpbx -e 's#unix:.*;#unix:/var/run/php/php8.3-fpm.sock;#g'
fi
ln -s /etc/nginx/sites-available/fusionpbx /etc/nginx/sites-enabled/fusionpbx
#self signed certificate

View File

@ -13,6 +13,18 @@ verbose "Configuring PHP"
#add the repository
if [ ."$os_name" = ."Ubuntu" ]; then
#24.04.x - /*noble/
if [ ."$os_codename" = ."noble" ]; then
echo "Ubuntu 24.04 LTS\n"
which add-apt-repository || apt-get install -y software-properties-common
LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/php
fi
#22.04.x - /*jammy/
if [ ."$os_codename" = ."jammy" ]; then
echo "Ubuntu 22.04 LTS\n"
which add-apt-repository || apt-get install -y software-properties-common
LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/php
fi
#20.04.x - /*bionic/
if [ ."$os_codename" = ."focal" ]; then
echo "Ubuntu 20.04 LTS\n"
@ -53,6 +65,15 @@ fi
if [ ."$php_version" = ."7.4" ]; then
apt-get install -y php7.4 php7.4-cli php7.4-fpm php7.4-pgsql php7.4-sqlite3 php7.4-odbc php7.4-curl php7.4-imap php7.4-xml php7.4-gd php7.4-mbstring
fi
if [ ."$php_version" = ."8.1" ]; then
apt-get install -y php8.1 php8.1-cli php8.1-fpm php8.1-pgsql php8.1-sqlite3 php8.1-odbc php8.1-curl php8.1-imap php8.1-xml php8.1-gd php8.1-mbstring
fi
if [ ."$php_version" = ."8.2" ]; then
apt-get install -y php8.2 php8.2-cli php8.2-fpm php8.2-pgsql php8.2-sqlite3 php8.2-odbc php8.2-curl php8.2-imap php8.2-xml php8.2-gd php8.2-mbstring
fi
if [ ."$php_version" = ."8.3" ]; then
apt-get install -y php8.3 php8.3-cli php8.3-fpm php8.3-pgsql php8.3-sqlite3 php8.3-odbc php8.3-curl php8.3-imap php8.3-xml php8.3-gd php8.3-mbstring
fi
#update config if source is being used
if [ ."$php_version" = ."5" ]; then
@ -75,6 +96,18 @@ if [ ."$php_version" = ."7.4" ]; then
verbose "version 7.4"
php_ini_file='/etc/php/7.4/fpm/php.ini'
fi
if [ ."$php_version" = ."8.1" ]; then
verbose "version 8.1"
php_ini_file='/etc/php/8.1/fpm/php.ini'
fi
if [ ."$php_version" = ."8.2" ]; then
verbose "version 8.2"
php_ini_file='/etc/php/8.2/fpm/php.ini'
fi
if [ ."$php_version" = ."8.3" ]; then
verbose "version 8.3"
php_ini_file='/etc/php/8.3/fpm/php.ini'
fi
sed 's#post_max_size = .*#post_max_size = 80M#g' -i $php_ini_file
sed 's#upload_max_filesize = .*#upload_max_filesize = 80M#g' -i $php_ini_file
sed 's#;max_input_vars = .*#max_input_vars = 8000#g' -i $php_ini_file
@ -102,6 +135,15 @@ fi
if [ ."$php_version" = ."7.4" ]; then
systemctl restart php7.4-fpm
fi
if [ ."$php_version" = ."8.1" ]; then
systemctl restart php8.1-fpm
fi
if [ ."$php_version" = ."8.2" ]; then
systemctl restart php8.2-fpm
fi
if [ ."$php_version" = ."8.3" ]; then
systemctl restart php8.3-fpm
fi
#init.d
#/usr/sbin/service php5-fpm restart
#/usr/sbin/service php7.0-fpm restart

View File

@ -5,6 +5,7 @@ cd "$(dirname "$0")"
#includes
. ./config.sh
. ./environment.sh
if [ .$switch_source = .true ]; then
if [ ."$switch_branch" = "master" ]; then

View File

@ -10,12 +10,7 @@ cd "$(dirname "$0")"
apt update && apt upgrade -y
# install dependencies
apt install -y autoconf automake devscripts g++ git-core libncurses5-dev libtool make libjpeg-dev \
pkg-config flac libgdbm-dev libdb-dev gettext sudo equivs mlocate git dpkg-dev libpq-dev \
liblua5.2-dev libtiff5-dev libperl-dev libcurl4-openssl-dev libsqlite3-dev libpcre3-dev \
devscripts libspeexdsp-dev libspeex-dev libldns-dev libedit-dev libopus-dev libmemcached-dev \
libshout3-dev libmpg123-dev libmp3lame-dev yasm nasm libsndfile1-dev libuv1-dev libvpx-dev \
libavformat-dev libswscale-dev libspandsp-dev pip libpq-dev libvlc-dev uuid-dev sox libsox-fmt-all
apt install -y autoconf automake devscripts g++ git-core libncurses5-dev libtool make libjpeg-dev pkg-config flac libgdbm-dev libdb-dev gettext sudo equivs plocate git dpkg-dev libpq-dev liblua5.2-dev libtiff5-dev libperl-dev libcurl4-openssl-dev libsqlite3-dev libpcre3-dev devscripts libspeexdsp-dev libspeex-dev libldns-dev libedit-dev libopus-dev libmemcached-dev libshout3-dev libmpg123-dev libmp3lame-dev yasm nasm libsndfile1-dev libuv1-dev libvpx-dev libavformat-dev libswscale-dev libspandsp-dev pip libpq-dev libvlc-dev uuid-dev sox libsox-fmt-all
# additional dependencies
apt install -y swig3.0 unzip sox wget
@ -79,12 +74,12 @@ mv freeswitch-$switch_version.-release freeswitch-$switch_version
cd /usr/src/freeswitch-$switch_version
# bootstrap is needed if using git
#./bootstrap.sh -j
./bootstrap.sh -j
# enable required modules
sed -i /usr/src/freeswitch-$switch_version/modules.conf -e s:'#applications/mod_callcenter:applications/mod_callcenter:'
sed -i /usr/src/freeswitch-$switch_version/modules.conf -e s:'#applications/mod_cidlookup:applications/mod_cidlookup:'
sed -i /usr/src/freeswitch-$switch_version-$switch_version/modules.conf -e s:'#applications/mod_memcache:applications/mod_memcache:'
sed -i /usr/src/freeswitch-$switch_version/modules.conf -e s:'#applications/mod_memcache:applications/mod_memcache:'
sed -i /usr/src/freeswitch-$switch_version/modules.conf -e s:'#applications/mod_curl:applications/mod_curl:'
sed -i /usr/src/freeswitch-$switch_version/modules.conf -e s:'#formats/mod_shout:formats/mod_shout:'
sed -i /usr/src/freeswitch-$switch_version/modules.conf -e s:'#formats/mod_pgsql:formats/mod_pgsql:'
@ -93,6 +88,7 @@ sed -i /usr/src/freeswitch-$switch_version/modules.conf -e s:'endpoints/mod_vert
#disable module or install dependency libks to compile signalwire
sed -i /usr/src/freeswitch-$switch_version/modules.conf -e s:'applications/mod_signalwire:#applications/mod_signalwire:'
sed -i /usr/src/freeswitch-$switch_version/modules.conf -e s:'applications/mod_av:#applications/mod_av:'
# prepare the build
#./configure --prefix=/usr/local/freeswitch --enable-core-pgsql-support --disable-fhs