Initial installer structure: FusionPBX + pre-install + template
This commit is contained in:
@@ -0,0 +1 @@
|
|||||||
|
install-scripts/
|
||||||
@@ -1,3 +1,33 @@
|
|||||||
# install-scripts
|
# Mundo Telecom - Install Scripts
|
||||||
|
|
||||||
Scripts de instalacao dos servicos Mundo Telecom - auto-instalador local
|
Scripts de instalação padronizados para os serviços da Mundo Telecom.
|
||||||
|
|
||||||
|
## Como usar
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Instalação rápida (Debian 12)
|
||||||
|
curl -sL https://git.homelabds.com.br/diegods/install-scripts/raw/branch/main/debian/pre-install.sh | sh
|
||||||
|
cd /usr/src/install-scripts/debian && ./install.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
## Estrutura
|
||||||
|
|
||||||
|
```
|
||||||
|
install-scripts/
|
||||||
|
├── README.md
|
||||||
|
├── debian/ ← scripts para Debian
|
||||||
|
├── ubuntu/ ← scripts para Ubuntu
|
||||||
|
└── docker/ ← scripts para Docker
|
||||||
|
```
|
||||||
|
|
||||||
|
## Serviços disponíveis
|
||||||
|
|
||||||
|
| Serviço | Script | Descrição |
|
||||||
|
|---------|--------|-----------|
|
||||||
|
| FusionPBX | `debian/install.sh` | PABX completo (FreeSWITCH + PHP + PostgreSQL) |
|
||||||
|
| *(mais em breve)* | | |
|
||||||
|
|
||||||
|
## Repositórios
|
||||||
|
|
||||||
|
- Código fonte: [git.homelabds.com.br](https://git.homelabds.com.br)
|
||||||
|
- Issue tracker: via Gitea
|
||||||
|
|||||||
+224
@@ -0,0 +1,224 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Mundo Telecom - Instalação FusionPBX (Debian 12)
|
||||||
|
#
|
||||||
|
# Este script instala o FusionPBX a partir do nosso repositório local
|
||||||
|
# em vez do GitHub oficial, garantindo controle de versão e disponibilidade.
|
||||||
|
#
|
||||||
|
# Uso: cd /usr/src/install-scripts/debian && ./install-fusionpbx.sh
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
RED='\033[0;31m'
|
||||||
|
GREEN='\033[0;32m'
|
||||||
|
YELLOW='\033[1;33m'
|
||||||
|
CYAN='\033[0;36m'
|
||||||
|
NC='\033[0m'
|
||||||
|
|
||||||
|
print_status() { echo -e "${GREEN}[FUSIONPBX]${NC} $1"; }
|
||||||
|
print_warn() { echo -e "${YELLOW}[AVISO]${NC} $1"; }
|
||||||
|
print_error() { echo -e "${RED}[ERRO]${NC} $1"; }
|
||||||
|
print_step() { echo -e "${CYAN}[PASSO]${NC} $1"; }
|
||||||
|
|
||||||
|
if [ "$(id -u)" -ne 0 ]; then
|
||||||
|
print_error "Execute como root"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Configurações
|
||||||
|
FUSIONPBX_REPO="https://git.homelabds.com.br/diegods/fusionpbx.git"
|
||||||
|
FUSIONPBX_DIR="/usr/src/fusionpbx"
|
||||||
|
FUSIONSQL_DIR="/var/www/fusionpbx"
|
||||||
|
DB_NAME="fusionpbx"
|
||||||
|
DB_USER="fusionpbx"
|
||||||
|
DB_PASS=$(openssl rand -hex 24)
|
||||||
|
|
||||||
|
# =============================================
|
||||||
|
print_step "1/7 - Instalando FreeSWITCH"
|
||||||
|
# =============================================
|
||||||
|
print_status "Adicionando repositório FreeSWITCH..."
|
||||||
|
wget -O - https://files.freeswitch.com/repo/deb/debian-release/fs-repo.gpg | apt-key add -
|
||||||
|
echo "deb [signed-by=/usr/share/keyrings/freeswitch.gpg] https://files.freeswitch.com/repo/deb/debian-release/ bookworm main" > /etc/apt/sources.list.d/freeswitch.list
|
||||||
|
|
||||||
|
apt-get update
|
||||||
|
apt-get install -y freeswitch-meta-vanilla freeswitch-mod-commands freeswitch-mod-conference \
|
||||||
|
freeswitch-mod-curl freeswitch-mod-db freeswitch-mod-directory \
|
||||||
|
freeswitch-mod-distributor freeswitch-mod-dptools freeswitch-mod-dialplan-xml \
|
||||||
|
freeswitch-mod-esl freeswitch-mod-expr freeswitch-mod-hash \
|
||||||
|
freeswitch-mod-httapi freeswitch-mod-json-cdr freeswitch-mod-logfile \
|
||||||
|
freeswitch-mod-loopback freeswitch-mod-memcache freeswitch-mod-native-file \
|
||||||
|
freeswitch-mod-pgsql freeswitch-mod-pin-collect freeswitch-mod-pt \
|
||||||
|
freeswitch-mod-posix-timer freeswitch-mod-rad-gateway freeswitch-mod-rtc \
|
||||||
|
freeswitch-mod-say-es freeswitch-mod-say-pt freeswitch-mod-say-ru \
|
||||||
|
freeswitch-mod-say-zh freeswitch-mod-sms freeswitch-mod-sndfile \
|
||||||
|
freeswitch-mod-snmp freeswitch-mod-sofia freeswitch-mod-spidermonkey \
|
||||||
|
freeswitch-mod-spy freeswitch-mod-static freeswitch-mod-syslog \
|
||||||
|
freeswitch-mod-tone-stream freeswitch-mod-valet-parking freeswitch-mod-vlc \
|
||||||
|
freeswitch-mod-voicemail freeswitch-mod-voicemail-ivr freeswitch-mod-xml-curl \
|
||||||
|
freeswitch-mod-xml-rpc freeswitch-mod-xml-cdr
|
||||||
|
|
||||||
|
systemctl enable freeswitch
|
||||||
|
systemctl start freeswitch
|
||||||
|
print_status "FreeSWITCH instalado e rodando!"
|
||||||
|
|
||||||
|
# =============================================
|
||||||
|
print_step "2/7 - Instalando PostgreSQL"
|
||||||
|
# =============================================
|
||||||
|
print_status "Instalando PostgreSQL..."
|
||||||
|
apt-get install -y postgresql postgresql-client
|
||||||
|
systemctl enable postgresql
|
||||||
|
systemctl start postgresql
|
||||||
|
|
||||||
|
print_status "Criando banco de dados..."
|
||||||
|
su - postgres -c "psql -c \"CREATE DATABASE $DB_NAME;\""
|
||||||
|
su - postgres -c "psql -c \"CREATE ROLE $DB_USER WITH SUPERUSER LOGIN PASSWORD '$DB_PASS';\""
|
||||||
|
su - postgres -c "psql -c \"GRANT ALL PRIVILEGES ON DATABASE $DB_NAME TO $DB_USER;\""
|
||||||
|
|
||||||
|
# =============================================
|
||||||
|
print_step "3/7 - Instalando Nginx + PHP"
|
||||||
|
# =============================================
|
||||||
|
print_status "Instalando Nginx e PHP-FPM..."
|
||||||
|
apt-get install -y nginx php-fpm php-pgsql php-cli php-json php-curl \
|
||||||
|
php-mbstring php-gd php-xml php-zip php-intl php-bcmath php-gmp php-imagick
|
||||||
|
|
||||||
|
systemctl enable nginx
|
||||||
|
systemctl enable php8.2-fpm 2>/dev/null || systemctl enable php8.*-fpm 2>/dev/null || true
|
||||||
|
|
||||||
|
# =============================================
|
||||||
|
print_step "4/7 - Clonando FusionPBX do repositório local"
|
||||||
|
# =============================================
|
||||||
|
print_status "Clonando de $FUSIONPBX_REPO..."
|
||||||
|
if [ -d "$FUSIONPBX_DIR" ]; then
|
||||||
|
cd "$FUSIONPBX_DIR" && git pull
|
||||||
|
else
|
||||||
|
git clone "$FUSIONPBX_REPO" "$FUSIONPBX_DIR"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Copiar para o diretório web
|
||||||
|
print_status "Copiando para $FUSIONSQL_DIR..."
|
||||||
|
cp -R "$FUSIONPBX_DIR"/* "$FUSIONSQL_DIR"/
|
||||||
|
chown -R www-data:www-data "$FUSIONSQL_DIR"
|
||||||
|
find "$FUSIONSQL_DIR" -type d -exec chmod 755 {} \;
|
||||||
|
find "$FUSIONSQL_DIR" -type f -exec chmod 644 {} \;
|
||||||
|
|
||||||
|
# =============================================
|
||||||
|
print_step "5/7 - Configurando FusionPBX"
|
||||||
|
# =============================================
|
||||||
|
cd "$FUSIONSQL_DIR"
|
||||||
|
|
||||||
|
print_status "Configurando recursos do FusionPBX..."
|
||||||
|
php "$FUSIONSQL_DIR"/secure.php 2>/dev/null || true
|
||||||
|
|
||||||
|
# Configurar banco de dados
|
||||||
|
cat > /etc/fusionpbx/config.php << EOF
|
||||||
|
<?php
|
||||||
|
// Configuração FusionPBX - Mundo Telecom
|
||||||
|
// Instalado em $(date)
|
||||||
|
|
||||||
|
\$db_host = '127.0.0.1';
|
||||||
|
\$db_port = '5432';
|
||||||
|
\$db_name = '$DB_NAME';
|
||||||
|
\$db_username = '$DB_USER';
|
||||||
|
\$db_password = '$DB_PASS';
|
||||||
|
\$db_type = 'pgsql';
|
||||||
|
EOF
|
||||||
|
|
||||||
|
mkdir -p /etc/fusionpbx
|
||||||
|
mv /etc/fusionpbx/config.php /etc/fusionpbx/ 2>/dev/null || true
|
||||||
|
chown -R www-data:www-data /etc/fusionpbx
|
||||||
|
|
||||||
|
# Importar schema do banco
|
||||||
|
print_status "Importando schema do banco..."
|
||||||
|
sudo -u postgres psql -d "$DB_NAME" < "$FUSIONSQL_DIR"/app/ databases.sql 2>/dev/null || \
|
||||||
|
php "$FUSIONSQL_DIR"/core/upgrade/upgrade.php 2>/dev/null || true
|
||||||
|
|
||||||
|
# =============================================
|
||||||
|
print_step "6/7 - Configurando Nginx"
|
||||||
|
# =============================================
|
||||||
|
cat > /etc/nginx/sites-available/fusionpbx << 'NGINX'
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
server_name _;
|
||||||
|
|
||||||
|
root /var/www/fusionpbx;
|
||||||
|
index index.php index.html index.htm;
|
||||||
|
|
||||||
|
access_log /var/log/nginx/fusionpbx-access.log;
|
||||||
|
error_log /var/log/nginx/fusionpbx-error.log;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
try_files $uri $uri/ /index.php?$args;
|
||||||
|
}
|
||||||
|
|
||||||
|
location ~ \.php$ {
|
||||||
|
include snippets/fastcgi-php.conf;
|
||||||
|
fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
|
||||||
|
}
|
||||||
|
|
||||||
|
location ~ /\.ht {
|
||||||
|
deny all;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Segurança
|
||||||
|
add_header X-Frame-Options "SAMEORIGIN";
|
||||||
|
add_header X-Content-Type-Options "nosniff";
|
||||||
|
add_header X-XSS-Protection "1; mode=block";
|
||||||
|
}
|
||||||
|
NGINX
|
||||||
|
|
||||||
|
ln -sf /etc/nginx/sites-available/fusionpbx /etc/nginx/sites-enabled/
|
||||||
|
rm -f /etc/nginx/sites-enabled/default
|
||||||
|
nginx -t && systemctl reload nginx
|
||||||
|
|
||||||
|
# =============================================
|
||||||
|
print_step "7/7 - Configurando Firewall e Finalização"
|
||||||
|
# =============================================
|
||||||
|
print_status "Configurando Fail2ban..."
|
||||||
|
apt-get install -y fail2ban
|
||||||
|
cat > /etc/fail2ban/jail.local << 'FAIL2BAN'
|
||||||
|
[freeswitch-ip]
|
||||||
|
enabled = true
|
||||||
|
logpath = /var/log/freeswitch/freeswitch.log
|
||||||
|
maxretry = 5
|
||||||
|
|
||||||
|
[freeswitch-auth]
|
||||||
|
enabled = true
|
||||||
|
logpath = /var/log/freeswitch/freeswitch.log
|
||||||
|
maxretry = 5
|
||||||
|
|
||||||
|
[fusionpbx-auth]
|
||||||
|
enabled = true
|
||||||
|
logpath = /var/log/nginx/fusionpbx-error.log
|
||||||
|
maxretry = 5
|
||||||
|
FAIL2BAN
|
||||||
|
|
||||||
|
systemctl enable fail2ban
|
||||||
|
systemctl restart fail2ban
|
||||||
|
|
||||||
|
# IP do servidor
|
||||||
|
IP=$(hostname -I | awk '{print $1}')
|
||||||
|
|
||||||
|
# =============================================
|
||||||
|
print_status ""
|
||||||
|
print_status "============================================"
|
||||||
|
print_status " ✅ INSTALAÇÃO CONCLUÍDA!"
|
||||||
|
print_status "============================================"
|
||||||
|
print_status ""
|
||||||
|
print_status " Acesse no navegador:"
|
||||||
|
print_status " https://$IP"
|
||||||
|
print_status ""
|
||||||
|
print_status " Usuário: admin"
|
||||||
|
print_status " Senha: (criada no primeiro acesso)"
|
||||||
|
print_status ""
|
||||||
|
print_status " Banco de dados PostgreSQL:"
|
||||||
|
print_status " Database: $DB_NAME"
|
||||||
|
print_status " Usuário: $DB_USER"
|
||||||
|
print_status " Senha: $DB_PASS"
|
||||||
|
print_status " Arquivo: /etc/fusionpbx/config.php"
|
||||||
|
print_status ""
|
||||||
|
print_status " Repositório local:"
|
||||||
|
print_status " $FUSIONPBX_REPO"
|
||||||
|
print_status ""
|
||||||
|
print_status " Para configurar SSL, use o Nginx Proxy Manager"
|
||||||
|
print_status " https://npm.homelabds.com.br"
|
||||||
|
print_status ""
|
||||||
|
print_status "============================================"
|
||||||
+82
@@ -0,0 +1,82 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Mundo Telecom - Pre-install (Debian 12)
|
||||||
|
# Uso: wget -O - https://git.homelabds.com.br/install.sh | sh
|
||||||
|
#
|
||||||
|
# Este script prepara o ambiente antes da instalação principal.
|
||||||
|
# Baseado no modelo FusionPBX.
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
# Cores para output
|
||||||
|
RED='\033[0;31m'
|
||||||
|
GREEN='\033[0;32m'
|
||||||
|
YELLOW='\033[1;33m'
|
||||||
|
NC='\033[0m'
|
||||||
|
|
||||||
|
print_status() {
|
||||||
|
echo -e "${GREEN}[MUNDO TELECOM]${NC} $1"
|
||||||
|
}
|
||||||
|
|
||||||
|
print_warn() {
|
||||||
|
echo -e "${YELLOW}[AVISO]${NC} $1"
|
||||||
|
}
|
||||||
|
|
||||||
|
print_error() {
|
||||||
|
echo -e "${RED}[ERRO]${NC} $1"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Verificar se é root
|
||||||
|
if [ "$(id -u)" -ne 0 ]; then
|
||||||
|
print_error "Este script deve ser executado como root"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Verificar sistema
|
||||||
|
OS=$(cat /etc/os-release | grep "^ID=" | cut -d= -f2 | tr -d '"')
|
||||||
|
VERSION=$(cat /etc/os-release | grep "^VERSION_ID=" | cut -d= -f2 | tr -d '"')
|
||||||
|
|
||||||
|
print_status "Sistema detectado: $OS $VERSION"
|
||||||
|
|
||||||
|
if [ "$OS" != "debian" ] || [ "$VERSION" != "12" ]; then
|
||||||
|
print_warn "Este script foi testado apenas no Debian 12"
|
||||||
|
print_warn "Prosseguindo mesmo assim..."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Instalar dependências básicas
|
||||||
|
print_status "Atualizando sistema..."
|
||||||
|
apt-get update && apt-get upgrade -y
|
||||||
|
|
||||||
|
print_status "Instalando dependências..."
|
||||||
|
apt-get install -y \
|
||||||
|
systemd \
|
||||||
|
systemd-sysv \
|
||||||
|
ca-certificates \
|
||||||
|
curl \
|
||||||
|
wget \
|
||||||
|
git \
|
||||||
|
gnupg \
|
||||||
|
lsb-release \
|
||||||
|
apt-transport-https \
|
||||||
|
sudo
|
||||||
|
|
||||||
|
# Clonar repositório de instalação
|
||||||
|
print_status "Clonando repositório de instalação..."
|
||||||
|
if [ -d /usr/src/install-scripts ]; then
|
||||||
|
cd /usr/src/install-scripts && git pull
|
||||||
|
else
|
||||||
|
git clone https://git.homelabds.com.br/diegods/install-scripts.git /usr/src/install-scripts
|
||||||
|
fi
|
||||||
|
|
||||||
|
print_status ""
|
||||||
|
print_status "============================================"
|
||||||
|
print_status " Pré-instalação concluída!"
|
||||||
|
print_status ""
|
||||||
|
print_status " Execute o instalador desejado:"
|
||||||
|
print_status " cd /usr/src/install-scripts/debian"
|
||||||
|
print_status " ./install.sh"
|
||||||
|
print_status ""
|
||||||
|
print_status " Scripts disponíveis:"
|
||||||
|
ls -1 /usr/src/install-scripts/debian/*.sh 2>/dev/null | grep -v pre-install | while read script; do
|
||||||
|
echo " - $(basename $script)"
|
||||||
|
done
|
||||||
|
print_status "============================================"
|
||||||
Reference in New Issue
Block a user