fix for server restart survivability

This commit is contained in:
Mr. Blue Coat 2022-01-16 18:57:56 -07:00 committed by GitHub
parent 1caf8e5dcd
commit 11fe7f6f65
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 37 additions and 37 deletions

View File

@ -57,11 +57,9 @@ sudo apt update && sudo apt install -y dnsutils
Create a directory to store SimpleLogin data: Create a directory to store SimpleLogin data:
```bash ```bash
cd / mkdir -p /sl/pgp # to store PGP key
mkdir sl mkdir /sl/db # to store database
mkdir sl/pgp # to store PGP key mkdir /sl/upload # to store quarantine emails
mkdir sl/db # to store database
mkdir sl/upload # to store quarantine emails
``` ```
### DKIM ### DKIM
@ -75,9 +73,8 @@ Setting up DKIM is highly recommended to reduce the chance your emails ending up
First you need to generate a private and public key for DKIM: First you need to generate a private and public key for DKIM:
```bash ```bash
cd / openssl genrsa -out /dkim.key 1024
openssl genrsa -out dkim.key 1024 openssl rsa -in /dkim.key -pubout -out /dkim.pub.key
openssl rsa -in dkim.key -pubout -out dkim.pub.key
``` ```
You will need the files `dkim.key` and `dkim.pub.key` for the next steps. You will need the files `dkim.key` and `dkim.pub.key` for the next steps.
@ -142,7 +139,7 @@ then the `PUBLIC_KEY` would be `abcdefgh`.
You can get the `PUBLIC_KEY` by running this command: You can get the `PUBLIC_KEY` by running this command:
```bash ```bash
sed "s/-----BEGIN PUBLIC KEY-----/v=DKIM1; k=rsa; p=/g" dkim.pub.key | sed 's/-----END PUBLIC KEY-----//g' |tr -d '\n' | awk 1 sed "s/-----BEGIN PUBLIC KEY-----/v=DKIM1; k=rsa; p=/g" /dkim.pub.key | sed 's/-----END PUBLIC KEY-----//g' |tr -d '\n' | awk 1
``` ```
To verify, the following command To verify, the following command
@ -209,8 +206,7 @@ If you don't already have Docker installed on your server, please follow the ste
You can also install Docker using the [docker-install](https://github.com/docker/docker-install) script which is You can also install Docker using the [docker-install](https://github.com/docker/docker-install) script which is
```bash ```bash
curl -fsSL https://get.docker.com -o get-docker.sh curl -fsSL https://get.docker.com | sh
sh get-docker.sh
``` ```
### Prepare the Docker network ### Prepare the Docker network
@ -240,7 +236,7 @@ docker run -d \
-e POSTGRES_USER=myuser \ -e POSTGRES_USER=myuser \
-e POSTGRES_DB=simplelogin \ -e POSTGRES_DB=simplelogin \
-p 127.0.0.1:5432:5432 \ -p 127.0.0.1:5432:5432 \
-v $(pwd)/sl/db:/var/lib/postgresql/data \ -v /sl/db:/var/lib/postgresql/data \
--restart always \ --restart always \
--network="sl-network" \ --network="sl-network" \
postgres:12.1 postgres:12.1
@ -419,11 +415,11 @@ Before running the webapp, you need to prepare the database by running the migra
```bash ```bash
docker run --rm \ docker run --rm \
--name sl-migration \ --name sl-migration \
-v $(pwd)/sl:/sl \ -v /sl:/sl \
-v $(pwd)/sl/upload:/code/static/upload \ -v /sl/upload:/code/static/upload \
-v $(pwd)/dkim.key:/dkim.key \ -v /dkim.key:/dkim.key \
-v $(pwd)/dkim.pub.key:/dkim.pub.key \ -v /dkim.pub.key:/dkim.pub.key \
-v $(pwd)/simplelogin.env:/code/.env \ -v /simplelogin.env:/code/.env \
--network="sl-network" \ --network="sl-network" \
simplelogin/app:3.4.0 flask db upgrade simplelogin/app:3.4.0 flask db upgrade
``` ```
@ -435,10 +431,10 @@ Init data
```bash ```bash
docker run --rm \ docker run --rm \
--name sl-init \ --name sl-init \
-v $(pwd)/sl:/sl \ -v /sl:/sl \
-v $(pwd)/simplelogin.env:/code/.env \ -v /simplelogin.env:/code/.env \
-v $(pwd)/dkim.key:/dkim.key \ -v /dkim.key:/dkim.key \
-v $(pwd)/dkim.pub.key:/dkim.pub.key \ -v /dkim.pub.key:/dkim.pub.key \
--network="sl-network" \ --network="sl-network" \
simplelogin/app:3.4.0 python init_app.py simplelogin/app:3.4.0 python init_app.py
``` ```
@ -448,11 +444,11 @@ Now, it's time to run the `webapp` container!
```bash ```bash
docker run -d \ docker run -d \
--name sl-app \ --name sl-app \
-v $(pwd)/sl:/sl \ -v /sl:/sl \
-v $(pwd)/sl/upload:/code/static/upload \ -v /sl/upload:/code/static/upload \
-v $(pwd)/simplelogin.env:/code/.env \ -v /simplelogin.env:/code/.env \
-v $(pwd)/dkim.key:/dkim.key \ -v /dkim.key:/dkim.key \
-v $(pwd)/dkim.pub.key:/dkim.pub.key \ -v /dkim.pub.key:/dkim.pub.key \
-p 127.0.0.1:7777:7777 \ -p 127.0.0.1:7777:7777 \
--restart always \ --restart always \
--network="sl-network" \ --network="sl-network" \
@ -464,11 +460,11 @@ Next run the `email handler`
```bash ```bash
docker run -d \ docker run -d \
--name sl-email \ --name sl-email \
-v $(pwd)/sl:/sl \ -v /sl:/sl \
-v $(pwd)/sl/upload:/code/static/upload \ -v /sl/upload:/code/static/upload \
-v $(pwd)/simplelogin.env:/code/.env \ -v /simplelogin.env:/code/.env \
-v $(pwd)/dkim.key:/dkim.key \ -v /dkim.key:/dkim.key \
-v $(pwd)/dkim.pub.key:/dkim.pub.key \ -v /dkim.pub.key:/dkim.pub.key \
-p 127.0.0.1:20381:20381 \ -p 127.0.0.1:20381:20381 \
--restart always \ --restart always \
--network="sl-network" \ --network="sl-network" \
@ -480,11 +476,11 @@ And finally the `job runner`
```bash ```bash
docker run -d \ docker run -d \
--name sl-job-runner \ --name sl-job-runner \
-v $(pwd)/sl:/sl \ -v /sl:/sl \
-v $(pwd)/sl/upload:/code/static/upload \ -v /sl/upload:/code/static/upload \
-v $(pwd)/simplelogin.env:/code/.env \ -v /simplelogin.env:/code/.env \
-v $(pwd)/dkim.key:/dkim.key \ -v /dkim.key:/dkim.key \
-v $(pwd)/dkim.pub.key:/dkim.pub.key \ -v /dkim.pub.key:/dkim.pub.key \
--restart always \ --restart always \
--network="sl-network" \ --network="sl-network" \
simplelogin/app:3.4.0 python job_runner.py simplelogin/app:3.4.0 python job_runner.py
@ -532,13 +528,17 @@ UPDATE users SET lifetime = TRUE;
exit exit
``` ```
Once you've created all your desired login accounts, add these lines to `/simplelogin.env` to disable further registrations, then restart to apply: Once you've created all your desired login accounts, add these lines to `/simplelogin.env` to disable further registrations:
``` ```
DISABLE_REGISTRATION=1 DISABLE_REGISTRATION=1
DISABLE_ONBOARDING=true DISABLE_ONBOARDING=true
``` ```
Then restart the web app to apply: `docker restart sl-app`
### Donations Welcome
You don't have to pay anything to SimpleLogin to use all its features. You don't have to pay anything to SimpleLogin to use all its features.
If you like the project, you can make a donation on our Patreon page at https://www.patreon.com/simplelogin If you like the project, you can make a donation on our Patreon page at https://www.patreon.com/simplelogin