mirror of
https://github.com/docker-mailserver/docker-mailserver.git
synced 2025-08-03 17:44:49 +02:00
scripts: refactored daemon-stack.sh
(#2496)
* refactored `daemon-stack.sh` A new method was introduced to uniformaly start daemons and log output accordingly. The methods for daemon start were renamed (plural -> singular), therefore the adjustments in `start-mailserver.sh`. * cleaned Fetchmail setup from `daemon-stack.sh` Not sure why, but the Fetchmail setup was somehow happening in `daemon-stack.sh` - this is not supposed to be the case. I relocated the setup into `setup-stack.sh`, where it belong. * delete old, unnecessary script in `target/bin/` These are unused leftovers from the last commit, that relocated the setup of Fetchmail into `setup.stack.sh`. * corrected changedetector function name * Apply suggestions from code review * adjusted `debug-fetchmail` script It is absolutely fine to source `setup-stack.sh` because sourcing the script does not execute a single function (by desing of the script). This way, we retain functionality. * praise be ShellCheck * added `log.sh` to `debug-fetchmail` as a dependency * final cleanup Co-authored-by: Brennan Kinney <5098581+polarathene@users.noreply.github.com> Co-authored-by: Casper <casperklein@users.noreply.github.com>
This commit is contained in:
parent
7721a48b9b
commit
a54d774587
6 changed files with 175 additions and 204 deletions
|
@ -1,6 +1,11 @@
|
|||
#! /bin/bash
|
||||
|
||||
/usr/local/bin/setup-fetchmail
|
||||
# shellcheck source=../scripts/helpers/log.sh
|
||||
source /usr/local/bin/helpers/log.sh
|
||||
# shellcheck source=../scripts/startup/setup-stack.sh
|
||||
source /usr/local/bin/setup-stack.sh
|
||||
|
||||
_setup_fetchmail
|
||||
|
||||
su -s /bin/sh -c "/usr/bin/fetchmail \
|
||||
--verbose \
|
||||
|
|
|
@ -1,55 +0,0 @@
|
|||
#! /bin/bash
|
||||
|
||||
# Description: This script will split the content of /etc/fetchmailrc into
|
||||
# smaller fetchmailrc files per server [poll] entries. Each
|
||||
# separate fetchmailrc file is stored in /etc/fetchmailrc.d
|
||||
#
|
||||
# The mail purpose for this is to work around what is known
|
||||
# as the Fetchmail IMAP idle issue.
|
||||
#
|
||||
|
||||
FETCHMAILRC="/etc/fetchmailrc"
|
||||
FETCHMAILRCD="/etc/fetchmailrc.d"
|
||||
DEFAULT_FILE="${FETCHMAILRCD}/defaults"
|
||||
|
||||
if [[ ! -r "${FETCHMAILRC}" ]]
|
||||
then
|
||||
_log 'error' "File '${FETCHMAILRC}' not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ! -d ${FETCHMAILRCD} ]]
|
||||
then
|
||||
if ! mkdir "${FETCHMAILRCD}"
|
||||
then
|
||||
_log 'error' "Unable to create folder '${FETCHMAILRCD}'"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
COUNTER=0
|
||||
SERVER=0
|
||||
while read -r LINE
|
||||
do
|
||||
if [[ ${LINE} =~ poll ]]
|
||||
then
|
||||
# If we read "poll" then we reached a new server definition
|
||||
# We need to create a new file with fetchmail defaults from
|
||||
# /etc/fetcmailrc
|
||||
COUNTER=$((COUNTER+1))
|
||||
SERVER=1
|
||||
cat "${DEFAULT_FILE}" > "${FETCHMAILRCD}/fetchmail-${COUNTER}.rc"
|
||||
echo "${LINE}" >> "${FETCHMAILRCD}/fetchmail-${COUNTER}.rc"
|
||||
elif [[ ${SERVER} -eq 0 ]]
|
||||
then
|
||||
# We have not yet found "poll". Let's assume we are still reading
|
||||
# the default settings from /etc/fetchmailrc file
|
||||
echo "${LINE}" >> "${DEFAULT_FILE}"
|
||||
else
|
||||
# Just the server settings that need to be added to the specific rc.d file
|
||||
echo "${LINE}" >> "${FETCHMAILRCD}/fetchmail-${COUNTER}.rc"
|
||||
fi
|
||||
# delete commented lines before parsing
|
||||
done < <(sed '/^[[:space:]]*#/d' "${FETCHMAILRC}")
|
||||
|
||||
rm "${DEFAULT_FILE}"
|
|
@ -1,14 +0,0 @@
|
|||
#! /bin/bash
|
||||
|
||||
CONF=/tmp/docker-mailserver/fetchmail.cf
|
||||
RC=/etc/fetchmailrc
|
||||
|
||||
if [[ -f ${CONF} ]]
|
||||
then
|
||||
cat /etc/fetchmailrc_general "${CONF}" >"${RC}"
|
||||
else
|
||||
cat /etc/fetchmailrc_general >"${RC}"
|
||||
fi
|
||||
|
||||
chmod 700 "${RC}"
|
||||
chown fetchmail:root "${RC}"
|
Loading…
Add table
Add a link
Reference in a new issue