-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdoveuserdel.sh
executable file
·54 lines (44 loc) · 1.07 KB
/
doveuserdel.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/bash
# script to delete a user from a dovecot and postfix file using pwdfiles.
# http://github.com/likyng/dotfiles
USERSFILE=/etc/dovecot/users
POSTFIXVIRTUAL_MAILBOX=/etc/postfix/vmailbox
POSTFIXVIRTUAL=/etc/postfix/virtual
function check_root() {
if [ "$(id -u)" != "0" ]
then
echo '[ERROR] must be root to use this script!'
exit 1
fi
}
function get_username() {
echo -n "Username <[email protected]>: "
read username
validate_username ${username}
}
function verify_delete() {
read -p "Really delete EMail user $username ?" -n 1 -r
echo
if [[ $REPLY =~ ^[Nn]$ ]]
then
echo "Aborting... No files have been changed!"
exit 1
fi
}
function delete_user() {
}
function restart_services() {
postmap $POSTFIXVIRTUAL
postmap $POSTFIXVIRTUAL_MAILBOX
systemctl restart dovecot
systemctl restart postfix
}
# executing functions with descriptive text...
echo "Script to DELETE usernames from dovecot"
check_root
get_username
verify_delete
echo "Beginning to delete stuff from disk, errors from here on require manual fixing"
delete_user
restart_services
# END