Support a configuration file for script 'postfix_add_mailboxes.sh'. View also a summary befor starting to create the new mailboxes.
This commit is contained in:
parent
71a9aeb113
commit
4a301f4912
48
conf/postfix_add_mailboxes.conf.sample
Normal file
48
conf/postfix_add_mailboxes.conf.sample
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
# ----------------------------------------------------
|
||||||
|
# ---
|
||||||
|
# - Parameter Settings for script 'postfix_add_mailboxes.sh'.
|
||||||
|
# ---
|
||||||
|
# ----------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
# - in_file
|
||||||
|
# -
|
||||||
|
# - The file from wich the script reads the e-mail-address/password
|
||||||
|
# - kombination(s). Each line in this file must only contain
|
||||||
|
# - <emal-address> <password>
|
||||||
|
# -
|
||||||
|
# - Defaults to: in_file="${conf_dir}/mailboxes_new.lst"
|
||||||
|
# -
|
||||||
|
#in_file="${conf_dir}/mailboxes_new.lst"
|
||||||
|
|
||||||
|
# - db_name
|
||||||
|
# -
|
||||||
|
# - Database name for the postfix database
|
||||||
|
# -
|
||||||
|
# - Defaults to: db_name="postfix"
|
||||||
|
# -
|
||||||
|
#db_name="postfix"
|
||||||
|
|
||||||
|
# - db_user
|
||||||
|
# -
|
||||||
|
# - Database user with access to the postfix database ($db_name)
|
||||||
|
# -
|
||||||
|
# - Defaults to: db_user="postfix"
|
||||||
|
# -
|
||||||
|
#db_user="postfix"
|
||||||
|
|
||||||
|
# - quota
|
||||||
|
# -
|
||||||
|
# - The quota setting for the new mailboxes.
|
||||||
|
# -
|
||||||
|
# - Defaults to: quota="536870912"
|
||||||
|
# -
|
||||||
|
#quota="536870912"
|
||||||
|
|
||||||
|
# - log_file
|
||||||
|
# -
|
||||||
|
# - Where to write logging informations?
|
||||||
|
# -
|
||||||
|
# - Defaults to: log_file="${script_dir}/log/postfix_add_mailboxes.log"
|
||||||
|
# -
|
||||||
|
#log_file="${script_dir}/log/postfix_add_mailboxes.log"
|
1
log/postfix_add_mailboxes.log.20171101-1817
Normal file
1
log/postfix_add_mailboxes.log.20171101-1817
Normal file
@ -0,0 +1 @@
|
|||||||
|
[ OK ]: e-mail: ckubu-test2@oopen.de -- password: EadGl15E.%
|
@ -6,22 +6,18 @@
|
|||||||
## -
|
## -
|
||||||
## --------------------------------------
|
## --------------------------------------
|
||||||
|
|
||||||
|
script_dir="$(dirname $(realpath $0))"
|
||||||
|
conf_dir="${script_dir}/conf"
|
||||||
|
conf_file="${conf_dir}/postfix_add_mailboxes.conf"
|
||||||
|
|
||||||
## - a.mx.oopen.de
|
|
||||||
db_name=postfix
|
|
||||||
db_user=postfix
|
|
||||||
|
|
||||||
## - mailbox related
|
## --- Default Settings
|
||||||
## -
|
## ---
|
||||||
# - 2GB
|
DEFAULT_db_name="postfix"
|
||||||
#quota=2147483648
|
DEFAULT_db_user="postfix"
|
||||||
# - 512MB
|
DEFAULT_quota="536870912"
|
||||||
quota=536870912
|
DEFAULT_in_file="${conf_dir}/mailboxes_new.lst"
|
||||||
#_passwd='$E%R&T/Z(U'
|
DEFAULT_log_file="${script_dir}/log/postfix_add_mailboxes.log"
|
||||||
|
|
||||||
in_file=/root/mailboxes_new.lst
|
|
||||||
|
|
||||||
log_file=/tmp/postfix_add_mailboxes.log
|
|
||||||
|
|
||||||
## --- some functions
|
## --- some functions
|
||||||
## ---
|
## ---
|
||||||
@ -93,6 +89,76 @@ trim() {
|
|||||||
|
|
||||||
date_suffix="`date +%Y%m%d-%H%M`"
|
date_suffix="`date +%Y%m%d-%H%M`"
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo ""
|
||||||
|
echononl " Loading default Configuration values from $(basename ${conf_file}).."
|
||||||
|
if [[ ! -f "$conf_file" ]]; then
|
||||||
|
echo_skipped
|
||||||
|
else
|
||||||
|
source "${conf_file}" > /dev/null 2>&1
|
||||||
|
if [[ $? -eq 0 ]]; then
|
||||||
|
echo_ok
|
||||||
|
else
|
||||||
|
echo_failed
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
[[ -n "$db_name" ]] || db_name="$DEFAULT_db_name"
|
||||||
|
[[ -n "$db_user" ]] || db_user="$DEFAULT_db_user"
|
||||||
|
[[ -n "$quota" ]] || quota="$DEFAULT_quota"
|
||||||
|
[[ -n "$in_file" ]] || in_file="$DEFAULT_in_file"
|
||||||
|
[[ -n "$log_file" ]] || log_file="$DEFAULT_log_file"
|
||||||
|
|
||||||
|
|
||||||
|
if [[ ! -f "$in_file" ]];then
|
||||||
|
fatal "File containing the email/password pairs '$in_file' does not exist !!"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo ""
|
||||||
|
echo -e "\033[32mSettings for script \033[37m\033[1msent_userinfo_postfix.sh\033[m"
|
||||||
|
echo ""
|
||||||
|
echo " File containing the new mailboxes and passwords.......: $in_file"
|
||||||
|
echo ""
|
||||||
|
echo " Mailbox quota to set for each new mailbox.............: $quota"
|
||||||
|
echo ""
|
||||||
|
echo " Database name for the postfix DB......................: $db_name"
|
||||||
|
echo " Database user to access the postfix DB................: $db_user"
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
OK=
|
||||||
|
while [ "$OK" != "yes" -o "$OK" != "no" ] ; do
|
||||||
|
echononl "\033[1mParameters ok? [yes/no]:\033[m "
|
||||||
|
read OK
|
||||||
|
## - To lower case
|
||||||
|
OK=${OK,,}
|
||||||
|
if [ "X$OK" = "X" ]; then
|
||||||
|
echo -e "\n\t\033[33m\033[1mAn entry is required!\033[m\n"
|
||||||
|
OK=""
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
if [ "$OK" != "yes" -o "$OK" != "no" ] ; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
echo -e "\n\t\033[33m\033[1mWrong entry!\033[m\n"
|
||||||
|
done
|
||||||
|
[[ $OK = "yes" ]] || fatal "Repeat execution with different parameters."
|
||||||
|
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echononl " Create log directory '$(dirname "$log_file")'.."
|
||||||
|
if [[ ! -d "$(dirname "$log_file")" ]] ; then
|
||||||
|
mkdir "$(dirname "$log_file")"
|
||||||
|
if [[ $? -eq 0 ]]; then
|
||||||
|
echo_ok
|
||||||
|
else
|
||||||
|
echo_failed
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo_skipped
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
echo
|
echo
|
||||||
|
|
||||||
## -
|
## -
|
||||||
@ -256,6 +322,14 @@ while read email passwd ; do
|
|||||||
|
|
||||||
done < $in_file
|
done < $in_file
|
||||||
|
|
||||||
|
echononl "\tMove file '$in_file'.."
|
||||||
|
mv "$in_file" "${in_file}.$(date +%Y-%m-%d)"
|
||||||
|
if [[ $? -eq 0 ]]; then
|
||||||
|
echo_ok
|
||||||
|
else
|
||||||
|
echo_failed
|
||||||
|
fi
|
||||||
|
|
||||||
echo
|
echo
|
||||||
echo -e "See \033[37m\033[1m$log_file\033[m to see the results again."
|
echo -e "See \033[37m\033[1m$log_file\033[m to see the results again."
|
||||||
echo ""
|
echo ""
|
||||||
|
Loading…
Reference in New Issue
Block a user