Correction erreur suppression compte

This commit is contained in:
Adrien Bourmault 2023-10-09 22:01:11 +02:00
parent 659085601b
commit c51c2a5f4b
Signed by: neox
GPG Key ID: 2974E1D5F25DFCC8
2 changed files with 13 additions and 6 deletions

View File

@ -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
exit 1

View File

@ -1,7 +1,7 @@
#!/bin/bash
if [ $# -ne 3 ] ; then
echo -e "Params:\t<username> <contact@email> <password>" >&2
if [ $# -ne 2 ] ; then
echo -e "Params:\t<username> <contact@email>" >&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