Improve doc
All checks were successful
/ test (push) Successful in 5s

This commit is contained in:
phil 2024-12-01 04:58:49 +01:00
parent 9a2dcd5a77
commit 01ef678823

View file

@ -13,8 +13,8 @@ apt install -y pipx && pipx install uv
Configuration is done by environment variables, prefixed by `SMS_HANDLER_`:
* `SMS_HANDLER_MAIL_SENDER`: origin email address (default: <username>@localhost)
* `SMS_HANDLER_MAIL_TO`: destination email address (default: <username>@localhost)
* `SMS_HANDLER_MAIL_SENDER`: origin email address (default: *username*@localhost)
* `SMS_HANDLER_MAIL_TO`: destination email address (default: *username*@localhost)
* `SMS_HANDLER_MAIL_SERVER`: address of the mail server (default: localhost)
* `SMS_HANDLER_MAIL_SERVER_PORT`: port of the mail server (default: 25)
* `SMS_HANDLER_MAIL_SERVER_START_TLS`: initiate mail server connection with TLS (default: no)
@ -34,14 +34,13 @@ The URI path `/sms-handle` is not configurable.
### In foreground
```sh
fastapi run server:app
sms-handler
```
Try `fastapi --help` for configuration of the server:
port, address to listen on, etc. For example:
Set port and listen address:
```sh
fastapi run server:app --port 8025
sms-handler --port 80125 --host 192.168.100.55
```
### As a deamon (Systemd)
@ -50,26 +49,30 @@ Create a service as follows.
Pass the settings for the web server (listen address, port) in the ExecStart statement,
and the parameters as `Environment=MAIL_SERVER_START_TLS=yes`.
```systemd
[Unit]
Description=SMS handler
[Service]
ExecStart=fastapi run server:app
ExecStart=/home/snoopy/.local/bin/sms-handler
Environment=SMS_HANDLER_MAIL_SENDER=snoopy@peanuts.com
Environment=SMS_HANDLER_MAIL_TO=snoopy@peanuts.com
Restart=on-failure
[Install]
WantedBy=default.target
```
### Container
Use `podman` or `docker`:
```sh
podman run tiptop:5000/sms_handler
```
**Note**: the container is not published publicly yet.
Pass parameters like this:
```sh
@ -84,6 +87,7 @@ Systemd can "orchestrate" containers easily thanks to podman.
For a rootless container, create a file in `.config/containers/systemd/sms-handler.container`:
```systemd
[Container]
ContainerName=sms-handler
Environment=SMS_HANDLER_MAIL_SENDER=snoopy@peanuts.com
@ -97,6 +101,7 @@ For a rootless container, create a file in `.config/containers/systemd/sms-handl
[Install]
WantedBy=default.target
```
Request systemd to reload configuration, creating the service for this container:
@ -120,6 +125,7 @@ sudo loginctl enable-linger snoopy
For a rootless container, create a file in `/etc/containers/systemd/sms-handler.container`:
```systemd
[Container]
ContainerName=sms-handler
Environment=SMS_HANDLER_MAIL_SENDER=snoopy@peanuts.com
@ -133,6 +139,7 @@ For a rootless container, create a file in `/etc/containers/systemd/sms-handler.
[Install]
WantedBy=default.target
```
Request systemd to reload configuration, creating the service for this container: