Rocky Linux 9安装Asterisk 20和freepbx 17脚本——筑梦之路

脚本搜集来自Rocky Linux 9安装Asterisk 20和freepbx 17脚本

bash 复制代码
#!/bin/bash

#Preparacion de ambiente de RockyLinux

echo "Deshabilitar SELINUX /etc/selinux/config "

sed -i s/^SELINUX=.*$/SELINUX=disabled/ /etc/selinux/config

echo "Establecer nombre de maquina"
hostnamectl set-hostname asterisk.local

echo "Instalar repositorio de paquetes adicionales"
/usr/bin/dnf -y install epel-release

/usr/bin/dnf -y update ca-certificates

/usr/bin/dnf makecache

echo "Habilitar repositorio de herramientas adicionales de desarrollo Code Ready Builder"
/usr/bin/dnf config-manager --set-enabled crb
/usr/bin/dnf group -y install "Development Tools" 
/usr/bin/dnf -y install git wget htop initscripts svn chkconfig mlocate nano

#Instalar PHP 8.3
/usr/bin/dnf install https://rpms.remirepo.net/enterprise/remi-release-9.rpm -y
/usr/bin/dnf module reset php
/usr/bin/dnf module install php:remi-8.3 -y

/usr/bin/dnf install httpd @php wget ncurses-devel sendmail sendmail-cf newt-devel libxml2-devel libtiff-devel gtk2-devel subversion kernel-devel git crontabs cronie cronie-anacron wget vim php-xml sqlite-devel net-tools gnutls-devel unixODBC php php-cli php-gd php-curl php-zip php-mbstring php-pear php-cgi php-common php-curl php-mbstring php-gd php-mysqlnd php-gettext php-bcmath php-zip php-xml  php-json php-process php-snmp nodejs sox -y

echo "Instalacion de BD"
dnf install mariadb-server unixODBC unixODBC-devel libtool-ltdl libtool-ltdl-devel mariadb-connector-odbc -y

echo "Actualizar sistema operativo"
/usr/bin/dnf -y update

systemctl start mariadb
systemctl enable mariadb

#/usr/bin/mysql_secure_installation

echo "Realizando hardenizacion de MYSQL"

mysql -sfu root <<EOS
USE mysql;
ALTER USER 'root'@'localhost' IDENTIFIED VIA mysql_native_password;
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('password');
DELETE FROM mysql.user WHERE User='';
DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1');
DROP DATABASE IF EXISTS test;
DELETE FROM mysql.db WHERE Db='test' OR Db='test\\_%';
FLUSH PRIVILEGES;
EOS

#Instalacion de Asterisk

echo "Instalando Asterisk"

echo "Configurando BD"

mysql -u root -ppassword -e "CREATE DATABASE asterisk;"
mysql -u root -ppassword -e "CREATE USER 'asterisk'@'%' IDENTIFIED BY 'password';"
mysql -u root -ppassword -e "CREATE DATABASE asterisk;"
mysql -u root -ppassword -e "GRANT ALL PRIVILEGES ON asterisk.* TO 'asterisk'@'%';"

#exit

odbcinst -q -d

#/etc/odbc.ini

echo "[asterisk-connector]
Description = MySQL connection to 'asterisk' database
Driver = MariaDB
Database = asterisk
Server = localhost
Port = 3306
Socket = /var/lib/mysql/mysql.sock" > /etc/odbc.ini

#isql -v asterisk-connector asterisk password
#quit

echo "Bajando archivos fuente"

mkdir /opt/asterisk/
cd /opt/asterisk/
wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-20-current.tar.gz
tar -xvf asterisk-20-current.tar.gz
cd /opt/asterisk/asterisk-20.*

echo "Configurando instalacion"



/opt/asterisk/asterisk-20.*/contrib/scripts/get_mp3_source.sh
/opt/asterisk/asterisk-20.*/contrib/scripts/install_prereq install
/opt/asterisk/asterisk-20.*/configure --libdir=/usr/lib64 --with-jansson-bundled=yes

#make menuselect
#Habilitar app_macro
make menuselect.makeopts
menuselect/menuselect --enable app_macro menuselect.makeopts

echo "Compilando binarios"

make
make install
make basic-pbx
make config

echo "Configurando usuarios y permisos"

groupadd asterisk
useradd -r -d /var/lib/asterisk -g asterisk asterisk
chown -R asterisk:asterisk /etc/asterisk /var/{lib,log,spool}/asterisk /usr/lib64/asterisk
restorecon -vr {/etc/asterisk,/var/lib/asterisk,/var/log/asterisk,/var/spool/asterisk}

sed -i 's/#AST_USER="asterisk"/AST_USER="asterisk"/g' /etc/sysconfig/asterisk
sed -i 's/#AST_GROUP="asterisk"/AST_GROUP="asterisk"/g' /etc/sysconfig/asterisk

sed -i 's/;runuser = asterisk/runuser = asterisk/g' /etc/asterisk/asterisk.conf
sed -i 's/;rungroup = asterisk/rungroup = asterisk/g' /etc/asterisk/asterisk.conf

echo '[directories](!)' >> /etc/asterisk/asterisk.conf
echo "astetcdir => /etc/asterisk" >> /etc/asterisk/asterisk.conf
echo "astmoddir => /usr/lib/asterisk/modules" >> /etc/asterisk/asterisk.conf
echo "astvarlibdir => /var/lib/asterisk" >> /etc/asterisk/asterisk.conf
echo "astdbdir => /var/lib/asterisk" >> /etc/asterisk/asterisk.conf
echo "astkeydir => /var/lib/asterisk" >> /etc/asterisk/asterisk.conf
echo "astdatadir => /var/lib/asterisk" >> /etc/asterisk/asterisk.conf
echo "astagidir => /var/lib/asterisk/agi-bin" >> /etc/asterisk/asterisk.conf
echo "astspooldir => /var/spool/asterisk" >> /etc/asterisk/asterisk.conf
echo "astrundir => /var/run/asterisk" >> /etc/asterisk/asterisk.conf
echo "astlogdir => /var/log/asterisk" >> /etc/asterisk/asterisk.conf
echo "astsbindir => /usr/sbin" >> /etc/asterisk/asterisk.conf

setenforce 0

echo "Configurando firewall"

firewall-cmd --zone=public --add-service sip --permanent
firewall-cmd --zone=public --add-port=10000-20000/udp --permanent

systemctl enable asterisk

systemctl start asterisk

#Instalacion de FREEPBX

echo "Instalacion de FREEPBX"

echo "Bajando archivos fuente"

mkdir -p /opt/freepbx
cd /opt/freepbx/
wget http://mirror.freepbx.org/modules/packages/freepbx/freepbx-17.0-latest-EDGE.tgz
tar -xvf freepbx-*.tgz
cd freepbx

echo "Instalando dependencias"

echo "Configurando usuarios y permisos"

chown -R asterisk:asterisk /var/www/*

sed -i 's/\(^upload_max_filesize = \).*/\120M/' /etc/php.ini
sed -i 's/\(^memory_limit = \).*/\1256M/' /etc/php.ini
sed -i 's/^\(User\|Group\).*/\1 asterisk/' /etc/httpd/conf/httpd.conf
sed -i 's/AllowOverride None/AllowOverride All/' /etc/httpd/conf/httpd.conf
sed -i 's/\(^user = \).*/\1asterisk/' /etc/php-fpm.d/www.conf
sed -i 's/\(^group = \).*/\1asterisk/' /etc/php-fpm.d/www.conf

sed -i 's/\(^listen.acl_users = apache,nginx\).*/\1,asterisk/' /etc/php-fpm.d/www.conf

echo "Habilitando servicios"

systemctl enable httpd
systemctl start httpd
firewall-cmd --add-service={http,https}  --permanent
firewall-cmd --reload

echo "Instalando FreePBX desde el instalador"

/opt/freepbx/freepbx/install -n --dbuser root --dbpass password

echo "FreePBX Instalado"

IPADRESS=$(ip addr show $(ip route | awk '/default/ { print $5 }') | grep "inet" | head -n 1 | awk '/inet/ {print $2}' | cut -d'/' -f1)

echo "Reiniciando, favor de ir a la interfaz web en tu navegador para usar FreePBX. http://$IPADRESS "
echo "Rebooting, please go to web interface in your browser to start using FreePBX. http://$IPADRESS "

reboot

脚本项目地址:

https://gist.github.com/mafairnet/87c9afddda60518f26e83b28fd8bb6ca

电子书参考资料:

www.freepbx.cn

www.asterisk.org.cn

https://www.wilivm.com/blog/almalinux-vs-rocky-linux-key-differences/

相关推荐
秦jh_4 分钟前
【Linux】多线程(概念,控制)
linux·运维·前端
yaosheng_VALVE24 分钟前
稀硫酸介质中 V 型球阀的材质选择与选型要点-耀圣
运维·spring cloud·自动化·intellij-idea·材质·1024程序员节
看山还是山,看水还是。1 小时前
Redis 配置
运维·数据库·redis·安全·缓存·测试覆盖率
扣得君1 小时前
C++20 Coroutine Echo Server
运维·服务器·c++20
keep__go1 小时前
Linux 批量配置互信
linux·运维·服务器·数据库·shell
矛取矛求2 小时前
Linux中给普通账户一次性提权
linux·运维·服务器
Fanstay9852 小时前
在Linux中使用Nginx和Docker进行项目部署
linux·nginx·docker
大熊程序猿2 小时前
ubuntu 安装kafka-eagle
linux·ubuntu·kafka
jieshenai2 小时前
使用VSCode远程连接服务器并解决Neo4j无法登陆问题
服务器·vscode·neo4j
渗透测试老鸟-九青2 小时前
通过投毒Bingbot索引挖掘必应中的存储型XSS
服务器·前端·javascript·安全·web安全·缓存·xss