Files
shell_sequencer/seqs/postgrey.sh

81 lines
2.0 KiB
Bash
Executable File

#!/bin/bash
toolName=postgrey
toolDeps="$toolName"
toolWhitelistLoc="/etc/postgrey/whitelist_clients"
updateUrl="https://postgrey.schweikert.ch/pub/postgrey_whitelist_clients"
# Get script working directory
# (when called from a different directory)
WDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >>/dev/null 2>&1 && pwd )"
CONFIG=0
CONFIG_FILE_NAME="${toolName}.cfg"
CONFIG_FILE_TEMPLATE="$WDIR/${CONFIG_FILE_NAME}.example"
#step_config() {
# echo "Called once before executing steps."
# ## e.g. to source a config file manually:
# #. "$CONFIG_FILE"
# ## or to use sequencer api:
# #initSeqConfig "$CONFIG_FILE_NAME" "$CONFIG_FILE_TEMPLATE"
# #if [ $? -eq 0 ] ; then
# # CONFIG=1
# #fi
#}
step_1_info() { echo "Install $toolDeps"; }
step_1_alias() { ALIAS="install"; }
step_1() {
local aptOpt=
if [ $QUIET -ne 0 ];then
aptOpt="-y"
fi
exe apt update
exe apt install "$toolDeps" $aptOpt
}
step_2_info() {
echo "Add cron to update whitelist_clients from"
echoinfo "$updateUrl"
}
step_2_alias() { ALIAS="cron"; }
step_2() {
addConf -s "$postCron" "$postCronLoc"
}
postCronLoc="/etc/cron.d/postgreyWhitelistUpdate"
postCron="# -q quiet -N timestamping (overwrite existing file) -O target file
01 23 5 * * root /usr/bin/wget -qNO \"$toolWhitelistLoc\" $updateUrl && /usr/sbin/service postgrey restart"
step_3_info() { echo "Configuration notes"; }
step_3_alias() { ALIAS="notes"; }
step_3() {
echo "$toolNotes"
}
toolNotes="
# Reduce default message delay to 1 minute
[/etc/default/postgrey]
POSTGREY_OPTS=\"--inet=10023 --delay=60\"
# Custom local whitelist rules
[/etc/postgrey/whitelist_clients.local]
# Rule examples
# own domains
mydomain.com
# own network
/^.*\.(lan|local)$/
192.168.0.0/24
fd21::/64
# External domains in frequent use
# Amazon mail system
amazonses.com
"
step_10_info() { echo "Restart $toolName"; }
step_10_alias() { ALIAS="restart"; }
step_10() {
exe service $toolName restart
}
VERSION_SEQREV=11
. /usr/local/bin/sequencer.sh