Add automated 1-click install script and FreePBX-style terminal login banner

This commit is contained in:
sorcier committed 2026-11-02 02:46:52 +01:00
1 parent c5de8d0c71
commit 502543e134
4 files changed
+463 -123

No files matched your search

+97
View File
@@ -0,0 +1,97 @@
#!/usr/bin/env bash
# ==============================================================================
# NexusPBX - Terminal Console Banner & Network Status (FreePBX-style)
# ==============================================================================
# Ne s'exécute que pour les shells interactifs
if [ -t 1 ]; then
C_GREEN="\033[1;32m"
C_CYAN="\033[1;36m"
C_WHITE="\033[1;37m"
C_YELLOW="\033[1;33m"
C_RED="\033[1;31m"
C_GRAY="\033[0;37m"
C_RESET="\033[0m"
echo ""
echo -e "${C_GREEN}"
cat << "BANNER"
_ _ ____ ______ __ __
| \ | | _____ ___ _ ___ | _ \| __ ) \ \/ /
| \| |/ _ \ \/ / | | / __| | |_) | _ \ \ /
| |\ | __/> <| |_| \__ \ | __/| |_) | / \
|_| \_|\___/_/\_\\__,_|___/ |_| |____/ /_/\_\
BANNER
echo -e "${C_RESET}"
# Vérification des statuts des services
AST_STATUS=$(systemctl is-active asterisk 2>/dev/null || echo "inactive")
NGINX_STATUS=$(systemctl is-active nginx 2>/dev/null || echo "inactive")
F2B_STATUS=$(systemctl is-active fail2ban 2>/dev/null || echo "inactive")
if [ "$AST_STATUS" = "active" ] && [ "$NGINX_STATUS" = "active" ]; then
echo -e "${C_CYAN}SYSTEM READY${C_RESET} - Asterisk: ${C_GREEN}ONLINE${C_RESET} | Nginx: ${C_GREEN}ONLINE${C_RESET} | Fail2ban: ${C_GREEN}ONLINE${C_RESET}"
else
echo -e "${C_YELLOW}NOTICE! Services en cours de démarrage ou attention requise dans l'interface.${C_RESET}"
fi
echo ""
# Tableau de configuration réseau
echo -e "${C_GREEN}Current Network Configuration${C_RESET}"
echo "+-----------------+-------------------+-----------------------------------+"
printf "| %-15s | %-17s | %-33s |\n" "Interface" "MAC Address" "IP Addresses"
echo "+-----------------+-------------------+-----------------------------------+"
FIRST_IP=""
INTERFACES=$(ip -o link show 2>/dev/null | awk -F': ' '{print $2}' | grep -v -E '^(lo|docker|veth|br-|tun|tap)')
for iface in $INTERFACES; do
MAC=$(cat /sys/class/net/"$iface"/address 2>/dev/null || echo "N/A")
# Récupère les IPv4 d'abord, puis les IPv6
IPV4S=$(ip -o -4 addr show dev "$iface" 2>/dev/null | awk '{print $4}' | cut -d/ -f1)
IPV6S=$(ip -o -6 addr show dev "$iface" scope global 2>/dev/null | awk '{print $4}' | cut -d/ -f1)
first_line=true
if [ -n "$IPV4S" ] || [ -n "$IPV6S" ]; then
for ip in $IPV4S; do
if [ -z "$FIRST_IP" ]; then FIRST_IP="$ip"; fi
if [ "$first_line" = true ]; then
printf "| %-15s | %-17s | %-33s |\n" "$iface" "$MAC" "$ip"
first_line=false
else
printf "| %-15s | %-17s | %-33s |\n" "" "" "$ip"
fi
done
for ip in $IPV6S; do
if [ "$first_line" = true ]; then
printf "| %-15s | %-17s | %-33s |\n" "$iface" "$MAC" "$ip"
first_line=false
else
printf "| %-15s | %-17s | %-33s |\n" "" "" "$ip"
fi
done
else
printf "| %-15s | %-17s | %-33s |\n" "$iface" "$MAC" "Aucune IP"
fi
echo "+-----------------+-------------------+-----------------------------------+"
done
if [ -z "$FIRST_IP" ]; then
FIRST_IP="127.0.0.1"
fi
echo ""
echo -e "${C_WHITE}Please note most tasks should be handled through the GUI.${C_RESET}"
echo -e "You can access the GUI by typing one of the above IPs into your web browser:"
echo -e " ${C_CYAN}http://${FIRST_IP}${C_RESET} ${C_GRAY}(ou https://${FIRST_IP}:8443)${C_RESET}"
echo ""
echo -e "Default credentials:"
echo -e " Username : ${C_GREEN}admin${C_RESET}"
echo -e " Password : ${C_GREEN}admin123${C_RESET}"
echo ""
echo -e "${C_GRAY}Dépôt officiel & Mises à jour : https://git.sorcier-research.com/sorcier/NexusPBX${C_RESET}"
echo ""
fi
+3 -118
View File
@@ -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" "$@"