mirror of
https://github.com/docker-mailserver/docker-mailserver.git
synced 2025-07-08 00:14:56 +02:00
start-mailserver.sh split (#1820)
* splitting start-mailserver.sh * refactoring part 2 * refactored setup-stack.sh * stzarted adjusting target/bin/*.sh to use new usage format * corrected lowercase-uppercase test error * better handling of .bashrc variable export * linting tests and fix for default assignements * last stylistic changes and rebase
This commit is contained in:
parent
2262d354db
commit
c881facbd2
21 changed files with 2214 additions and 2278 deletions
64
target/scripts/startup/misc-stack.sh
Normal file
64
target/scripts/startup/misc-stack.sh
Normal file
|
@ -0,0 +1,64 @@
|
|||
#! /bin/bash
|
||||
|
||||
function start_misc
|
||||
{
|
||||
_notify 'inf' 'Starting miscellaneous tasks'
|
||||
for FUNC in "${FUNCS_MISC[@]}"
|
||||
do
|
||||
${FUNC} || _defunc
|
||||
done
|
||||
}
|
||||
|
||||
# consolidate all states into a single directory
|
||||
# (/var/mail-state) to allow persistence using docker volumes
|
||||
function _misc_save_states
|
||||
{
|
||||
local STATEDIR FILE FILES
|
||||
|
||||
STATEDIR='/var/mail-state'
|
||||
|
||||
if [[ ${ONE_DIR} -eq 1 ]] && [[ -d ${STATEDIR} ]]
|
||||
then
|
||||
_notify 'inf' "Consolidating all state onto ${STATEDIR}"
|
||||
|
||||
FILES=(
|
||||
spool/postfix
|
||||
lib/postfix
|
||||
lib/amavis
|
||||
lib/clamav
|
||||
lib/spamassassin
|
||||
lib/fail2ban
|
||||
lib/postgrey
|
||||
lib/dovecot
|
||||
)
|
||||
|
||||
for FILE in "${FILES[@]}"
|
||||
do
|
||||
DEST="${STATEDIR}/${FILE//\//-}"
|
||||
FILE="/var/${FILE}"
|
||||
|
||||
if [[ -d ${DEST} ]]
|
||||
then
|
||||
_notify 'inf' "Destination ${DEST} exists, linking ${FILE} to it"
|
||||
rm -rf "${FILE}"
|
||||
ln -s "${DEST}" "${FILE}"
|
||||
elif [[ -d ${FILE} ]]
|
||||
then
|
||||
_notify 'inf' "Moving contents of ${FILE} to ${DEST}:" "$(ls "${FILE}")"
|
||||
mv "${FILE}" "${DEST}"
|
||||
ln -s "${DEST}" "${FILE}"
|
||||
else
|
||||
_notify 'inf' "Linking ${FILE} to ${DEST}"
|
||||
mkdir -p "${DEST}"
|
||||
ln -s "${DEST}" "${FILE}"
|
||||
fi
|
||||
done
|
||||
|
||||
_notify 'inf' 'Fixing /var/mail-state/* permissions'
|
||||
chown -R clamav /var/mail-state/lib-clamav
|
||||
chown -R postfix /var/mail-state/lib-postfix
|
||||
chown -R postgrey /var/mail-state/lib-postgrey
|
||||
chown -R debian-spamd /var/mail-state/lib-spamassassin
|
||||
chown -R postfix /var/mail-state/spool-postfix
|
||||
fi
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue