diff --git a/CHANGELOG b/CHANGELOG index 0a2bcf41..fa8d22e9 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -8,10 +8,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] Support PGP -Take into account Sender header -## [1.1.0] - 2020-03-13 +## [2.0.0] - 2020-03-13 Support multiple Mailboxes +Take into account Sender header ## [1.0.5] - 2020-02-24 Improve email forwarding. diff --git a/README.md b/README.md index 49818b22..a366e4ba 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ docker run --name sl -it --rm \ -e RESET_DB=true \ -e CONFIG=/code/example.env \ -p 7777:7777 \ - simplelogin/app:1.1.0 python server.py + simplelogin/app:2.0.0 python server.py ``` Then open http://localhost:7777, you should be able to login with `john@wick.com/password` account! @@ -463,7 +463,7 @@ sudo docker run --rm \ -v $(pwd)/dkim.pub.key:/dkim.pub.key \ -v $(pwd)/simplelogin.env:/code/.env \ --network="sl-network" \ - simplelogin/app:1.1.0 flask db upgrade + simplelogin/app:2.0.0 flask db upgrade ``` This command could take a while to download the `simplelogin/app` docker image. @@ -479,7 +479,7 @@ sudo docker run -d \ -p 7777:7777 \ --restart always \ --network="sl-network" \ - simplelogin/app:1.1.0 + simplelogin/app:2.0.0 ``` Next run the `email handler` @@ -493,7 +493,7 @@ sudo docker run -d \ -p 20381:20381 \ --restart always \ --network="sl-network" \ - simplelogin/app:1.1.0 python email_handler.py + simplelogin/app:2.0.0 python email_handler.py ``` ### Nginx diff --git a/docs/upgrade.md b/docs/upgrade.md index 04115019..3341a749 100644 --- a/docs/upgrade.md +++ b/docs/upgrade.md @@ -1,6 +1,55 @@ -# Upgrade to 1.1.0 from 1.0.5 +Upgrading SimpleLogin usually consists of simply pulling the latest version, stop & re-run SimpleLogin containers: *sl-migration*, *sl-app* and *sl-email*. It's not necessary to restart *sl-db* as it uses Postgres image. -1.1.0 comes with mailbox feature that requires running a script that puts all existing users to "full-mailbox" mode. +No emails or any data is lost in the upgrade process. The same process is by the way used by the SimpleLogin SaaS version which is deployed several times per day. + +Sometimes upgrade to a major version might require running a manual migration. This is for example the case when upgrading to 2.0.0. + +```bash +# Pull the latest version +sudo docker pull simplelogin/app:2.0.0 + +# Stop SimpleLogin containers +sudo docker stop sl-email sl-migration sl-app + +# Make sure to remove these containers to avoid conflict +sudo docker rm -f sl-email sl-migration sl-app + +# Run the database migration +sudo docker run --rm \ + --name sl-migration \ + -v $(pwd)/dkim.key:/dkim.key \ + -v $(pwd)/dkim.pub.key:/dkim.pub.key \ + -v $(pwd)/simplelogin.env:/code/.env \ + --network="sl-network" \ + simplelogin/app:2.0.0 flask db upgrade + +# Run the webapp container +sudo docker run -d \ + --name sl-app \ + -v $(pwd)/simplelogin.env:/code/.env \ + -v $(pwd)/dkim.key:/dkim.key \ + -v $(pwd)/dkim.pub.key:/dkim.pub.key \ + -p 7777:7777 \ + --restart always \ + --network="sl-network" \ + simplelogin/app:2.0.0 + +# Run the email handler container +sudo docker run -d \ + --name sl-email \ + -v $(pwd)/simplelogin.env:/code/.env \ + -v $(pwd)/dkim.key:/dkim.key \ + -v $(pwd)/dkim.pub.key:/dkim.pub.key \ + -p 20381:20381 \ + --restart always \ + --network="sl-network" \ + simplelogin/app:2.0.0 python email_handler.py +``` + + +## Upgrade to 2.0.0 from 1.0.5 + +2.0.0 comes with mailbox feature that requires running a script that puts all existing users to "full-mailbox" mode. Please connect to your SimpleLogin container and runs this script: @@ -13,7 +62,7 @@ docker exec -it sl-app python shell.py Then copy and run this below script: ```python -"""This ad-hoc script is to be run when upgrading from 1.0.5 to 1.1.0 +"""This ad-hoc script is to be run when upgrading from 1.0.5 to 2.0.0 """ from app.extensions import db from app.log import LOG diff --git a/scripts/__init__.py b/scripts/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/scripts/migrate-1.1.0.py b/scripts/migrate-1.1.0.py deleted file mode 100644 index 9effde0f..00000000 --- a/scripts/migrate-1.1.0.py +++ /dev/null @@ -1,31 +0,0 @@ -"""This ad-hoc script is to be run when upgrading from 1.0.5 to 1.1.0 -""" -from app.extensions import db -from app.log import LOG -from app.models import Mailbox, GenEmail, User - - -def convert_user_full_mailbox(user): - # create a default mailbox - default_mb = Mailbox.get_by(user_id=user.id, email=user.email) - if not default_mb: - LOG.d("create default mailbox for user %s", user) - default_mb = Mailbox.create(user_id=user.id, email=user.email, verified=True) - db.session.commit() - - # assign existing alias to this mailbox - for gen_email in GenEmail.query.filter_by(user_id=user.id): - if not gen_email.mailbox_id: - LOG.d("Set alias %s mailbox to default mailbox", gen_email) - gen_email.mailbox_id = default_mb.id - - # finally set user to full_mailbox - user.full_mailbox = True - user.default_mailbox_id = default_mb.id - db.session.commit() - - -if __name__ == "__main__": - for user in User.query.all(): - if not user.full_mailbox: - convert_user_full_mailbox(user)