Files
NexusPBX/scripts/nexus-banner.sh
T

98 lines
4.0 KiB
Bash
Executable File

#!/usr/bin/env bash
# ==============================================================================
# NexusPBX - Terminal Console Banner & Network Status (FreePBX-style)
# ==============================================================================
# Ne s'exécute que pour les shells interactifs ou avec l'option --force
if [ -t 1 ] || [ "${1:-}" = "--force" ] || [ -n "${SSH_TTY:-}" ]; 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