From c51c2a5f4b6e3ba70cdb1f69620d66fcaa4b435e Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Mon, 9 Oct 2023 22:01:11 +0200 Subject: [PATCH] Correction erreur suppression compte --- scripts/del_full_member.sh | 13 ++++++++++--- scripts/sendmail_deletion.sh | 6 +++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/scripts/del_full_member.sh b/scripts/del_full_member.sh index 5242fe8..e1ef3b1 100755 --- a/scripts/del_full_member.sh +++ b/scripts/del_full_member.sh @@ -15,10 +15,17 @@ if grep -q -e ^$user: /etc/passwd ; then # Del account from members ML echo -n "Deleting mail from member list..." - pos=$(grep --line-number -e ^$user: /etc/passwd | cut -d ":" -f 1) + pos=$(grep --line-number -e ^$user: /etc/postfix/virtual_members | cut -d ":" -f 1) sed -i "${pos}d" /etc/postfix/virtual_members postmap /etc/postfix/virtual_members echo "[OK]" + + # Del account from any redirect (if exist) + echo -n "Deleting mail from member list..." + pos=$(grep --line-number -e ^$user: /etc/postfix/virtual_redirect | cut -d ":" -f 1) + sed -i "${pos}d" /etc/postfix/virtual_redirect + postmap /etc/postfix/virtual_redirect + echo "[OK]" # Del user echo -n "Deleting POSIX account \"$user\"..." @@ -30,9 +37,9 @@ if grep -q -e ^$user: /etc/passwd ; then postfix reload > /dev/null 2>&1 echo "[OK]" - $SCRIPTPATH/sendmail_deletion.sh $user $email $password + $SCRIPTPATH/sendmail_deletion.sh $user $email exit fi echo User \"$user\" not in base. -exit 1 \ No newline at end of file +exit 1 diff --git a/scripts/sendmail_deletion.sh b/scripts/sendmail_deletion.sh index 519d0ba..f14720c 100755 --- a/scripts/sendmail_deletion.sh +++ b/scripts/sendmail_deletion.sh @@ -1,7 +1,7 @@ #!/bin/bash -if [ $# -ne 3 ] ; then - echo -e "Params:\t " >&2 +if [ $# -ne 2 ] ; then + echo -e "Params:\t " >&2 exit fi @@ -9,7 +9,7 @@ user=$1 email=$2 password=$3 -echo -n "Sending mail to \"$email\" for account creation \"$user\"..." +echo -n "Sending mail to \"$email\" for account deletion \"$user\"..." date=$( date -R ) headers=$(cat<< EOF