Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- if [ ! $# = 1 ]
- then
- echo "Usage: $0 username@domain"
- exit 1
- else
- user=`echo "$1" | cut -f1 -d "@"`
- domain=`echo "$1" | cut -s -f2 -d "@"`
- if [ -x $domain ]
- then
- echo "No domain given\nUsage: $0 username@domain"
- exit 2
- fi
- echo "\nCreate a password for the new email user"
- #SWAP THE FOLLOWING passwd LINES IF USING A UBUNTU VERSION PRIOR TO 12.04
- #passwd=`dovecotpw`
- passwd=`doveadm pw -u $user`
- echo "Adding user $user@$domain to /maildata/userpass"
- if [ ! -x /maildata/userpass ]
- then
- touch /maildata/userpass
- chmod 640 /maildata/userpass
- fi
- echo "$user@$domain:$passwd" >> /maildata/userpass
- # Create the needed Maildir directories
- echo "Creating user directory /home/vmail/$domain/$user"
- # maildirmake.dovecot does only chown on user directory, we'll create domain directory instead
- if [ ! -x /maildata/mailbox/$domain ]
- then
- mkdir -p /maildata/mailbox/$domain
- chown 2000:2000 /maildata/mailbox/$domain
- chmod 700 /maildata/mailbox/$domain
- fi
- /usr/bin/maildirmake.dovecot /maildata/mailbox/$domain/$user 2000:2000
- # Also make folders for Drafts, Sent, Junk and Trash
- /usr/bin/maildirmake.dovecot /maildata/mailbox/$domain/$user/.Drafts 2000:2000
- /usr/bin/maildirmake.dovecot /maildata/mailbox/$domain/$user/.Sent 2000:2000
- /usr/bin/maildirmake.dovecot /maildata/mailbox/$domain/$user/.Junk 2000:2000
- /usr/bin/maildirmake.dovecot /maildata/mailbox/$domain/$user/.Trash 2000:2000
- # To add user to Postfix virtual map file and relode Postfix
- echo "Adding user to /etc/postfix/vmaps"
- echo $1 $domain/$user/ >> /maildata/vmaps
- postmap /maildata/vmaps
- postfix reload
- fi
- exit 0
Add Comment
Please, Sign In to add comment