Add automated 1-click install script and FreePBX-style terminal login banner
This commit is contained in:
1 parent
c5de8d0c71
commit
502543e134
4 files changed
+463
-123
No files matched your search
+3
-118
@@ -1,119 +1,4 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
echo "=== Configuration Debian pour NexusPBX ==="
|
||||
|
||||
# 1. Ajout de www-data au groupe asterisk
|
||||
usermod -aG asterisk www-data
|
||||
|
||||
# 2. Création d'un certificat TLS local de secours pour PJSIP TLS (port 5061)
|
||||
mkdir -p /etc/asterisk/keys
|
||||
if [ ! -f /etc/asterisk/keys/asterisk.crt ]; then
|
||||
openssl req -x509 -nodes -days 3650 -newkey rsa:2048 \
|
||||
-keyout /etc/asterisk/keys/asterisk.key \
|
||||
-out /etc/asterisk/keys/asterisk.crt \
|
||||
-subj "/C=FR/ST=IDF/L=Paris/O=NexusPBX/CN=pbx.local" 2>/dev/null
|
||||
fi
|
||||
|
||||
# 3. Configuration de l'AMI (/etc/asterisk/manager.conf) sur 127.0.0.1:5038
|
||||
cat << 'EOF' > /etc/asterisk/manager.conf
|
||||
[general]
|
||||
enabled = yes
|
||||
port = 5038
|
||||
bindaddr = 127.0.0.1
|
||||
displayconnects = no
|
||||
timestampevents = yes
|
||||
|
||||
[pbxgui]
|
||||
secret = AsteriskAmi2026!
|
||||
deny = 0.0.0.0/0.0.0.0
|
||||
permit = 127.0.0.1/255.255.255.0
|
||||
read = all
|
||||
write = all
|
||||
EOF
|
||||
|
||||
# 4. Fichiers .custom.conf initiaux et inclusions dans pjsip.conf et extensions.conf
|
||||
touch /etc/asterisk/pjsip.custom.conf /etc/asterisk/extensions.custom.conf
|
||||
|
||||
if ! grep -q 'pjsip.custom.conf' /etc/asterisk/pjsip.conf; then
|
||||
printf '\n#tryinclude "pjsip.custom.conf"\n' >> /etc/asterisk/pjsip.conf
|
||||
fi
|
||||
|
||||
if ! grep -q 'extensions.custom.conf' /etc/asterisk/extensions.conf; then
|
||||
printf '\n#tryinclude "extensions.custom.conf"\n' >> /etc/asterisk/extensions.conf
|
||||
fi
|
||||
|
||||
# 5. Permissions Debian strictes pour asterisk:asterisk et accès groupe www-data
|
||||
chown -R asterisk:asterisk /etc/asterisk
|
||||
chmod 2775 /etc/asterisk
|
||||
chmod 2750 /etc/asterisk/keys
|
||||
chmod 0640 /etc/asterisk/keys/asterisk.key /etc/asterisk/keys/asterisk.crt
|
||||
chmod 0660 /etc/asterisk/pjsip.custom.conf /etc/asterisk/extensions.custom.conf
|
||||
chmod 0664 /etc/asterisk/pjsip.conf /etc/asterisk/extensions.conf
|
||||
chmod 0640 /etc/asterisk/manager.conf
|
||||
|
||||
# 6. Permissions du projet Web et des répertoires de stockage / sauvegardes
|
||||
mkdir -p /var/www/nexus-pbx/storage/backups
|
||||
mkdir -p /var/www/nexus-pbx/storage/system_backups
|
||||
mkdir -p /var/www/nexus-pbx/storage/sounds
|
||||
mkdir -p /var/lib/asterisk/sounds/custom
|
||||
mkdir -p /var/spool/asterisk/voicemail/default
|
||||
|
||||
chown -R www-data:asterisk /var/www/nexus-pbx
|
||||
chmod 2775 /var/www/nexus-pbx/storage /var/www/nexus-pbx/storage/backups /var/www/nexus-pbx/storage/system_backups /var/www/nexus-pbx/storage/sounds
|
||||
chown -R asterisk:asterisk /var/lib/asterisk/sounds /var/spool/asterisk/voicemail
|
||||
chmod -R g+rwX /var/lib/asterisk/sounds /var/spool/asterisk/voicemail
|
||||
|
||||
# Configuration du cron pour sauvegardes automatiques NexusPBX
|
||||
cat << 'EOF' > /etc/cron.d/nexus-backup
|
||||
# Sauvegardes programmées automatiques NexusPBX
|
||||
*/10 * * * * www-data /usr/bin/php /var/www/nexus-pbx/scripts/nexus_autobackup.php >> /var/log/nexus_backup.log 2>&1
|
||||
EOF
|
||||
chmod 0644 /etc/cron.d/nexus-backup
|
||||
touch /var/log/nexus_backup.log && chown www-data:asterisk /var/log/nexus_backup.log && chmod 664 /var/log/nexus_backup.log
|
||||
|
||||
# 7. Configuration du VirtualHost Nginx (Port 80)
|
||||
PHP_SOCK=$(find /run/php/ -name "php*-fpm.sock" | head -n 1)
|
||||
if [ -z "$PHP_SOCK" ]; then
|
||||
PHP_SOCK="/run/php/php8.4-fpm.sock"
|
||||
fi
|
||||
|
||||
cat << EOF > /etc/nginx/sites-available/nexus-pbx
|
||||
server {
|
||||
listen 80 default_server;
|
||||
listen [::]:80 default_server;
|
||||
server_name _;
|
||||
|
||||
root /var/www/nexus-pbx/public;
|
||||
index index.php;
|
||||
|
||||
access_log /var/log/nginx/nexus-pbx.access.log;
|
||||
error_log /var/log/nginx/nexus-pbx.error.log;
|
||||
|
||||
location / {
|
||||
try_files \$uri \$uri/ /index.php?\$query_string;
|
||||
}
|
||||
|
||||
location ~ \.php\$ {
|
||||
include snippets/fastcgi-php.conf;
|
||||
fastcgi_pass unix:${PHP_SOCK};
|
||||
fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
|
||||
}
|
||||
|
||||
location ~ /\.(?!well-known).* {
|
||||
deny all;
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
chown root:asterisk /etc/nginx/sites-available/nexus-pbx
|
||||
chmod 664 /etc/nginx/sites-available/nexus-pbx
|
||||
rm -f /etc/nginx/sites-enabled/default
|
||||
ln -sf /etc/nginx/sites-available/nexus-pbx /etc/nginx/sites-enabled/nexus-pbx
|
||||
|
||||
# 8. Redémarrage des services Debian
|
||||
systemctl restart php8.4-fpm
|
||||
nginx -t && systemctl restart nginx
|
||||
systemctl restart asterisk
|
||||
|
||||
echo "=== Déploiement NexusPBX terminé avec succès ==="
|
||||
# Redirection vers le script d'installation principal
|
||||
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
exec bash "$DIR/install.sh" "$@"
|
||||
Reference in new issue
Block a user