51 lines
1.4 KiB
Bash
51 lines
1.4 KiB
Bash
# ------------------------------------------------------------------------------
|
|
# Mail system
|
|
# This file is part of the init.sh project
|
|
# Copyright (c) 2019-2022 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org>
|
|
# ------------------------------------------------------------------------------
|
|
# This file is distributed under 3-clause BSD license.
|
|
# The complete license agreement can be obtained at:
|
|
# https://opensource.org/licenses/BSD-3-Clause
|
|
# ------------------------------------------------------------------------------
|
|
# Variable:
|
|
# * HOSTNAME: Name of the host
|
|
# * REALM: Default main domain name
|
|
# * MAIL_RELAY: Name of the mail relay server
|
|
# ------------------------------------------------------------------------------
|
|
|
|
export VER_conf_mail="0.0.8"
|
|
export DEP_conf_mail="upgrade_dist"
|
|
|
|
conf_mail()
|
|
{
|
|
prnt I "Installing postfix..."
|
|
pkginst postfix
|
|
|
|
local pfmain="/etc/postfix/main.cf"
|
|
|
|
prnt I "Configuring postfix..."
|
|
install_file postfix/main.cf $pfmain
|
|
tag_file $pfmain
|
|
sed -i -e "s/@HOSTNAME@/$HOSTNAME/" -e "s/@REALM@/$REALM/" \
|
|
-e "s/@MAIL_RELAY@/$MAIL_RELAY/" $pfmain
|
|
|
|
echo $HOSTNAME.$REALM > /etc/mailname
|
|
#tag_file /etc/mailname
|
|
|
|
svc_restart postfix
|
|
}
|
|
|
|
precheck_conf_mail()
|
|
{
|
|
if [[ -z $REALM ]]; then
|
|
prnt E "No main domain configured, can't continue."
|
|
die 158
|
|
fi
|
|
file_must_exists postfix/main.cf
|
|
}
|
|
|
|
export -f conf_mail
|
|
export -f precheck_conf_mail
|
|
|
|
# EOF
|