This commit is contained in:
15
mail-sync/Dockerfile
Normal file
15
mail-sync/Dockerfile
Normal file
@@ -0,0 +1,15 @@
|
||||
FROM alpine:latest
|
||||
|
||||
RUN apk add --no-cache isync cron python3 ca-certificates bash su-exec tzdata
|
||||
|
||||
# Copy configuration template and entrypoint
|
||||
COPY mbsyncrc.template /root/.mbsyncrc.template
|
||||
COPY entrypoint.sh /entrypoint.sh
|
||||
|
||||
RUN chmod +x /entrypoint.sh
|
||||
|
||||
# Create the Maildir directory
|
||||
RUN mkdir -p /Maildir
|
||||
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
CMD ["cron", "-f"]
|
||||
29
mail-sync/entrypoint.sh
Normal file
29
mail-sync/entrypoint.sh
Normal file
@@ -0,0 +1,29 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# Copy the template to the actual config location if it doesn't exist
|
||||
if [ ! -f /root/.mbsyncrc ]; then
|
||||
echo "No .mbsyncrc found. Copying template. PLEASE CONFIGURE THIS FILE."
|
||||
cp /root/.mbsyncrc.template /root/.mbsyncrc
|
||||
fi
|
||||
|
||||
# Set up cron job if not already set
|
||||
if ! crontab -l | grep -q "mbsync -a"; then
|
||||
echo "Setting up mbsync cron job (every 5 minutes)..."
|
||||
(crontab -l 2>/dev/null; echo "*/5 * * * * /usr/bin/mbsync -a >> /var/log/mbsync.log 2>&1") | crontab -
|
||||
fi
|
||||
|
||||
# Make sure log file exists
|
||||
touch /var/log/mbsync.log
|
||||
|
||||
# Run mbsync once on startup
|
||||
echo "Running initial mbsync..."
|
||||
/usr/bin/mbsync -a || echo "Initial mbsync failed, probably needs configuration."
|
||||
|
||||
# Execute the CMD (usually cron -f)
|
||||
if [ "$1" = "cron" ]; then
|
||||
echo "Starting cron daemon..."
|
||||
crond -f -l 2
|
||||
else
|
||||
exec "$@"
|
||||
fi
|
||||
20
mail-sync/mbsyncrc.template
Normal file
20
mail-sync/mbsyncrc.template
Normal file
@@ -0,0 +1,20 @@
|
||||
# IMAPAccount example
|
||||
# Host imap.example.com
|
||||
# User user@example.com
|
||||
# PassCmd "echo password"
|
||||
# SSLType IMAPS
|
||||
|
||||
# IMAPStore example-remote
|
||||
# Account example
|
||||
|
||||
# MaildirStore example-local
|
||||
# SubFolders Verbatim
|
||||
# Path /Maildir/example/
|
||||
# Inbox /Maildir/example/Inbox
|
||||
|
||||
# Channel example
|
||||
# Far :example-remote:
|
||||
# Near :example-local:
|
||||
# Patterns *
|
||||
# Create Both
|
||||
# SyncState *
|
||||
Reference in New Issue
Block a user