basics - new steps to install msmtp (recommended replacement for ssmtp)

This commit is contained in:
2022-09-06 23:46:01 +02:00
parent ed6815b0d6
commit 6d2af2d866

View File

@@ -3,21 +3,19 @@
# Collection of simple setup tasks
# e.g. Ability to send mail (ssmtp)
# Get script working directory
# (when called from a different directory)
WDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >>/dev/null 2>&1 && pwd )"
WSUBDIR="${WDIR}/basics"
sc_configLoc="./basics"
#step_config() {
step_config() {
# echo "Called once before executing steps."
# echo "e.g. to source a config file:"
# #. "$CONFIG_FILE"
#}
sc_configLoc="${seq_origin}/basics"
}
step_10_info() { echo "ssmtp installation"; }
step_10_alias() { echo "ssmtp"; }
step_10() {
exe apt update && apt install "$SSMTP_DEPS"
exe apt update && apt install $SSMTP_DEPS
endReturn -o $? "ssmtp installation failed"
}
SSMTP_DEPS="ssmtp"
@@ -43,22 +41,20 @@ step_11() {
}
CONFIG_LOC_SSMTP="/etc/ssmtp/ssmtp.conf"
CONFIG_LOC_SSMTP_AL="/etc/ssmtp/revaliases"
CONFIG_FILE_SSMTP="$WSUBDIR/ssmtp.cfg"
CONFIG_FILE_SSMTP="$sc_configLoc/ssmtp.cfg"
CONFIG_FILE_SSMTP_TEMPLATE="${CONFIG_FILE_SSMTP}.example"
CONFIG_FILE_SSMTP_AL="$WSUBDIR/revaliases.cfg"
CONFIG_FILE_SSMTP_AL="$sc_configLoc/revaliases.cfg"
CONFIG_FILE_SSMTP_AL_TEMPLATE="${CONFIG_FILE_SSMTP}.example"
step_13_info() {
echo -n "Send test E-Mail to "
if [ -z $2 ] ; then echo "<MAILADDRESS>"; else echo "$2"; fi
if [ -z "${2:-}" ] ; then echo "<MAILADDRESS>"; else echo "$2"; fi
}
step_13_alias() { echo "ssmtpTest"; }
step_13_alias() { echo "smtpTest"; }
step_13() {
if [ ! -z "$2" ] || [ "$2" == "" ] ; then
error -e "No mailaddress provided"
fi
[[ -z "${2:-}" ]] && fatal -e "No mailaddress provided"
exep "echo \"Subject: sendmail test\" | sendmail -v $2"
exep echo "Subject: sendmail test" \| sendmail -v "$2"
}
step_15_info() { echo "ssmtp help"; }
@@ -77,5 +73,53 @@ step_15() {
echo " - $CONFIG_LOC_SSMTP_AL"
}
step_30_info() { echo "msmtp setup"; }
step_30_alias() { echo "msmtp"; }
step_30() {
exe apt update
exe apt install ${sq_msmtpDeps:?}
}
sq_msmtpDeps="msmtp msmtp-mta"
step_31_info() { echo "Init config"; }
step_31() {
if addConf -c "${sc_msmtpConfig}" "${sc_msmtpConfigLoc}" ; then
if confirm "Edit this file now?" "n" ; then
editor "${sc_msmtpConfigLoc}"
fi
else
fatal "Couldn't create msmtp system configuration file ${sc_msmtpConfigLoc}"
fi
}
sc_msmtpConfigLoc="/etc/msmtprc"
sc_msmtpConfig="# Example for a system wide configuration file
# A system wide configuration file is optional.
# If it exists, it usually defines a default account.
# This allows msmtp to be used like /usr/sbin/sendmail.
account default
# The SMTP smarthost (use FQDN from certificate if possible)
host mail
# Use TLS on port 465
port 25
tls on
tls_starttls on
# Usually not need on debian systems
#tls_trust_file /etc/ssl/certs/ca-certificates.crt
# Construct envelope-from addresses of the form "user@oursite.example"
#auto_from on
#maildomain oursite.example
# or set a static from address
#from noreply@yourdomain.com
# Syslog logging with facility LOG_MAIL instead of the default LOG_USER
syslog LOG_MAIL"
# shellcheck disable=SC2034 # Appears unused
readonly sqr_minVersion=16
# shellcheck disable=SC1091 # Don't follow this source
. /usr/local/bin/sequencer.sh