mailcow / mailcow-dockerized

mailcow: dockerized - 🐮 + 🐋 = 💕
https://mailcow.email
GNU General Public License v3.0
9.08k stars 1.19k forks source link

Update via cronjob #2655

Closed xopez closed 5 years ago

xopez commented 5 years ago

Is your feature request related to a problem? Please describe. I don't think cause I didn't find anything.

Describe the solution you'd like I only know the way of updating with ´./update.sh´. I want to automate the process. Since you must accept the stop of the containers, you can't really automate it. I want simply to ad a cronjob with a script, where I change the directory and start the update-file. If there is already such a feature ignore this request.

sriccio commented 5 years ago

If you really want to do this you could crontab a script like:

#!/bin/bash
MCDIR=/your/mailcow/dir
cd $MCDIR
yes | ./update.sh >>$MCDIR/update.log
exit 0

This should run the script auto answeing yes to the prompts and log the result to a file so you can review if something goes wrong.

However you should not run it too often as it brings down the services for a good minute at least.

andryyy commented 5 years ago

Yes, indeed, it is dangerous. It is better to always watch the update process.

xopez commented 5 years ago

Thanks for the little script. Maybe I just let the cronjob out and do this manually once a month.

sriccio commented 5 years ago

Yes, you might miss for exemple some merge conflits problems you have to resolve manually if you customized some config stuff if you modded some files

xopez commented 5 years ago

I just use the default stuff. Closing this for now.

magnetic5355 commented 8 months ago

If you really want to do this you could crontab a script like:

#!/bin/bash
MCDIR=/your/mailcow/dir
cd $MCDIR
yes | ./update.sh >>$MCDIR/update.log
exit 0

This should run the script auto answeing yes to the prompts and log the result to a file so you can review if something goes wrong.

However you should not run it too often as it brings down the services for a good minute at least.

Modified script so that it will not execute the update script if there are no updates. The script can now be run daily without a service restart.

#!/bin/bash

MCDIR=/opt/mailcow-dockerized
cd $MCDIR

checkServer=$(./update.sh --check)

echo $checkServer

if [[ $checkServer =~ "No updates available" ]]; then
  echo "no update"
else
  echo "update"
  yes | ./update.sh >>$MCDIR/update.log
fi

exit 0