Lorem ipsum dolor sit amet, consectetur adipiscing elit lobortis arcu enim urna adipiscing praesent velit viverra sit semper lorem eu cursus vel hendrerit elementum morbi curabitur etiam nibh justo, lorem aliquet donec sed sit mi dignissim at ante massa mattis.
Vitae congue eu consequat ac felis placerat vestibulum lectus mauris ultrices cursus sit amet dictum sit amet justo donec enim diam porttitor lacus luctus accumsan tortor posuere praesent tristique magna sit amet purus gravida quis blandit turpis.
At risus viverra adipiscing at in tellus integer feugiat nisl pretium fusce id velit ut tortor sagittis orci a scelerisque purus semper eget at lectus urna duis convallis. porta nibh venenatis cras sed felis eget neque laoreet suspendisse interdum consectetur libero id faucibus nisl donec pretium vulputate sapien nec sagittis aliquam nunc lobortis mattis aliquam faucibus purus in.
Nisi quis eleifend quam adipiscing vitae aliquet bibendum enim facilisis gravida neque. Velit euismod in pellentesque massa placerat volutpat lacus laoreet non curabitur gravida odio aenean sed adipiscing diam donec adipiscing tristique risus. amet est placerat in egestas erat imperdiet sed euismod nisi.
“Nisi quis eleifend quam adipiscing vitae aliquet bibendum enim facilisis gravida neque velit euismod in pellentesque massa placerat”
Eget lorem dolor sed viverra ipsum nunc aliquet bibendum felis donec et odio pellentesque diam volutpat commodo sed egestas aliquam sem fringilla ut morbi tincidunt augue interdum velit euismod eu tincidunt tortor aliquam nulla facilisi aenean sed adipiscing diam donec adipiscing ut lectus arcu bibendum at varius vel pharetra nibh venenatis cras sed felis eget dolor cosnectur drolo.
While working on a postfix/dovecot non-mysql virtual domain configuration, I needed a simple admin script to add new users. The script below is what I came up with after about 30 minutes.I was unable to find something that met my needs on the interweb, so I hope this post finds someone else in need!Please submit bugs/suggestions to: nick.wilkens@mnxsolutions.com[code]#!/bin/bash# bugs/suggestions to: nick.wilkens@mnxsolutions.com# 1/29/2012USERSFILE=/etc/dovecot/usersPOSTFIXVIRTUAL_MAILBOX=/etc/postfix/virtual_mailbox_mapsPOSTFIXVIRTUAL_DOMAINS=/etc/postfix/virtual_domainsfunction validate_username() { username=$1 echo $username| egrep -iq '([[:alnum:]_.]+@[[:alnum:]_]+?.[[:alpha:].]{2,6})'; RC=$? if [ ${RC} -ne 0 ] then echo "Invalid username, please ensure user@domain.tld format ($RC)" exit 1 fi}function get_username() { echo -n "Username <user@domain.com>: " read username validate_username ${username}}function get_password() { randpw=$(mkpasswd -l 15 -d 3 -C 5) echo echo "Password suggestion: ${randpw}" echo echo -n "Password: " read password1 echo -n "Password (again): " read password2 if [ "${password1}" != "${password2}" ] then echo "Passwords miss-match, retry" get_password fi}function gen_ssha512() { local password=$1 doveadm pw -s SSHA512 -p "$password"}function check_dovecot_user() { grep -iq $username $USERSFILE; RC=$? if [ "${RC}" -eq 0 ] then echo "User already exists in $USERSFILE, please check." echo "For reference, or manual editing here was the computed string to use" echo "${username}:${password}" exit 1 fi}function check_postfix_maps() { grep -iq $username $POSTFIXVIRTUAL_MAILBOX; RC=$? if [ "${RC}" -eq 0 ] then echo "User already exists in $POSTFIXVIRTUAL_MAILBOX, please check." echo "For reference, or manual editing here was the computed string to use" echo echo "${username} OK" echo echo "You will also need to run 'postmap hash:$POSTFIXVIRTUAL_MAILBOX' if you edit this file directly" exit 1 fi}function update_postfix_virtual() { local domain=`echo $username|cut -d@ -f2` grep -iq $domain $POSTFIXVIRTUAL_DOMAINS; RC=$? # Add the domain if we don't find it in grep if [ "${RC}" -ne 0 ] then echo "${domain}" >> $POSTFIXVIRTUAL_DOMAINS fi}get_usernameget_passwordpassword=$(gen_ssha512)check_dovecot_usercheck_postfix_mapsupdate_postfix_virtualecho "${username}:${password}" >> $USERSFILEecho "${username} OK" >> $POSTFIXVIRTUAL_MAILBOXpostmap hash:$POSTFIXVIRTUAL_MAILBOXservice postfix reloadecho "Done"[/code]