initial commit of file from CVS for smeserver-freepbx on Sat Sep 7 20:25:35 AEST 2024

This commit is contained in:
Trevor Batley
2024-09-07 20:25:35 +10:00
parent bd24175623
commit 190a3e0d7a
80 changed files with 3092 additions and 2 deletions

View File

@@ -0,0 +1,13 @@
[directories]
astetcdir => /etc/asterisk
astmoddir => { return '/usr/lib64/asterisk/modules' if -d '/usr/lib64/asterisk/modules';
return '/usr/lib/asterisk/modules' if -d '/usr/lib/asterisk/modules'; }
astvarlibdir => /var/lib/asterisk
astdatadir => { return '/var/lib/asterisk' if -d '/var/lib/asterisk/documentation' ;
return '/usr/share/asterisk' if -d '/usr/share/asterisk/documentation';}
astagidir => /var/lib/asterisk/agi-bin
astspooldir => /var/spool/asterisk
astrundir => /var/run/asterisk
astlogdir => /var/log/asterisk

View File

@@ -0,0 +1,39 @@
[options]
languageprefix = yes ; Use the new sound prefix path syntax
;verbose = 3
;debug = 3
;alwaysfork = yes ; same as -F at startup
;nofork = yes ; same as -f at startup
;quiet = yes ; same as -q at startup
;timestamp = yes ; same as -T at startup
execincludes = yes ; support #exec in config files
;console = yes ; Run as console (same as -c at startup)
highpriority = yes ; Run realtime priority (same as -p at startup)
;initcrypto = yes ; Initialize crypto keys (same as -i at startup)
nocolor = yes ; Disable console colors
;dontwarn = yes ; Disable some warnings
;dumpcore = yes ; Dump core on crash (same as -g at startup)
;internal_timing = yes
;systemname = my_system_name ; prefix uniqueid with a system name for global uniqueness issues
;maxcalls = 10 ; Maximum amount of calls allowed
;maxload = 0.9 ; Asterisk stops accepting new calls if the load average exceed this limit
;cache_record_files = yes ; Cache recorded sound files to another directory during recording
;record_cache_dir = /tmp ; Specify cache directory (used in conjunction with cache_record_files)
;transmit_silence_during_record = yes ; Transmit SLINEAR silence while a channel is being recorded
;transmit_silence = yes ; Transmit silence while a channel is in a waiting state, a recording only state, or when DTMF is
; being generated. Note that the silence internally is generated in raw signed linear format.
; This means that it must be transcoded into the native format of the channel before it can be sent
; to the device. It is for this reason that this is optional, as it may result in requiring a
; temporary codec translation path for a channel that may not otherwise require one.
;transcode_via_sln = yes ; Build transcode paths via SLINEAR, instead of directly
;runuser = asterisk ; The user to run as
;rungroup = asterisk ; The group to run as
;dahdichanname = yes ; Channels created by chan_dahdi will be called 'DAHDI', otherwise 'Zap'
; Changing the following lines may compromise your security.
;[files]
;astctlpermissions = 0660
;astctlowner = root
;astctlgroup = apache
;astctl = asterisk.ctl

View File

@@ -0,0 +1,20 @@
;
; Note - if the database server is hosted on the same machine as the
; asterisk server, you can achieve a local Unix socket connection by
; setting hostname = localhost
;
; port and sock are both optional parameters. If hostname is specified
; and is not "localhost", then cdr_mysql will attempt to connect to the
; port specified or use the default port. If hostname is not specified
; or if hostname is "localhost", then cdr_mysql will attempt to connect
; to the socket file specified by sock or otherwise use the default socket
; file.
;
[global]
hostname = localhost
dbname = {${'freepbx'}{'CdrDbName'};}
password = {${'freepbx'}{'DbPassword'};}
user = {${'freepbx'}{'DbUser'};}
userfield=1
sock = /var/lib/mysql/mysql.sock

View File

@@ -0,0 +1,11 @@
;------------------------------------------------------------
; !!DO NOT MODIFY THIS FILE!!
;
; Manual changes will be lost when this file is regenerated.
;
; Please read the developer's guide, which is available
; at http://www.contribs.org/development/
;
; Copyright (C) 1999-2006 Mitel Networks Corporation
;------------------------------------------------------------

View File

@@ -0,0 +1,8 @@
;
; Asterisk Call Management support
;
[general]
enabled = yes
port = 5038
bindaddr = 0.0.0.0

View File

@@ -0,0 +1,7 @@
[admin]
secret = {${'freepbx'}{'ManagerPassword'};}
deny=0.0.0.0/0.0.0.0
permit=127.0.0.1/255.255.255.0
read = system,call,log,verbose,command,agent,user
write = system,call,log,verbose,command,agent,user

View File

@@ -0,0 +1,4 @@
#include manager_additional.conf
#include manager_custom.conf

View File

@@ -0,0 +1,11 @@
;------------------------------------------------------------
; !!DO NOT MODIFY THIS FILE!!
;
; Manual changes will be lost when this file is regenerated.
;
; Please read the developer's guide, which is available
; at http://www.contribs.org/development/
;
; Copyright (C) 1999-2006 Mitel Networks Corporation
;------------------------------------------------------------

View File

@@ -0,0 +1,51 @@
{
my $dbname = $freepbx{'DbName'} || 'freepbxdb';
my $cdrdbname = $freepbx{'CdrDbName'} || 'asteriskcdrdb';
my $dbuser = $freepbx{'DbUser'} || 'freepbxuser';
my $dbpass = $freepbx{'DbPassword'} || 'secret';
my $cdrdbpass = $freepbx{'CdrDbPassword'} || 'secret';
my $ManagerPassword = $freepbx{'ManagerPassword'} || 'secret';
$OUT .= << "HERE";
#! /bin/sh
if [ ! -d /var/lib/mysql/$dbname ]; then
mysql -e "create database $dbname CHARACTER SET utf8 COLLATE utf8_unicode_ci ;"
if [ -e /usr/share/freepbx/sql/asterisk.sql ]; then
mysql $dbname < /usr/share/freepbx/sql/asterisk.sql
else
echo "Error: file /usr/share/freepbx/sql/asterisk.sql doesn't exists"
exit 1
fi
fi
if [ ! -d /var/lib/mysql/$cdrdbname ]; then
mysql -e "create database $cdrdbname CHARACTER SET utf8 COLLATE utf8_unicode_ci ;"
if [ -e /usr/share/freepbx/sources/freepbx/installlib/SQL/cdr.sql ]; then
mysql $cdrdbname < /usr/share/freepbx/sources/freepbx/installlib/SQL/cdr.sql
else
echo "Error: file /usr/share/freepbx/sources/freepbx/installlib/SQL/cdr.sql doesn't exists"
exit 1
fi
fi
/usr/bin/mysql $dbname -e 'INSERT INTO `admin` (`variable`, `value`) VALUES ("email", "admin\@$DomainName") ON DUPLICATE KEY UPDATE `value` = "admin\@$DomainName";'
/usr/bin/mysql $dbname -e 'INSERT INTO `ampusers` (`username`, `password_sha1`, `extension_low`, `extension_high`, `deptname`, `sections`) VALUES
("admin", sha1("$ManagerPassword"), "", "", "", 0x2a) ON DUPLICATE KEY UPDATE `password_sha1` = sha1("$ManagerPassword");'
/usr/bin/mysql <<EOF
USE mysql;
GRANT ALL PRIVILEGES ON ${dbname} TO '$dbuser'\@'localhost' identified by '$dbpass';
GRANT ALL PRIVILEGES ON ${cdrdbname} TO '$dbuser'\@'localhost' identified by '$dbpass';
FLUSH PRIVILEGES;
EOF
HERE
}

View File

@@ -0,0 +1,47 @@
{
# vim: ft=perl:
$haveSSL = (exists ${modSSL}{status} and ${modSSL}{status} eq "enabled") ? 'yes' : 'no';
$OUT = '';
if ((${'freepbx'}{'status'} || 'disabled') eq 'enabled' &&
(${'httpd-fpbx'}{'status'} || 'disabled') eq 'enabled'){
if (($port eq "80") && ($haveSSL eq 'yes')){
$OUT .= " RewriteRule ^/freepbx(/.*|\$) https://%{HTTP_HOST}/freepbx\$1 [L,R]\n";
$OUT .= " RewriteRule ^/ucp(/.*|\$) https://%{HTTP_HOST}/ucp\$1 [L,R]\n";
}
else{
$OUT .= " ProxyPass /freepbx http://127.0.0.1:${'httpd-fpbx'}{TCPPort}/freepbx\n";
$OUT .= " ProxyPassReverse /freepbx http://127.0.0.1:${'httpd-fpbx'}{TCPPort}/freepbx\n";
$OUT .= " ProxyPass /ucp http://127.0.0.1:${'httpd-fpbx'}{TCPPort}/ucp\n";
$OUT .= " ProxyPassReverse /ucp http://127.0.0.1:${'httpd-fpbx'}{TCPPort}/ucp\n";
}
foreach my $url qw(recordings){
$OUT .= " RewriteRule ^/$url(.*|\$) /freepbx/$url\$1 [L,R]\n";
}
$OUT .=<<"HERE";
<Location /freepbx>
SSLRequireSSL on
Require ip $localAccess $externalSSLAccess
</Location>
<Location /freepbx/admin>
Require ip $localAccess $externalSSLAccess
</Location>
<Location /freepbx/recordings>
Require all granted
</Location>
<Location /ucp>
SSLRequireSSL on
Require ip $localAccess $externalSSLAccess
</Location>
HERE
}
}

View File

@@ -0,0 +1,28 @@
{
use esmith::AccountsDB;
sub getUsersList ($){
my ($panelName) = @_;
my $a = esmith::AccountsDB->open_ro || die "Error opening accounts db";
my @users = $a->users();
my @groups = $a->groups();
my @fpbxUsers = ();
foreach my $user (@users){
my $panels = $user->prop('AdminPanels') || '';
push(@fpbxUsers,$user->key) if ($panels =~ /^(.*,)?$panelName(,.*)?$/);
}
foreach my $group (@groups){
$panels = $group->prop('AdminPanels') || '';
if ($panels =~ /^(.*,)?$panelName(,.*)?$/){
my @members = split(/,/,($group->prop('Members') || ''));
push(@fpbxUsers,@members);
}
}
my %seen = ();
my $u = join (' ', grep { ! $seen{ $_ }++ } @fpbxUsers);
return $u;
}
}

View File

@@ -0,0 +1,22 @@
{
#---------------------------------------------------------------------
# Grab ValidFrom access list property of httpd-admin
# SSL enabled virtual hosts should only allow access from IP's in
# this list, as well as local networks.
#---------------------------------------------------------------------
use esmith::NetworksDB;
my $ndb = esmith::NetworksDB->open_ro();
my @localAccess = $ndb->local_access_spec();
my $validFrom = ${'httpd-admin'}{'ValidFrom'};
if ($validFrom)
{
push @localAccess, split /,/, $validFrom;
}
$localAccess .= join ' ',
map { s:/255.255.255.255::; $_ }
@localAccess;
"";
}

View File

@@ -0,0 +1,7 @@
{
$OUT .= "LoadModule auth_tkt_module modules/mod_auth_tkt.so\n";
my $secret = ${'httpd-admin'}{TKTAuthSecret} || "34322500-7330-4400-423A-3A00434F5245";
$OUT .= "TKTAuthSecret \"$secret\"\n";
$OUT .= "TKTAuthDigestType SHA256\n";
}

View File

@@ -0,0 +1,152 @@
{
$OUT .= "Listen 127.0.0.1:${'httpd-fpbx'}{TCPPort}\n";
$OUT .= <<HERE;
HostnameLookups off
ServerAdmin admin@$DomainName
ServerRoot /etc/httpd
ServerTokens ProductOnly
User asterisk
Group asterisk
ErrorLog /var/log/httpd/fpbx_error_log
LogLevel warn
HERE
foreach (qw(
env
log_config
mime
proxy
proxy_fcgi
authz_core
authn_core
unixd
systemd
mpm_prefork
negotiation
status
info
include
autoindex
dir
asis
imap
imagemap
actions
userdir
alias
rewrite
access
authz_host
authz_user
auth
auth_anon
auth_digest
expires
headers
usertrack
setenvif
))
{
next unless -f "/usr/lib/httpd/modules/mod_${_}.so" ||
-f "/usr/lib64/httpd/modules/mod_${_}.so";
$OUT .= "LoadModule ${_}_module modules/mod_${_}.so\n";
}
# we do not use php module anymore, but php-fpm
$OUT .= <<HERE;
PidFile /var/run/httpd-fpbx.pid
UseCanonicalName off
LogFormat "%h %l %u %t \\"%r\\" %>s %b" common
LogFormat "%{User-agent}i" agent
CustomLog /var/log/httpd/fpbx_access_log common
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 15
MaxClients 150
MaxRequestsPerChild 100
ServerName www.$DomainName
MinSpareServers 1
MaxSpareServers 5
StartServers 1
Timeout 300
DefaultIcon /icons/unknown.gif
DirectoryIndex index.htm index.html index.php index.cgi
IndexOptions FancyIndexing VersionSort NameWidth=*
IndexIgnore .??* *~ *# HEADER* README* RCS CVS *,v *,t
AccessFileName .htaccess
AddIconByEncoding (CMP,/icons/compressed.gif) x-compress x-gzip
AddIconByType (TXT,/icons/text.gif) text/*
AddIconByType (IMG,/icons/image2.gif) image/*
AddIconByType (SND,/icons/sound2.gif) audio/*
AddIconByType (VID,/icons/movie.gif) video/*
TypesConfig /etc/mime.types
AddEncoding x-compress Z
AddEncoding x-gzip gz
AddIcon /icons/binary.gif .bin .exe
AddIcon /icons/binhex.gif .hqx
AddIcon /icons/tar.gif .tar
AddIcon /icons/world2.gif .wrl .wrl.gz .vrml .vrm .iv
AddIcon /icons/compressed.gif .Z .z .tgz .gz .zip
AddIcon /icons/a.gif .ps .ai .eps
AddIcon /icons/layout.gif .html .shtml .htm .pdf
AddIcon /icons/text.gif .txt
AddIcon /icons/c.gif .c
AddIcon /icons/p.gif .pl .py
AddIcon /icons/f.gif .for
AddIcon /icons/dvi.gif .dvi
AddIcon /icons/uuencoded.gif .uu
AddIcon /icons/script.gif .conf .sh .shar .csh .ksh .tcl
AddIcon /icons/tex.gif .tex
AddIcon /icons/bomb.gif core
AddIcon /icons/back.gif ..
AddIcon /icons/hand.right.gif README
AddIcon /icons/folder.gif ^^DIRECTORY^^
AddIcon /icons/blank.gif ^^BLANKICON^^
AddLanguage en .en
AddLanguage fr .fr
AddLanguage de .de
AddLanguage da .da
AddLanguage el .el
AddLanguage it .it
LanguagePriority en fr de
AddType text/html .shtml
AddType application/x-pkcs7-crl .crl
AddType application/x-x509-ca-cert .crt
BrowserMatch "Mozilla/2" nokeepalive
BrowserMatch "MSIE 4\.0b2;" nokeepalive downgrade-1.0 force-response-1.0
BrowserMatch "RealPlayer 4\.0" force-response-1.0
BrowserMatch "Java/1\.0" force-response-1.0
BrowserMatch "JDK/1\.0" force-response-1.0
AddHandler cgi-script .cgi
AddHandler server-parsed .shtml
AddHandler imap-file map
DocumentRoot /opt/freepbx/
HERE
}

View File

@@ -0,0 +1,10 @@
# First, we configure the "default" to be a very restrictive set of
# permissions.
<Directory />
Options None
AllowOverride None
Require all denied
</Directory>

View File

@@ -0,0 +1,4 @@
Alias /freepbx /opt/freepbx/
Alias /ucp /opt/freepbx/ucp/

View File

@@ -0,0 +1,16 @@
<Directory /opt/freepbx/>
Options +followSymlinks
{
my $key = "freepbx";
my $pool_name = lc $key;
my $version = ( $freepbx{PHPVersion} eq '74' )? '74' : '56';
$OUT .="
<FilesMatch .php\$>
SetHandler \"proxy:unix:/var/run/php-fpm/php${version}-${pool_name}.sock|fcgi://localhost\"
</FilesMatch>\n";
}
AllowOverride All
Require host 127.0.0.1
</Directory>

View File

@@ -0,0 +1,24 @@
<Directory /opt/freepbx/admin/>
Options +followSymlinks
</Directory>
<Directory /opt/freepbx/admin/modules/>
Require host 127.0.0.1
</Directory>
<Location /freepbx/admin>
AuthType Basic
TKTAuthLoginURL /server-common/cgi-bin/login
Require user admin {getUsersList('freepbx');}
{
my $ManagerTimeout = ${'httpd-admin'}{ManagerTimeout} || "30m";
$OUT = " TKTAuthTimeout $ManagerTimeout\n";
my $Cookie = ${'httpd-admin'}{Cookie} || "disabled";
$OUT .= " TKTAuthCookieExpires $ManagerTimeout\n" if "$Cookie" eq "enabled";
my $ManagerTimeoutReset = ${'httpd-admin'}{ManagerTimeoutReset} || "0.66";
$OUT .= " TKTAuthTimeoutRefresh $ManagerTimeoutReset\n";
}
#Satisfy all
</Location>

View File

@@ -0,0 +1,36 @@
/var/log/asterisk/messages
/var/log/asterisk/event_log
/var/log/asterisk/queue_log
/var/log/asterisk/full
/var/log/asterisk/security
/var/log/asterisk/freepbx.log
/var/log/asterisk/freepbx_security.log
/var/log/asterisk/ucp_err.log
/var/log/asterisk/ucp_out.log
/var/log/asterisk/cdr-csv/Master.csv
/var/log/asterisk/warnings
/var/log/asterisk/misdn.log
/var/log/asterisk/backup.log
/var/log/asterisk/backup-*.log
/var/log/asterisk/freepbx_dbug
/var/log/asterisk/core-fastagi_out.log
/var/log/asterisk/core-calltransfer-monitor_err.log
/var/log/asterisk/core-calltransfer-monitor_out.log
\{
missingok
notifempty
compress
compressoptions -T0
compresscmd /usr/bin/xz
compressext .xz
uncompresscmd /usr/bin/unxz
daily
rotate 365
su asterisk asterisk
create 0640 asterisk asterisk
sharedscripts
postrotate
/usr/sbin/asterisk -rx 'logger reload' >/dev/null 2>/dev/null || true
endscript
\}

View File

@@ -0,0 +1 @@
# /var/log/xferlog already handled in /etc/logrotate.d/proftpd

View File

@@ -0,0 +1,12 @@
[MySQL-{ ${freepbx}{CdrDbName} || 'asteriskcdrdb' }]
Description=MySQL connection to '{ ${freepbx}{CdrDbName} || 'asteriskcdrdb' }' database
driver=MySQL
server=localhost
database={ ${freepbx}{CdrDbName} || 'asteriskcdrdb' }
Port=3306
Socket=/var/lib/mysql/mysql.sock
option=3
Charset=utf8
User = { ${freepbx}{DbUser} || 'freepbxuser'}
Password = { ${freepbx}{DbPassword} || 'freepbxuser'}

View File

@@ -0,0 +1,70 @@
{
my $PHPVersion = ( $freepbx{PHPVersion} eq '74' )? '74' : '56';
if ($PHP_VERSION eq $PHPVersion){
if (($freepbx{'status'} || 'disabled') eq 'enabled'){
my $max_upload_size = ($freepbx{MaxUploadSize} || '100M');
$max_upload_size .= 'M' if ($max_upload_size =~ m/^\d+$/);
my $memory_limit = ($freepbx{MemoryLimit} || '512M');
$memory_limit .= 'M' if ($memory_limit =~ m/^\d+$/);
my $open_basedir= $freepbx{PHPBaseDir} || '';
$open_basedir = "/usr/share/freepbx:/var/lib/freepbx:/var/log/freepbx/:/var/lib/php/freepbx:/home/e-smith/files/freepbx:/dev/urandom:/proc/meminfo:$open_basedir";
my $id = 'freepbx';
my $max_children = $freepbx{'PHPmaxChildren'} || 15;
my $min_spare_servers = $freepbx{'PHPminServers'} || 3;
my $start_servers = $freepbx{'PHPstartServers'} || 3;
my $max_spare_servers = $freepbx{'PHPmaxServers'} || 6;
my $max_requests = $freepbx{'PHPmaxRequests'} || 5000;
$min_spare_servers = ( $min_spare_servers > $max_spare_servers ) ? printf("%.0f",$max_spare_servers/2) : $min_spare_servers;
$start_servers = ( $start_servers > $max_spare_servers ) ? printf("%.0f", $max_spare_servers /2 + $min_spare_servers/2 ) : $start_servers;
$OUT .=<<_EOF;
[freepbx]
listen.owner = root
listen.group = asterisk
listen.mode = 0660
listen = /var/run/php-fpm/php$PHP_VERSION-$id.sock
user = asterisk
group = asterisk
catch_workers_output = yes
pm = dynamic
pm.max_children = $max_children
pm.start_servers = $start_servers
pm.min_spare_servers = $min_spare_servers
pm.max_spare_servers = $max_spare_servers
pm.max_requests = $max_requests
request_terminate_timeout = 60m
php_flag[display_errors] = off
php_admin_flag[log_errors] = on
php_admin_value[error_log] = /var/log/$id/error.log
php_admin_value[memory_limit] = $memory_limit
php_admin_value[session.save_path] = /var/lib/php/fpbx-session
php_admin_value[upload_tmp_dir] = /var/lib/php/$id/tmp
php_admin_value[sys_temp_dir] = /var/lib/php/$id/tmp
php_admin_value[post_max_size] = $max_upload_size
php_admin_value[upload_max_filesize] = $max_upload_size
php_admin_value[max_execution_time] = 900
php_admin_value[max_input_time] = 900
php_admin_flag[allow_url_include] = off
php_admin_flag[allow_url_fopen] = on
php_admin_flag[file_uploads] = on
php_admin_flag[session.cookie_httponly] = on
; Needed so that the #!/usr/bin/env php shebang will point to the correct PHP version
env[PATH] = /opt/remi/php{{ fpbx_php_version }}/root/usr/bin:/opt/remi/php{{ fpbx_php_version }}/root/usr/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
;env[http_proxy] = {{ system_proxy }}
;env[https_proxy] = {{ system_proxy }}
;env[no_proxy] =
_EOF
}
else{
$OUT .= '; Nextcloud is disabled';
}
}
}