#!/bin/bash # ============================================================ # Antoine's Toolbox — Master Script # https://antoine-srv.fr/script.sh # ============================================================ # Usage : bash <(curl -fsSL https://antoine-srv.fr/script.sh) # ============================================================ BASE_URL="https://antoine-srv.fr/scripts" VERSION="2.1" # ── FIX CRITIQUE : bash <(curl ...) capte stdin sur le pipe ── # Quand le script est lancé via process substitution, stdin est # le pipe du script lui-meme. On force /dev/tty pour que read # lise bien le clavier de lutilisateur. if [[ ! -t 0 ]]; then exec < /dev/tty fi # ───────────────────────────────────────────── # COULEURS & STYLES # ───────────────────────────────────────────── R='\033[0;31m' ; G='\033[0;32m' ; Y='\033[1;33m' B='\033[0;34m' ; C='\033[0;36m' ; W='\033[1;37m' DIM='\033[2m' ; BOLD='\033[1m' ; RESET='\033[0m' BG_DARK='\033[48;5;233m' # ───────────────────────────────────────────── # MENU CONFIG — Ajouter un script ici suffit ! # Format : "Nom affiché|fichier.sh|Description courte" # ───────────────────────────────────────────── # ───────────────────────────────────────────── # MENU CONFIG — Ajouter un script ici suffit ! # Format entrées : "nom|chemin/fichier.sh|Description" # Pour ajouter une catégorie : incrémenter CAT_COUNT, # ajouter get_cat_name() et CAT_SCRIPTS_N # ───────────────────────────────────────────── CAT_COUNT=6 # ← changer ce nombre quand on ajoute une catégorie get_cat_name() { case "$1" in 1) echo "🖥️ Système" ;; 2) echo "🌐 Réseau" ;; 3) echo "🐳 Docker" ;; 4) echo "🌍 Web & Serveurs" ;; 5) echo "🔒 Sécurité" ;; 6) echo "📊 Monitoring" ;; esac } get_cat_scripts() { case "$1" in 1) cat << 'ENDSCRIPTS' sysinfo|system/sysinfo.sh|Infos complètes du système (CPU, RAM, disques) update|system/update.sh|Mise à jour complète (apt/dnf/pacman auto-détecté) cleanup|system/cleanup.sh|Nettoyage cache, logs et paquets inutiles swap|system/swap.sh|Créer / redimensionner un fichier swap hostname|system/hostname.sh|Changer le hostname de la machine ENDSCRIPTS ;; 2) cat << 'ENDSCRIPTS' netinfo|network/netinfo.sh|Infos réseau complètes (IP, routes, DNS) firewall|network/firewall.sh|Configuration UFW/firewalld interactive port-scan|network/port-scan.sh|Scanner les ports ouverts localement vpn-setup|network/vpn-setup.sh|Installation et config WireGuard VPN fail2ban|network/fail2ban.sh|Installer et configurer Fail2ban ENDSCRIPTS ;; 3) cat << 'ENDSCRIPTS' docker-install|docker/install.sh|Installer Docker + Docker Compose docker-clean|docker/clean.sh|Purger images/containers/volumes inutilisés portainer|docker/portainer.sh|Déployer Portainer CE compose-gen|docker/compose-gen.sh|Générateur interactif de docker-compose.yml ENDSCRIPTS ;; 4) cat << 'ENDSCRIPTS' apache2|web/apache2.sh|Apache2 wizard complet (install, VirtualHosts, PHP, WebApps…) pureftpd|web/pureftpd.sh|Pure-FTPd wizard complet (users virtuels, quotas, IP, horaires…) nginx|web/nginx.sh|Installer et configurer Nginx certbot|web/certbot.sh|Générer certificats SSL Let's Encrypt nodejs|web/nodejs.sh|Installer Node.js (LTS ou spécifique) ENDSCRIPTS ;; 5) cat << 'ENDSCRIPTS' ssh-harden|security/ssh-harden.sh|Sécurisation SSH (port, clés, bannière) audit|security/audit.sh|Audit rapide de sécurité du serveur backup|security/backup.sh|Script de backup automatisé vers S3/local 2fa|security/2fa.sh|Activer l'authentification 2FA (Google Auth) ENDSCRIPTS ;; 6) cat << 'ENDSCRIPTS' netdata|monitoring/netdata.sh|Installer Netdata (monitoring temps réel) grafana|monitoring/grafana.sh|Stack Grafana + Prometheus uptime-kuma|monitoring/uptime-kuma.sh|Déployer Uptime Kuma logwatch|monitoring/logwatch.sh|Configurer Logwatch (rapports logs) ENDSCRIPTS ;; esac } # ───────────────────────────────────────────── # FONCTIONS UTILITAIRES # ───────────────────────────────────────────── clear_screen() { clear; } print_banner() { clear_screen echo -e "${C}" cat << 'EOF' ╔════════════════════════════════════════════════════════════════╗ ║ ║ ║ █████╗ ███╗ ██╗████████╗ ██████╗ ██╗███╗ ██╗███████╗ ║ ║ ██╔══██╗████╗ ██║╚══██╔══╝██╔═══██╗██║████╗ ██║██╔════╝ ║ ║ ███████║██╔██╗ ██║ ██║ ██║ ██║██║██╔██╗ ██║█████╗ ║ ║ ██╔══██║██║╚██╗██║ ██║ ██║ ██║██║██║╚██╗██║██╔══╝ ║ ║ ██║ ██║██║ ╚████║ ██║ ╚██████╔╝██║██║ ╚████║███████╗ ║ ║ ╚═╝ ╚═╝╚═╝ ╚═══╝ ╚═╝ ╚═════╝ ╚═╝╚═╝ ╚═══╝╚══════╝ ║ ║ T O O L B O X ║ ╚════════════════════════════════════════════════════════════════╝ EOF echo -e "${RESET}" echo -e " ${DIM}Version ${VERSION} • https://antoine-srv.fr${RESET}\n" } print_separator() { echo -e " ${DIM}────────────────────────────────────────────────────────${RESET}" } confirm() { local msg="$1" echo -e "\n ${Y}⚠ ${msg}${RESET}" echo -ne " ${W}Confirmer ? [o/N] → ${RESET}" read -r ans [[ "$ans" =~ ^[oOyY]$ ]] } download_and_run() { local script_path="$1" local script_name="$2" local url="${BASE_URL}/${script_path}" local tmp_file="/tmp/toolbox_$(date +%s).sh" echo "" print_separator echo -e " ${C}⬇ Téléchargement de ${BOLD}${script_name}${RESET}${C}...${RESET}" echo -e " ${DIM}URL : ${url}${RESET}\n" if ! curl -fsSL "$url" -o "$tmp_file" 2>/dev/null; then echo -e " ${R}✗ Impossible de télécharger le script.${RESET}" echo -e " ${DIM}Vérifiez votre connexion ou que le script existe sur le serveur.${RESET}" echo "" read -rp " Appuyer sur Entrée pour revenir..." return 1 fi chmod +x "$tmp_file" echo -e " ${G}✓ Téléchargement réussi !${RESET}\n" print_separator echo "" if confirm "Lancer le script '${script_name}' maintenant ?"; then echo -e "\n ${G}▶ Exécution en cours...${RESET}\n" print_separator echo "" bash "$tmp_file" local exit_code=$? echo "" print_separator if [ $exit_code -eq 0 ]; then echo -e " ${G}✓ Script terminé avec succès.${RESET}" else echo -e " ${R}✗ Le script s'est terminé avec le code ${exit_code}.${RESET}" fi else echo -e " ${Y}→ Script téléchargé dans : ${tmp_file}${RESET}" echo -e " ${DIM}Vous pouvez l'inspecter avant de l'exécuter manuellement.${RESET}" fi rm -f "$tmp_file" 2>/dev/null echo "" read -rp " Appuyer sur Entrée pour revenir au menu..." } # ───────────────────────────────────────────── # MENU SOUS-CATÉGORIE # ───────────────────────────────────────────── show_subcategory() { local cat_id="$1" local cat_name cat_name="$(get_cat_name "$cat_id")" local scripts_raw scripts_raw="$(get_cat_scripts "$cat_id")" # Parser les scripts dans des tableaux indexés local -a names descs paths while IFS='|' read -r name path desc; do [[ -z "$name" ]] && continue names+=("$name") paths+=("$path") descs+=("$desc") done <<< "$scripts_raw" while true; do print_banner echo -e " ${BOLD}${cat_name}${RESET}\n" print_separator for j in "${!names[@]}"; do local num=$((j + 1)) printf " ${C}[%2d]${RESET} ${BOLD}%-20s${RESET} ${DIM}%s${RESET}\n" \ "$num" "${names[$j]}" "${descs[$j]}" done print_separator echo -e " ${DIM}[0] ← Retour au menu principal${RESET}\n" echo -ne " ${W}Votre choix → ${RESET}" read -r choice if [[ "$choice" == "0" ]]; then return elif [[ "$choice" =~ ^[0-9]+$ ]] && [ "$choice" -ge 1 ] && [ "$choice" -le "${#names[@]}" ]; then local idx=$((choice - 1)) download_and_run "${paths[$idx]}" "${names[$idx]}" else echo -e "\n ${R}✗ Choix invalide.${RESET}" sleep 1 fi done } # ───────────────────────────────────────────── # MENU PRINCIPAL # ───────────────────────────────────────────── main_menu() { while true; do print_banner echo -e " ${BOLD}Sélectionnez une catégorie :${RESET}\n" print_separator for key in $(seq 1 "$CAT_COUNT"); do printf " ${C}[%s]${RESET} %s\n" "$key" "$(get_cat_name "$key")" done print_separator echo -e " ${DIM}[q] Quitter${RESET}\n" echo -ne " ${W}Votre choix → ${RESET}" read -r choice case "$choice" in q|Q|quit|exit) echo -e "\n ${DIM}À bientôt !${RESET}\n" exit 0 ;; *) if [[ "$choice" =~ ^[0-9]+$ ]] && [ "$choice" -ge 1 ] && [ "$choice" -le "$CAT_COUNT" ]; then show_subcategory "$choice" else echo -e "\n ${R}✗ Catégorie invalide.${RESET}" sleep 1 fi ;; esac done } # ───────────────────────────────────────────── # VÉRIFICATIONS PRÉLIMINAIRES # ───────────────────────────────────────────── check_deps() { local missing=() for cmd in curl bash; do command -v "$cmd" &>/dev/null || missing+=("$cmd") done if [ ${#missing[@]} -gt 0 ]; then echo -e "${R}Dépendances manquantes : ${missing[*]}${RESET}" exit 1 fi } check_deps main_menu