evoadmin-mail/scripts/evoadmin.sh
David Prevot cf873c35eb
All checks were successful
gitea/evoadmin-mail/pipeline/head This commit looks good
gitea/evoadmin-mail/pipeline/tag This commit looks good
Fix USERDIR to delete
Not sure why we didn’t use directly the homeDirectory ldap entry, but
just trying to minimize the patch by trying to figure out the path from
the uid and domain…
2023-07-26 15:16:47 +02:00

54 lines
1,012 B
Bash
Executable file

#!/bin/bash
# This is a bash script, not sh compatible!
# vim: expandtab softtabstop=4 tabstop=4 shiftwidth=4 showtabline=2
PASSWORD='xxx'
DATE=$(date +"%d-%m-%Y")
while getopts "p:u:D:d" option ; do
case $option in
p)
READPASS=$OPTARG
;;
u)
USERIS=$OPTARG
;;
D)
DOMAINIS=$OPTARG
;;
d)
DEL='on'
;;
*)
echo "script error"
exit 1
;;
esac
done
if [ "$PASSWORD" != "$READPASS" ]; then
echo "Invalid password"
echo "Use -p <password>"
exit 1
fi
# mv pseudo-homeDir to directory.<date> for deleted users
USERDIR=${USERIS%%@$DOMAINIS}
if [ "$DEL" == "on" ]; then
if [[ -n $USERIS && -n $DOMAINIS && -n $USERDIR && -e "/home/vmail/$DOMAINIS" && -e "/home/vmail/$DOMAINIS/$USERDIR" ]]; then
mv /home/vmail/$DOMAINIS/$USERDIR /home/vmail/$DOMAINIS/$USERDIR.$DATE
chown -R root:root /home/vmail/$DOMAINIS/$USERDIR.$DATE
chmod -R 700 /home/vmail/$DOMAINIS/$USERDIR.$DATE
fi
exit 0
fi
exit 1