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 @@
system

View File

@@ -0,0 +1 @@
url

View File

@@ -0,0 +1 @@
url

View File

@@ -0,0 +1 @@
url

View File

@@ -0,0 +1 @@
enabled

View File

@@ -0,0 +1 @@
service

View File

@@ -0,0 +1 @@
asteriskcdrdb

View File

@@ -0,0 +1 @@
freepbxdb

View File

@@ -0,0 +1 @@
freepbxuser

View File

@@ -0,0 +1 @@
5061

View File

@@ -0,0 +1 @@
5060,5061,5160,5161,4569,10000:20000

View File

@@ -0,0 +1 @@
private

View File

@@ -0,0 +1 @@
enabled

View File

@@ -0,0 +1 @@
service

View File

@@ -0,0 +1 @@
960

View File

@@ -0,0 +1 @@
enabled

View File

@@ -0,0 +1 @@
service

View File

@@ -0,0 +1,46 @@
{
my $freepbx = $DB->get('freepbx') || $DB->new_record('freepbx', {type => 'service'});
my $dbpass = $freepbx->prop('DbPassword') ||
$freepbx->set_prop('DbPassword', `/usr/bin/openssl rand -base64 40 | /usr/bin/tr -c -d '[:graph:]'`);
my $managerpass = $freepbx->prop('ManagerPassword') ||
$freepbx->set_prop('ManagerPassword', `/usr/bin/openssl rand -base64 10 | /usr/bin/tr -c -d '[:alnum:]'`);
my $aripass = $freepbx->prop('AriPassword') ||
$freepbx->set_prop('AriPassword', `/usr/bin/openssl rand -base64 10 | /usr/bin/tr -c -d '[:alnum:]'`);
# FOP not compatible with latest astersisk
my $fop = $DB->get("fop");
$fop->delete if $fop;
# with freepbx 13, we have a new port
my $UDPPorts = $freepbx->prop('UDPPorts') || '5060,5061,5160,5161,4569,10000:20000';
my @UDPlist= split(',',$UDPPorts);
unless ('5061' ~~ @UDPlist){
$UDPPorts = "$UDPPorts,5061";
$freepbx->set_prop('UDPPorts',$UDPPorts);
}
unless ('5160' ~~ @UDPlist){
$UDPPorts = "$UDPPorts,5160";
$freepbx->set_prop('UDPPorts',$UDPPorts);
}
unless ('5161' ~~ @UDPlist){
$UDPPorts = "$UDPPorts,5161";
$freepbx->set_prop('UDPPorts',$UDPPorts);
}
if ('10000-20000' ~~ @UDPlist){
$UDPPorts =~ s/,10000-20000//;
$UDPPorts = "$UDPPorts,10000:20000";
$freepbx->set_prop('UDPPorts',$UDPPorts);
}
if ('1000-2000' ~~ @UDPlist){
$UDPPorts =~ s/,1000-2000//;
$freepbx->set_prop('UDPPorts',$UDPPorts);
}
}
#remove DeviceAndUser property
my $DeviceAndUser = $freepbx->prop('DeviceAndUser');
$frepbx->delete_prop('DeviceAndUser') if defined $DeviceAndUser;

View File

@@ -0,0 +1,33 @@
#!/bin/bash
version=$(/usr/bin/xmllint --xpath 'string(/module/version)' /opt/freepbx/admin/modules/core/module.xml|cut -d. -f1)
if [[ $version -ge 15 ]] ; then
fwconsole="/sbin/e-smith/fwconsole"
$fwconsole setting DISABLE_CSS_AUTOGEN 1
$fwconsole setting CHECKREFERER 0
$fwconsole setting AUTHTYPE none
$fwconsole setting AMPWEBROOT /opt/freepbx
$fwconsole setting MODULEADMINWGET 1
$fwconsole setting DYNAMICHINTS 1
$fwconsole setting ARI_ADMIN_PASSWORD $(/sbin/e-smith/db configuration getprop freepbx AriPassword) 2>/dev/null 1>&2
$fwconsole setting AMPMGRPASS $(/sbin/e-smith/db configuration getprop freepbx ManagerPassword)
$fwconsole setting RSSFEEDS 'http://www.freepbx.org/rss.xml'
$fwconsole setting BRAND_FREEPBX_ALT_FOOT FreePBX
else
# Change FreePBX database settings that should have come from /etc/amportal.conf,
# this is a dynamic template for FreePBX > 1.9 as it update the file on the fly, and also the db
FPBX_SETTING_PATH="/var/lib/asterisk/bin/freepbx_setting"
$FPBX_SETTING_PATH DISABLE_CSS_AUTOGEN 1
$FPBX_SETTING_PATH CHECKREFERER 0
$FPBX_SETTING_PATH AUTHTYPE none
$FPBX_SETTING_PATH AMPWEBROOT /opt/freepbx
$FPBX_SETTING_PATH MODULEADMINWGET 1
$FPBX_SETTING_PATH DYNAMICHINTS 1
$FPBX_SETTING_PATH ARI_ADMIN_PASSWORD $(/sbin/e-smith/db configuration getprop freepbx AriPassword)
$FPBX_SETTING_PATH AMPMGRPASS $(/sbin/e-smith/db configuration getprop freepbx ManagerPassword)
$FPBX_SETTING_PATH RSSFEEDS 'http://www.freepbx.org/rss.xml'
$FPBX_SETTING_PATH BRAND_FREEPBX_ALT_FOOT FreePBX
fi
# now regenrate the amportal.conf from mysql
/sbin/e-smith/fwconsole r

View File

@@ -0,0 +1,20 @@
#!/bin/bash
#version
version=$(/usr/bin/xmllint --xpath 'string(/module/version)' /opt/freepbx/admin/modules/backup/module.xml|cut -d. -f1)
#if version >=15
if [[ $version -ge 15 ]]
then
#backup id SELECT `id` FROM `kvstore_FreePBX_modules_Backup` WHERE `key` LIKE 'backup_name' and `val` LIKE 'Default-backup';
backupid=$(echo 'SELECT `id` FROM `kvstore_FreePBX_modules_Backup` WHERE `key` LIKE "backup_name" and `val` LIKE "Default-backup"'| mysql -u root freepbxdb -s)
#if backupid empty need to set one of manually backup something
if [ -z $backupid ] ; then
echo "missing backupid, we create the db entries"
/etc/e-smith/events/actions/freepbx-checkinstall-backup pre-backup
fi
echo "backup for freepbx version 15 or above"
/usr/sbin/fwconsole bu --backup $backupid 1>/dev/null
else
echo "backup for freepbx version 14 or below"
su asterisk -s /bin/bash -c '/usr/sbin/php56 /var/lib/asterisk/bin/backup.php --id=1'
fi

View File

@@ -0,0 +1,130 @@
#!/bin/bash
DBNAME=$(/sbin/e-smith/db configuration getprop freepbx DbName)
DBUSER=$(/sbin/e-smith/db configuration getprop freepbx DbUser)
DBPASS=$(/sbin/e-smith/db configuration getprop freepbx DbPassword)
CDRDBNAME=$(/sbin/e-smith/db configuration getprop freepbx CdrDbName)
MANAGERPASSWORD=$(/sbin/e-smith/db configuration getprop freepbx ManagerPassword)
DomainName=$(/sbin/e-smith/db configuration get DomainName)
if [ $(mysqlshow | grep -c $DBNAME) -lt 1 ]; then
mysql -e "create database $DBNAME CHARACTER SET utf8 COLLATE utf8_unicode_ci ;"
mysql -e "grant all privileges on $DBNAME.* to '$DBUSER'@'localhost' identified by '$DBPASS';"
mysql -e 'flush privileges;'
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 [ $(mysqlshow | grep -c $CDRDBNAME) -lt 1 ]; then
mysql -e "create database $CDRDBNAME CHARACTER SET utf8 COLLATE utf8_unicode_ci ;"
mysql -e "grant all privileges on $CDRDBNAME.* to '$DBUSER'@'localhost' identified by '$DBPASS';"
mysql -e 'flush privileges;'
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
# set user and passwords
/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 ');"
# Chown dir to allow user asterisk to create its files
chown asterisk:asterisk /var/lib/asterisk
# workaround as freepbx is expecting them in /var not /usr/share
cd /var/lib/asterisk
if [[ ! -d /var/lib/asterisk/documentation ]]; then ln -s /usr/share/asterisk/documentation ; fi
if [[ ! -d /var/lib/asterisk/moh ]]; then ln -s /usr/share/asterisk/moh ; fi
if [[ ! -d /var/lib/asterisk/sounds ]]; then ln -s /usr/share/asterisk/sounds/ ; fi
mkdir -p /usr/share/asterisk/sounds/tmp
chown asterisk: /usr/share/asterisk/sounds/tmp
chown asterisk: /usr/share/asterisk/sounds/ /usr/share/asterisk/moh
# Run the install script only if it's a new install
# Upgrades have to be done through freePBX and the online repository
if [ ! -d /opt/freepbx/admin ]; then
mkdir -p /opt/freepbx
# we need the right php version available
version=$(/usr/bin/rpm -q freepbx-src --qf "%{version}"|cut -d. -f1)
php="/usr/bin/php56"
if [[ $version -ge 16 ]]
then
php="/usr/bin/php74"
elif [[ $version -le 15 ]]
then
php="/usr/bin/php56"
fi
ln -sf $php /usr/sbin/php
ln -sf $php /usr/local/sbin/php
if [ -e /usr/share/freepbx/sources/freepbx/ ]; then
cd /usr/share/freepbx/sources/freepbx/
echo "Starting Asterisk..." > /root/freepbx_install.log
./start_asterisk start >> /root/freepbx_install.log 2>&1
echo "" >> /root/freepbx_install.log
echo "Installing FreePBX..." >> /root/freepbx_install.log
echo "a" |$php --define sys_temp_dir=/var/spool/asterisk/tmp/ --define allow_url_fopen=1 --define memory_limit=256M /usr/share/freepbx/sources/freepbx/install --webroot="/opt/freepbx" \
--dbengine="mysql" --dbname="freepbxdb" --dbuser="freepbxuser" --dbpass="$DBPASS" -n \
--cdrdbname="$CDRDBNAME" --astmoddir=/usr/lib64/asterisk/modules/ \
--astagidir=/usr/share/asterisk/agi-bin/ --ampsbin=/usr/sbin --ampcgibin=/opt/freepbx/cgi-bin \
>> /root/freepbx_install.log 2>&1
else
echo "error: /usr/share/freepbx/sources/freepbx/ doesn't exists"
exit 1
fi
else
if [ -x /var/lib/asterisk/bin/freepbx_engine ]; then
/var/lib/asterisk/bin/freepbx_engine chown > /dev/null 2>&1
else
echo "error: /var/lib/asterisk/bin/freepbx_engine is not executable"
exit 1
fi
if [ -x /var/lib/asterisk/bin/retrieve_conf ]; then
/var/lib/asterisk/bin/retrieve_conf > /dev/null 2>&1
else
echo "error: /var/lib/asterisk/bin/freepbx_engine is not executable"
exit 1
fi
fi
if [ ! -d /opt/freepbx/digium_phones ]; then
mkdir -p /opt/freepbx/digium_phones
chown asterisk:asterisk /opt/freepbx/digium_phones
fi
#change the links to get the right php
ln -sf /usr/sbin/e-smith/fwconsole /usr/sbin/fwconsole
ln -sf /usr/sbin/e-smith/fwconsole /usr/local/sbin/fwconsole
version=$(/usr/bin/xmllint --xpath 'string(/module/version)' /opt/freepbx/admin/modules/core/module.xml|cut -d. -f1)
php="56"
if [[ $version -ge 16 ]]
then
#version we have is not fully compatible, need newer source
php="74"
elif [[ $version -le 15 ]]
then
php="56"
fi
forcephp=$(/sbin/e-smith/db configuration getprop freepbx PHPVersion 2>/dev/null || echo $php )
php=$forcephp
ln -sf /usr/bin/php$php /usr/sbin/php
ln -sf /usr/bin/php$php /usr/local/sbin/php
# update modules
/usr/sbin/e-smith/fwconsole ma upgrade framework 2>/dev/null
/usr/sbin/e-smith/fwconsole ma upgrade core 2>/dev/null
/usr/sbin/e-smith/fwconsole ma upgradeall -R standard -R extended 2>/dev/null
/usr/sbin/e-smith/fwconsole ma refreshsignatures 2>/dev/null
/usr/sbin/e-smith/fwconsole ma downloadinstall userman certman arimanager 2>/dev/null
/usr/sbin/e-smith/fwconsole ma downloadinstall ucp 2>/dev/null
exit 0

View File

@@ -0,0 +1,211 @@
#!/bin/sh
DBNAME=$(/sbin/e-smith/db configuration getprop freepbx DbName)
backuppath='/home/e-smith/files/freepbx'
# check if backup module is local, enabled and running
# if not solve this...
if [[ ! `/usr/sbin/fwconsole ma list|/bin/grep backup` ]] ;then
/usr/sbin/fwconsole ma download backup -R standard -R extended >/dev/null 2>&1
fi
#force install
/usr/sbin/fwconsole ma install backup -R standard -R extended >/dev/null 2>&1
# force enable
/usr/sbin/fwconsole ma enable backup >/dev/null 2>&1
/usr/sbin/fwconsole r >/dev/null
# check our freepbx backup folder is there and accessible
if [[ ! -d $backuppath ]] ; then
/bin/mkdir -p $backuppath
fi
version=$(/usr/bin/xmllint --xpath 'string(/module/version)' /opt/freepbx/admin/modules/backup/module.xml|cut -d. -f1)
#if version >=15
if [[ $version -ge 15 ]]
then
############
# FILE STORE
############
# check local space is defined, if not do it kvstore_FreePBX_modules_Filestore
filestore=$(echo 'SELECT `id` FROM `kvstore_FreePBX_modules_Filestore` WHERE `key` LIKE "path" and `val` LIKE "/home/e-smith/files/freepbx/"'| mysql -u root freepbxdb -s)
if [ -z $filestore ] ; then
filestore=$(/usr/bin/uuidgen)
echo "creating new filestore id $filestore"
else
echo "filestore $filestore will be used"
fi
# we need existing servers value to update it
servers=$(echo 'SELECT `val` FROM `kvstore_FreePBX_modules_Filestore` WHERE `key` LIKE "servers" and `id` LIKE "noid"'| mysql -u root freepbxdb -s)
servers=$(echo $servers| jq '. |= . + {"'$filestore'" : { "id": "'$filestore'","name": "Local Storage","desc": "Storage location for backups", "driver": "Local" }}')
mysql -e "use $DBNAME; INSERT INTO \`kvstore_FreePBX_modules_Filestore\` (\`key\`, \`val\`, \`type\`, \`id\`) VALUES
('servers', '$servers', 'json-arr', 'noid')
ON DUPLICATE KEY UPDATE val=VALUES(val);"
mysql -e "use $DBNAME; INSERT INTO \`kvstore_FreePBX_modules_Filestore\` (\`key\`, \`val\`, \`type\`, \`id\`) VALUES
('name', 'Local Storage', NULL, '$filestore'),
('desc', 'Storage location for backups', NULL, '$filestore'),
('path', '/home/e-smith/files/freepbx/', NULL, '$filestore'),
('immortal', 'true', NULL, '$filestore'),
('driver', 'Local', NULL, '$filestore')
ON DUPLICATE KEY UPDATE val=VALUES(val);"
###########
# BACKUP
###########
# check Default-backup exists, if not set it, else update it
backupid=$(echo 'SELECT `id` FROM `kvstore_FreePBX_modules_Backup` WHERE `key` LIKE "backup_name" and `val` LIKE "Default-backup"'| mysql -u root freepbxdb -s)
if [ -z $backupid ] ; then
backupid=$(/usr/bin/uuidgen)
echo "creating new backup id $backupid"
mysql -e "use $DBNAME; CREATE TABLE IF NOT EXISTS \`kvstore_FreePBX_modules_Backup\` (
\`key\` char(255) NOT NULL,
\`val\` varchar(4096) DEFAULT NULL,
\`type\` char(16) DEFAULT NULL,
\`id\` char(255) DEFAULT NULL,
UNIQUE KEY \`uniqueindex\` (\`key\`(190),\`id\`(190)),
KEY \`keyindex\` (\`key\`(190)),
KEY \`idindex\` (\`id\`(190))
) ENGINE=InnoDB DEFAULT CHARSET=utf8;"
##TODO SELECT * FROM `kvblobstore` WHERE `uuid` LIKE 'a9fe727b-fc4c-40c4-ad45-bcabd075302a'
### TODO : list modules enabled and populate
blobstore=$(/usr/bin/uuidgen)
mysql -e "use $DBNAME;INSERT INTO kvstore_FreePBX_modules_Backup (\`key\`, \`val\`, \`type\`, \`id\`) VALUES
('backup_items', '$blobstore', 'blob', '$backupid')
ON DUPLICATE KEY UPDATE val=VALUES(val);"
# create an empty blob store, it seems to not be a problem to actually run the backup
mysql -e "use $DBNAME;INSERT INTO kvblobstore (\`uuid\`, \`type\`, \`content\`) VALUES
('$blobstore', NULL, '');" || exit 1
# we do this only if the other did not failed to avoid hitting one existing uuid
mysql -e "use $DBNAME;INSERT INTO kvstore_FreePBX_modules_Backup (\`key\`, \`val\`, \`type\`, \`id\`) VALUES
('backup_items', '$blobstore', 'blob', '$backupid')
ON DUPLICATE KEY UPDATE val=VALUES(val);"
else
echo "Updating backup $backupid"
fi
mysql -e "use $DBNAME;INSERT INTO kvstore_FreePBX_modules_Backup (\`key\`, \`val\`, \`type\`, \`id\`) VALUES
('backup_name', 'Default-backup', NULL, '$backupid'),
('backup_description', 'Default SME PBX backup; automatically installed', NULL, '$backupid'),
('backup_email', 'admin', NULL, '$backupid'),
('created_by', 'SME Server Event', NULL, '$backupid'),
('desc', 'Default SME PBX backup; automatically installed', NULL, '$backupid'),
('warmspare_remoteip', '', NULL, '$backupid'),
('warmspare_user', '', NULL, '$backupid'),
('maintruns', '2', NULL, '$backupid'),
('backup_emailtype', 'failure', NULL, '$backupid'),
('backup_schedule', '31 5 * * 0', NULL, '$backupid'),
('schedule_enabled', 'yes', NULL, '$backupid'),
('backup_storage', '[\\\"Local_$filestore\\\"]', 'json-arr', '$backupid'),
('backup_items', 'a9fe727b-fc4c-40c4-ad45-bcabd075302a', 'blob', '$backupid'),
('maintage', 'Unlimited', NULL, '$backupid'),
('backup_emailinline', '', NULL, '$backupid'),
('backup_addbjname', 'yes', NULL, '$backupid'),
('warmspareenabled', 'on', NULL, '$backupid'),
('warmspare_remotenat', 'on', NULL, '$backupid'),
('warmspare_cert', 'on', NULL, '$backupid'),
('warmspare_remotebind', 'on', NULL, '$backupid'),
('warmspare_remotedns', 'on', NULL, '$backupid'),
('warmspare_remoteapply', 'on', NULL, '$backupid'),
('publickey', '', NULL, '$backupid'),
('warmsparewayofrestore', 'API', NULL, '$backupid'),
('warmspare_remoteapi_filestoreid', '', NULL, '$backupid'),
('warmspare_remoteapi_accesstoken', '', NULL, '$backupid'),
('warmspare_remoteapi_accesstokenurl', '', NULL, '$backupid'),
('warmspare_remoteapi_accesstoken_expire', '', NULL, '$backupid'),
('warmspare_remoteapi_clientid', '', NULL, '$backupid'),
('warmspare_remoteapi_secret', '', NULL, '$backupid'),
('warmspare_remoteapi_gql', '', NULL, '$backupid'),
('warmspare_excludetrunks', 'on', NULL, '$backupid'),
('warmspare_remotessh_filestoreid', '', NULL, '$backupid'),
('custom_files', '[{\"type\":\"dir\",\"path\":\"__ASTETCDIR__\",\"exclude\":[]}]', NULL, '$backupid'),
('prebu_hook', '', NULL, '$backupid'),
('postbu_hook', '', NULL, '$backupid'),
('prere_hook', '', NULL, '$backupid'),
('postre_hook', '', NULL, '$backupid'),
('core_disabletrunks', '', NULL, '$backupid'),
('$backupid', '{\\\"id\\\":\\\"$backupid\\\",\\\"name\\\":\\\"Default-backup\\\",\\\"description\\\":\\\"Default SME PBX backup; automatically installed\\\"}', 'json-arr', 'backupList'),
('bu_1', '{\\\"id\\\":\\\"1\\\",\\\"name\\\":\\\"Default backup\\\",\\\"description\\\":\\\"Default SME PBX backup; automatically installed\\\",\\\"immortal\\\":\\\"true\\\",\\\"data\\\":{\\\"created_by\\\":\\\"install.php\\\",\\\"desc\\\":\\\"Default SME PBX backup; automatically installed\\\",\\\"cron_schedule\\\":\\\"weekly\\\",\\\"storage_servers\\\":[\\\"1\\\"],\\\"bu_server\\\":\\\"0\\\",\\\"delete_amount\\\":\\\"2\\\",\\\"delete_time_type\\\":\\\"days\\\",\\\"cron_random\\\":\\\"on\\\",\\\"cron_month\\\":\\\"\\\",\\\"cron_minute\\\":\\\"0\\\",\\\"cron_hour\\\":\\\"0\\\",\\\"cron_dow\\\":\\\"0\\\",\\\"cron_dom\\\":\\\"\\\",\\\"delete_time\\\":\\\"0\\\",\\\"email\\\":\\\"admin\\\",\\\"emailfailonly\\\":\\\"1\\\"},\\\"email\\\":\\\"admin\\\",\\\"uuid\\\":\\\"$backupid\\\",\\\"items\\\":[{\\\"backup_id\\\":\\\"1\\\",\\\"type\\\":\\\"mysql\\\",\\\"path\\\":\\\"server-2\\\",\\\"exclude\\\":[]},{\\\"backup_id\\\":\\\"1\\\",\\\"type\\\":\\\"astdb\\\",\\\"path\\\":\\\"astdb\\\",\\\"exclude\\\":[]},{\\\"backup_id\\\":\\\"1\\\",\\\"type\\\":\\\"dir\\\",\\\"path\\\":\\\"\\/etc\\/dahdi\\\",\\\"exclude\\\":[]},{\\\"backup_id\\\":\\\"1\\\",\\\"type\\\":\\\"dir\\\",\\\"path\\\":\\\"__ASTSPOOLDIR__\\/voicemail\\\",\\\"exclude\\\":[]},{\\\"backup_id\\\":\\\"1\\\",\\\"type\\\":\\\"mysql\\\",\\\"path\\\":\\\"server-3\\\",\\\"exclude\\\":[]},{\\\"backup_id\\\":\\\"1\\\",\\\"type\\\":\\\"dir\\\",\\\"path\\\":\\\"__ASTETCDIR__\\\",\\\"exclude\\\":[]},{\\\"backup_id\\\":\\\"1\\\",\\\"type\\\":\\\"dir\\\",\\\"path\\\":\\\"__AMPWEBROOT__\\\",\\\"exclude\\\":[]},{\\\"backup_id\\\":\\\"1\\\",\\\"type\\\":\\\"dir\\\",\\\"path\\\":\\\"__AMPBIN__\\\",\\\"exclude\\\":[]},{\\\"backup_id\\\":\\\"1\\\",\\\"type\\\":\\\"dir\\\",\\\"path\\\":\\\"\\/tftpboot\\\",\\\"exclude\\\":[]}]}', 'json-arr', 'migratedbackups'),
('arimanager', '1', NULL, 'modules_$backupid'),
('backup', '1', NULL, 'modules_$backupid'),
('blacklist', '1', NULL, 'modules_$backupid'),
('callrecording', '1', NULL, 'modules_$backupid'),
('cdr', '1', NULL, 'modules_$backupid'),
('cel', '1', NULL, 'modules_$backupid'),
('certman', '1', NULL, 'modules_$backupid'),
('cidlookup', '1', NULL, 'modules_$backupid'),
('conferences', '1', NULL, 'modules_$backupid'),
('core', '1', NULL, 'modules_$backupid'),
('customappsreg', '1', NULL, 'modules_$backupid'),
('dashboard', '1', NULL, 'modules_$backupid'),
('fax', '1', NULL, 'modules_$backupid'),
('filestore', '1', NULL, 'modules_$backupid'),
('findmefollow', '1', NULL, 'modules_$backupid'),
('framework', '1', NULL, 'modules_$backupid'),
('infoservices', '1', NULL, 'modules_$backupid'),
('ivr', '1', NULL, 'modules_$backupid'),
('languages', '1', NULL, 'modules_$backupid'),
('logfiles', '1', NULL, 'modules_$backupid'),
('manager', '1', NULL, 'modules_$backupid'),
('music', '1', NULL, 'modules_$backupid'),
('phonebook', '1', NULL, 'modules_$backupid'),
('pm2', '1', NULL, 'modules_$backupid'),
('recordings', '1', NULL, 'modules_$backupid'),
('ringgroups', '1', NULL, 'modules_$backupid'),
('sipsettings', '1', NULL, 'modules_$backupid'),
('soundlang', '1', NULL, 'modules_$backupid'),
('ucp', '1', NULL, 'modules_$backupid'),
('userman', '1', NULL, 'modules_$backupid'),
('voicemail', '1', NULL, 'modules_$backupid')
ON DUPLICATE KEY UPDATE val=VALUES(val);"
# TODO update
#mysql -e "use $DBNAME;INSERT INTO kvstore_FreePBX_modules_Backup (\`key\`, \`val\`, \`type\`, \`id\`) VALUES
#('backup_items', 'a9fe727b-fc4c-40c4-ad45-bcabd075302a', 'blob', '$backupid')
#ON DUPLICATE KEY UPDATE val=VALUES(val);"
elif [[ $version -lt 15 ]] ; then
# set first backup as the one for SME way
# set destination
mysql -e "use $DBNAME;UPDATE backup_server_details set value = '/home/e-smith/files/freepbx' WHERE server_id = 1;"
# set info for backup 1
#data = a:1:{s:10:"created_by";s:11:"install.php";}
mysql -e "use $DBNAME;INSERT INTO backup (\`id\`, \`name\`, \`description\` , \`immortal\` ,\`data\`, \`email\` ) VALUES (1, 'Default backup', 'Default SME PBX backup; automatically installed', 'true','', 'admin' ) ON DUPLICATE KEY UPDATE \`description\` = 'Default SME PBX backup; automatically installed', \`immortal\` = 'true', \`email\` = 'admin' , \`name\`= 'Default backup' ;" 2>/dev/null || mysql -e "use $DBNAME;INSERT INTO backup (\`id\`, \`name\`, \`emailaddr\` ) VALUES (1, 'SMEbackup', 'admin' ) ON DUPLICATE KEY UPDATE \`name\` = 'SMEbackup', \`emailaddr\` = 'admin' ;"
mysql -e "use $DBNAME;ALTER TABLE backup_details ADD UNIQUE uniq ( \`backup_id\` , \`key\` , \`index\` ) ;"
mysql -e "use $DBNAME;INSERT INTO backup_details (\`backup_id\`, \`key\`, \`index\`, \`value\`) VALUES
(1, 'delete_time_type', '', 'days'),
(1, 'delete_amount', '', '2'),
(1, 'desc', '', 'Default SME PBX backup; automatically installed'),
(1, 'cron_schedule', '', 'weekly'),
(1, 'cron_random', '', 'on'),
(1, 'cron_month', '', ''),
(1, 'cron_minute', '', '0'),
(1, 'cron_hour', '', '0'),
(1, 'cron_dow', '', '0'),
(1, 'cron_dom', '', ''),
(1, 'bu_server', '', '0'),
(1, 'delete_time', '', '0'),
(1, 'email', '', 'admin'),
(1, 'emailfailonly', '', '1'),
(1, 'storage_servers', '0', '1') ON DUPLICATE KEY UPDATE \`value\`=VALUES(\`value\`) ;"
mysql -e "use $DBNAME;ALTER TABLE backup_details DROP INDEX uniq;"
# set what to backup
mysql -e "use $DBNAME;ALTER TABLE backup_items ADD UNIQUE \`uniq\` ( \`backup_id\` , \`type\` , \`path\` ( 15 ) ) ;"
mysql -e "use freepbxdb;INSERT INTO backup_items (\`backup_id\`, \`type\`, \`path\`, \`exclude\`) VALUES
(1, 'dir', '/etc/dahdi', 'a:0:{}'),
(1, 'dir', '__ASTSPOOLDIR__/voicemail', 'a:0:{}'),
(1, 'mysql', 'server-2', 'a:0:{}'),
(1, 'astdb', 'astdb', 'a:0:{}'),
(1, 'mysql', 'server-3', 'a:0:{}'),
(1, 'dir', '__ASTETCDIR__', 'a:0:{}'),
(1, 'dir', '__AMPWEBROOT__', 'a:0:{}'),
(1, 'dir', '__AMPBIN__', 'a:0:{}'),
(1, 'dir', '/tftpboot', 'a:0:{}') ON DUPLICATE KEY UPDATE \`exclude\`=VALUES(\`exclude\`) ;";
mysql -e "use $DBNAME;ALTER TABLE backup_items DROP INDEX \`uniq\` ;"
fi
# make sure all perms are ok for backup
/usr/sbin/fwconsole chown > /dev/null 2>&1

View File

@@ -0,0 +1,20 @@
#/bin/bash
# Remove crontab entry automatically added by FreePBX
# as it generate an error (run as root before asterisk
# which means asterisk won't be allowed to open the debug
# file /tmp/freepbx_debug.log, and send a email to the admin
crontab -l > /tmp/freepbx_old_crontab
awk '$0!~/freepbx-cron-scheduler.php/ { print $0 }' /tmp/freepbx_old_crontab > /tmp/freepbx_new_crontab
crontab /tmp/freepbx_new_crontab
rm -f /tmp/freepbx_old_crontab
rm -f /tmp/freepbx_new_crontab
# Now change permissions on /tmp/freepbx_debug.log to be sure
# asterisk user has write permission
if [ -e /tmp/freepbx_debug.log ]; then
chown asterisk:asterisk /tmp/freepbx_debug.log
chmod 700 /tmp/freepbx_debug.log
fi

View File

@@ -0,0 +1,22 @@
#!/bin/bash
path='PATH=\/usr\/local\/sbin:\/usr\/local\/bin:\/usr\/sbin:\/usr\/bin:\/root\/bin'
cronfile='/var/spool/cron/asterisk'
[ ! -f $cronfile ] && exit 0
status=$(/sbin/e-smith/config getprop freepbx status || echo "disabled")
# add PATH to fist line if not present; else update it
sed -i "1!b;s/^PATH.*/$path/; t; 1i $path" $cronfile
# remove any other occurence of PATH
sed -i "1p;t; /^PATH.*/d" $cronfile
# check if freepbx enabled
if [[ $status == "enabled" ]]; then
# if enabled uncomment
sed -ri 's/^#(\@[a-zA-Z]+ .*|[0-9*]+ [0-9*]+ [0-9*]+ [0-9*]+ [0-9*]+ .*)/\1/' $cronfile
else
# if disabled comment out
sed -ri 's/^(\@[a-zA-Z]+ .*|[0-9*]+ [0-9*]+ [0-9*]+ [0-9*]+ [0-9*]+ .*)/#\1/' $cronfile
fi
#remove any duplicate entry
awk '!x[$0]++' ${cronfile} >${cronfile}-tmp && cat ${cronfile}-tmp > ${cronfile} && rm -f ${cronfile}-tmp

View File

@@ -0,0 +1,37 @@
#!/usr/bin/env php
<?php
// No use outputting anything, as env forces php headers to appear. Sigh.
function getconf($filename) {
$file = file($filename);
foreach ($file as $line) {
if (preg_match("/^\s*([\w]+)\s*=\s*\"?([\w\/\:\.\%-]*)\"?\s*([;#].*)?/",$line,$matches)) {
$conf[ $matches[1] ] = $matches[2];
}
}
return $conf;
}
$amp_conf = getconf("/etc/amportal.conf");
// Start quickly.
$bootstrap_settings['freepbx_auth'] = false; // Just in case.
$restrict_mods = true; // Takes startup from 0.2 seconds to 0.07 seconds.
include '/etc/freepbx.conf';
$astman = new AGI_AsteriskManager();
if (! $res = $astman->connect("127.0.0.1", $amp_conf["AMPMGRUSER"] , $amp_conf["AMPMGRPASS"])) {
unset( $astman );
}
@mkdir("/home/e-smith/db/freepbx/");
$fh = fopen("/home/e-smith/db/freepbx/astdb.dump", "w");
$astdb = $astman->database_show();
foreach ($astdb as $key => $val) {
if ($key == "") { continue; }
if ($key == "Privilege") { continue; }
fwrite($fh, "[$key] [$val]\n");
}
fclose($fh);
?>

View File

@@ -0,0 +1,4 @@
PERMS=0660
UID="root"
GID="asterisk"

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';
}
}
}

View File

@@ -0,0 +1,31 @@
#!/usr/bin/perl
#----------------------------------------------------------------------
# heading : Telephony
# description : FreePBX
# navigation : 4000 4200
#----------------------------------------------------------------------
use strict;
use CGI':all';
use CGI::Carp qw(fatalsToBrowser);
BEGIN
{
$ENV {'PATH'} = '/bin:/usr/bin:/sbin';
$ENV {'SHELL'} = '/bin/bash';
delete $ENV {'ENV'};
}
my $q = new CGI;
my $content="0; url=https://".$ENV {'HTTP_X_FORWARDED_HOST'}."/freepbx/admin";
$q->default_dtd('-//W3C//DTD XHTML 1.0 Transitional//EN');
print $q->header ('text/html');
print $q->start_html (-head=>meta({-http_equiv=>'refresh', -content=>$content}));
print $q->end_html;

View File