Added basics sequence as collection simple setup tasks

Starting with ssmtp
This commit is contained in:
2019-12-13 12:20:31 +01:00
parent d182f5e0c6
commit 0cf41c708d
3 changed files with 106 additions and 0 deletions

76
seqs/basics.sh Executable file
View File

@@ -0,0 +1,76 @@
#!/bin/bash
# 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"
#step_config() {
# echo "Called once before executing steps."
# echo "e.g. to source a config file:"
# #. "$CONFIG_FILE"
#}
step_10_info() { echo "ssmtp installation"; }
step_10_alias() { ALIAS="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() { ALIAS="ssmtpSetup"; }
step_11() {
if [ ! -f "$CONFIG_FILE_SSMTP" ] ; then
echoerr " [E] User config ($CONFIG_FILE_SSMTP) not found"
echoerr " 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
echoerr " [W] User aliases ($CONFIG_FILE_SSMTP_AL) not found"
echoerr " 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="$WSUBDIR/ssmtp.cfg"
CONFIG_FILE_SSMTP_TEMPLATE="${CONFIG_FILE_SSMTP}.example"
CONFIG_FILE_SSMTP_AL="$WSUBDIR/revaliases.cfg"
CONFIG_FILE_SSMTP_AL_TEMPLATE="${CONFIG_FILE_SSMTP}.example"
step_13_info() { echo "ssmtp test <MAILADDRESS>"; }
step_13_alias() { ALIAS="ssmtpTest"; }
step_13() {
if [ ! -z "$2" ] || [ "$2" == "" ] ; then
echoerr " [E] No mailaddress provided"
fi
exep "echo \"Subject: sendmail test\" | sendmail -v $2"
}
step_15_info() { echo "ssmtp help"; }
step_15_alias() { ALIAS="ssmtpHelp"; }
step_15() {
echo " Configuration files expected by this seq:"
echo
echo " - $CONFIG_FILE_SSMTP (see template: $CONFIG_FILE_SSMTP_TEMPLATE)"
echo " - $CONFIG_FILE_SSMTP optional (see template: $CONFIG_FILE_SSMTP_TEMPLATE)"
echo
echo " ssmtp configuration files"
echo
echo " - $CONFIG_LOC_SSMTP"
echo " - $CONFIG_LOC_SSMTP_AL"
}
VERSION_SEQREV=8
. /usr/local/bin/sequencer

View File

@@ -0,0 +1,6 @@
# sSMTP aliases
#
# Format: local_account:outgoing_address:mailhub
#
# Example: root:your_login@your.domain:mailhub.your.domain[:port]
# where [:port] is an optional port number that defaults to 25.

View File

@@ -0,0 +1,24 @@
#
# Config file for sSMTP sendmail
#
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
root=postmaster
# The place where the mail goes. The actual machine name is required no
# MX records are consulted. Commonly mailhosts are named mail.domain.com
mailhub=host:port
#AuthUser=
#AuthPass=
UseTLS=YES
# Where will the mail seem to come from?
rewriteDomain=mydomain.eu
# The full hostname
hostname=mydomain.eu
# Are users allowed to set their own From: address?
# YES - Allow the user to specify their own From: address
# NO - Use the system generated From: address
#FromLineOverride=YES