Ce script Bash permet de configurer automatiquement une VM Debian Trixie fraîchement déployée sur Misère.
Il effectue les actions suivantes :
clipboard Cliquez dans le bloc ci-dessous pour copier le script complet :
#!/bin/bash set -e if [ "$EUID" -ne 0 ]; then echo " Veuillez exécuter ce script en tant que root." exit 1 fi read -p " Entrez l'adresse IP statique à assigner (ex: 192.168.77.42): " STATIC_IP NETMASK="255.255.255.0" GATEWAY="192.168.77.254" DNS_SERVERS=$(grep -m1 ^nameserver /etc/resolv.conf | awk '{print $2}') [ -z "$DNS_SERVERS" ] && DNS_SERVERS="1.1.1.1 8.8.8.8" IFACE=$(ip -o -4 route show to default | awk '{print $5}') if [ -z "$IFACE" ]; then echo " Impossible de détecter l'interface réseau." exit 1 fi echo " Interface détectée : $IFACE" mkdir -p /etc/systemd/network cat > /etc/systemd/network/20-static.network <<EOF [Match] Name=$IFACE [Network] Address=$STATIC_IP/24 Gateway=$GATEWAY DNS=$DNS_SERVERS EOF systemctl disable --now networking || true systemctl enable systemd-networkd systemctl restart systemd-networkd echo " IP statique configurée sur $IFACE : $STATIC_IP" echo " Installation de Docker..." apt update && apt install -y ca-certificates curl gnupg lsb-release install -m 0755 -d /etc/apt/keyrings curl -fsSL https://download.docker.com/linux/debian/gpg | \ gpg --dearmor -o /etc/apt/keyrings/docker.gpg chmod a+r /etc/apt/keyrings/docker.gpg echo \ "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] \ https://download.docker.com/linux/debian \ $(lsb_release -cs) stable" | \ tee /etc/apt/sources.list.d/docker.list > /dev/null apt update apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin systemctl enable docker systemctl start docker CURRENT_USER=$(logname) usermod -aG docker "$CURRENT_USER" echo " Installation des outils système..." apt install -y btop git curl vim bat duf eza BASHRC="/home/$CURRENT_USER/.bashrc" echo " Configuration des alias et du prompt dans $BASHRC..." cat >> "$BASHRC" <<'EOT' # Aliases personnalisés alias ll="eza -l" alias la="eza -A" alias dufhide="duf --hide special" alias bat="batcat" # Prompt coloré minimal PS1='\[\e[1;32m\]\u@\h:\[\e[0;36m\]\w\[\e[0m\]\$ ' EOT chown "$CURRENT_USER:$CURRENT_USER" "$BASHRC" echo "" echo " Réseau statique OK, Docker installé, outils ajoutés" echo " Déconnexion + reconnexion recommandée." read -p " Redémarrer maintenant ? (o/N): " confirm if [[ "$confirm" =~ ^[oO]$ ]]; then reboot fi