install_postfix_base.sh: add default values if configuration file is not present or some values not set.
This commit is contained in:
parent
6e8e46af98
commit
408ac30592
@ -1,27 +1,15 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
script_dir="$(dirname $(realpath $0))"
|
||||
script_name="$(basename "$0")"
|
||||
|
||||
conf_dir=$(dirname $0)/conf
|
||||
conf_file="${conf_dir}/install_postfix_base.conf"
|
||||
|
||||
_TLS_CERT_DIR=/etc/postfix/ssl
|
||||
_TLS_CERT_FILE="${_TLS_CERT_DIR}/mailserver.crt"
|
||||
_TLS_KEY_FILE="${_TLS_CERT_DIR}/mailserver.key"
|
||||
#
|
||||
_TLS_CA_FILE=/etc/ssl/certs/ca-certificates.crt
|
||||
#
|
||||
#
|
||||
#_HOSTNAME=o15.oopen.de
|
||||
#_IPV4=83.223.86.96
|
||||
#_EXT_IF_IP=83.223.86.96
|
||||
#
|
||||
### - Leave empty, if no IPv6 should be supported
|
||||
### -
|
||||
#_IPV6=2a01:30:0:13:5054:ff:fe09:2318
|
||||
##_IPV6=
|
||||
#
|
||||
#_ADMIN_EMAIL=admin@oopen.de
|
||||
#
|
||||
#_SASL_AUTH=false
|
||||
#_RELAY_HOST=b.mx.oopen.de
|
||||
#_SASL_USER=anw-urb
|
||||
#_SASL_PASS='OhPie2aethei'
|
||||
|
||||
|
||||
# -------------
|
||||
@ -81,6 +69,15 @@ echo_skipped() {
|
||||
}
|
||||
|
||||
|
||||
# -------------
|
||||
# --- Some default settings
|
||||
# -------------
|
||||
|
||||
DEFAULT_ADMIN_EMAIL="argus@oopen.de"
|
||||
DEFAULT_RELAY_HOST="b.mx.oopen.de"
|
||||
DEFAULT_SASL_AUTH=false
|
||||
|
||||
|
||||
# - Is this a systemd system?
|
||||
# -
|
||||
if [[ "X`which systemd`" = "X" ]]; then
|
||||
@ -91,13 +88,27 @@ fi
|
||||
|
||||
echo ""
|
||||
|
||||
conf_dir=$(dirname $0)/conf
|
||||
conf_file="${conf_dir}/install_postfix_base.conf"
|
||||
|
||||
# - Read Configuration File if exists
|
||||
# -
|
||||
if [[ -f "$conf_file" ]]; then
|
||||
source $conf_file
|
||||
fi
|
||||
|
||||
|
||||
# -------------
|
||||
# --- Set default values for some non existent variables (i.e. no configuration file is present)
|
||||
# -------------
|
||||
|
||||
[[ -z "$_ADMIN_EMAIL" ]] && _ADMIN_EMAIL="$DEFAULT_ADMIN_EMAIL"
|
||||
[[ -z "$_SASL_AUTH" ]] && _SASL_AUTH="$DEFAULT_SASL_AUTH"
|
||||
|
||||
if [[ -z "$_HOSTNAME" ]] ; then
|
||||
_HOSTNAME="$(hostname -f)"
|
||||
_HOSTNAME_SHORT="$(hostname)"
|
||||
[[ "$_HOSTNAME" = "$_HOSTNAME_SHORT" ]] && _HOSTNAME=""
|
||||
fi
|
||||
|
||||
|
||||
clear
|
||||
echo -e "\033[21G\033[32mInstallation script for Postfix basic mailsystem \033[m"
|
||||
echo
|
||||
@ -124,6 +135,24 @@ else
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
# -------------
|
||||
# --- Some further default values depending on Hostname
|
||||
# -------------
|
||||
|
||||
# - Set default values for ipv4- and ipv6-address
|
||||
# -
|
||||
if [[ -z $_IPV4 ]] && [[ -n "$_HOSTNAME" ]] && [[ -x "$(which dig)" ]]; then
|
||||
_IPV4="$(dig +short "$_HOSTNAME" A)"
|
||||
fi
|
||||
if [[ -z $_IPV6 ]] && [[ -n "$_HOSTNAME" ]] && [[ -x "$(which dig)" ]]; then
|
||||
_IPV6="$(dig +short "$_HOSTNAME" AAAA)"
|
||||
fi
|
||||
if [[ -z $_IPV6 ]]; then
|
||||
_IPV6=None
|
||||
fi
|
||||
|
||||
|
||||
IPV4=
|
||||
echo ""
|
||||
echo -e "\033[32m--\033[m"
|
||||
@ -239,6 +268,21 @@ else
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
# -------------
|
||||
# --- Some further default values depending on sasl authentification
|
||||
# -------------
|
||||
|
||||
# - Set default value for relay host if sasl authentification should be
|
||||
# - supported and value for _RELAY_HOST not given
|
||||
# -
|
||||
if [[ "$SASL_AUTH" = "yes" ]] || $SASL_AUTH ; then
|
||||
[[ -z "$_RELAY_HOST" ]] && _RELAY_HOST="$DEFAULT_RELAY_HOST"
|
||||
fi
|
||||
|
||||
|
||||
|
||||
if [[ "$SASL_AUTH" = "yes" ]] || $SASL_AUTH ; then
|
||||
SASL_AUTH=true
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user