Files
notes-techniques/scripts/server-mail/del_domain.sh
2025-03-14 08:12:48 +01:00

25 lines
494 B
Bash
Executable File

#!/bin/bash
# Basé sur un travail de Cédric Abonnel / Cédrix sous licence CC BY-NC 4.0
MAILDIR="/var/mail/vhosts"
POSTFIX_CONFIG="/etc/postfix/virtual_domains"
if [[ -z "$1" ]]; then
echo "Usage: $0 <domaine>"
exit 1
fi
DOMAIN=$1
echo "Suppression du domaine : $DOMAIN"
# Supprimer le domaine du fichier de Postfix
sed -i "/^$DOMAIN$/d" $POSTFIX_CONFIG
# Supprimer les boîtes mail associées
rm -rf $MAILDIR/$DOMAIN
systemctl reload postfix
echo "Domaine $DOMAIN supprimé"