130 lines
3.6 KiB
Bash
Executable File
130 lines
3.6 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Collection of simple setup tasks
|
|
# e.g. Ability to send mail (ssmtp)
|
|
|
|
sc_configLoc="./basics"
|
|
|
|
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
|
|
endReturn -o $? "ssmtp installation failed"
|
|
}
|
|
SSMTP_DEPS="ssmtp"
|
|
|
|
step_11_info() { echo "ssmtp setup"; }
|
|
step_11_alias() { echo "ssmtpSetup"; }
|
|
step_11() {
|
|
if [ ! -f "$CONFIG_FILE_SSMTP" ] ; then
|
|
error -e "User config ($CONFIG_FILE_SSMTP) not found"
|
|
error -e " See $CONFIG_FILE_SSMTP_TEMPLATE"
|
|
return 1
|
|
fi
|
|
addConf -c -f "$CONFIG_FILE_SSMTP" "$CONFIG_LOC_SSMTP"
|
|
endReturn -o $? "Could not write ssmtp configuration"
|
|
|
|
if [ ! -f "$CONFIG_FILE_SSMTP_AL" ] ; then
|
|
warning -e "User aliases ($CONFIG_FILE_SSMTP_AL) not found"
|
|
error -e " See $CONFIG_FILE_SSMTP_TEMPLATE or modify $CONFIG_LOC_SSMTP_AL directly"
|
|
return 1
|
|
fi
|
|
addConf -c -f "$CONFIG_FILE_SSMTP_AL" "$CONFIG_LOC_SSMTP_AL"
|
|
endReturn -o $? "Could not write ssmtp aliases"
|
|
}
|
|
CONFIG_LOC_SSMTP="/etc/ssmtp/ssmtp.conf"
|
|
CONFIG_LOC_SSMTP_AL="/etc/ssmtp/revaliases"
|
|
CONFIG_FILE_SSMTP="$sc_configLoc/ssmtp.cfg"
|
|
CONFIG_FILE_SSMTP_TEMPLATE="${CONFIG_FILE_SSMTP}.example"
|
|
CONFIG_FILE_SSMTP_AL="$sc_configLoc/revaliases.cfg"
|
|
CONFIG_FILE_SSMTP_AL_TEMPLATE="${CONFIG_FILE_SSMTP}.example"
|
|
|
|
step_13_info() {
|
|
echoinfoArgs "<MAILADDRESS>"; echo -n "Send test E-Mail"
|
|
if [ -z "${2:-}" ] ; then
|
|
echo " to MAILADDRESS"
|
|
else
|
|
echo " to ${2}"
|
|
fi
|
|
}
|
|
step_13_alias() { echo "smtpTest"; }
|
|
step_13() {
|
|
[[ -z "${2:-}" ]] && fatal -e "No mailaddress provided"
|
|
|
|
exep echo "Subject: sendmail test" \| sendmail -v "$2"
|
|
}
|
|
|
|
step_15_info() { echo "ssmtp help"; }
|
|
step_15_alias() { echo "ssmtpHelp"; }
|
|
step_15() {
|
|
echo " Configuration files expected by this seq:"
|
|
echo
|
|
echo " - $CONFIG_FILE_SSMTP"
|
|
echo " (see template: $CONFIG_FILE_SSMTP_TEMPLATE)"
|
|
echo " - $CONFIG_FILE_SSMTP_AL optional"
|
|
echo " (see template: $CONFIG_FILE_SSMTP_AL_TEMPLATE)"
|
|
echo
|
|
echo " ssmtp configuration files"
|
|
echo
|
|
echo " - $CONFIG_LOC_SSMTP"
|
|
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
|