#Auther:YooMa
STORAGE_BASE_DIRECTORY=”/var/vmail/vmail1″
# Password setting.
# Note: password will be crypted in MD5.
DEFAULT_PASSWD=’88888888′
USE_DEFAULT_PASSWD=’NO’ # If set to ‘NO’, password is the same as username.
# Default mail quota.
DEFAULT_QUOTA=’100′ # 100 -> 100M
# ————– You may not need to change variables below ——————-
# Mailbox format: mbox, Maildir.
MAILBOX_FORMAT=’Maildir’
MAILDIR_STYLE=’hashed’ # hashed, normal.
# Time stamp, will be appended in maildir.
DATE=”$(date +%Y.%m.%d.%H.%M.%S)”
STORAGE_BASE=”$(dirname ${STORAGE_BASE_DIRECTORY})”
STORAGE_NODE=”$(basename ${STORAGE_BASE_DIRECTORY})”
# Path to SQL template file.
SQL=”output.sql”
echo ” > ${SQL}
# Cyrpt the password.
generate_sql()
{
# Get domain name.
DOMAIN=”test.net.cn” #要进行哪个邮箱域的导入
UserList=/root/iRedMail-0.8.3/tools/user10.txt #这里是存放用户和密码的用户列表
cat $UserList | while read line
do
arr=($line)
username=${arr[0]}
pswd=${arr[1]}
mail=”${username}@${DOMAIN}”
export CRYPT_PASSWD=”$(openssl passwd -1 ${pswd})”
# Different maildir style: hashed, normal.
if [ X”${MAILDIR_STYLE}” == X”hashed” ]; then
length=”$(echo ${username} | wc -L)”
str1=”$(echo ${username} | cut -c1)”
str2=”$(echo ${username} | cut -c2)”
str3=”$(echo ${username} | cut -c3)”
if [ X”${length}” == X”1″ ]; then
str2=”${str1}”
str3=”${str1}”
elif [ X”${length}” == X”2″ ]; then
str3=”${str2}”
else
:
fi
# Use mbox, will be changed later.
maildir=”${DOMAIN}/${str1}/${str2}/${str3}/${username}-${DATE}”
else
# Use mbox, will be changed later.
maildir=”${DOMAIN}/${username}-${DATE}”
fi
# Different maildir format: maildir, mbox.
if [ X”${MAILBOX_FORMAT}” == X”Maildir” ]; then
# Append slash to make it ‘maildir’ format.
maildir=”${maildir}/”
else
# It’s already mbox format.
:
fi
cat >> ${SQL} <<EOF
INSERT INTO mailbox (username, password, name, storagebasedirectory,storagenode, maildir, quota, domain, active, local_part, created)
VALUES (‘${mail}’, ‘${CRYPT_PASSWD}’, ‘${username}’, ‘${STORAGE_BASE}’,’${STORAGE_NODE}’, ‘${maildir}’, ‘${DEFAULT_QUOTA}’, ‘${DOMAIN}’, ‘1’,’${username}’, NOW());
INSERT INTO alias (address, goto, domain, created, active) VALUES (‘${mail}’, ‘${mail}’,’${DOMAIN}
generate_sql
转载于:https://blog.51cto.com/yooma/1187058
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/110148.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...