This commit is contained in:
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
|
||||
Reference in New Issue
Block a user