parent
9a2dcd5a77
commit
01ef678823
1 changed files with 51 additions and 44 deletions
23
README.md
23
README.md
|
@ -13,8 +13,8 @@ apt install -y pipx && pipx install uv
|
||||||
|
|
||||||
Configuration is done by environment variables, prefixed by `SMS_HANDLER_`:
|
Configuration is done by environment variables, prefixed by `SMS_HANDLER_`:
|
||||||
|
|
||||||
* `SMS_HANDLER_MAIL_SENDER`: origin 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_TO`: destination email address (default: *username*@localhost)
|
||||||
* `SMS_HANDLER_MAIL_SERVER`: address of the mail server (default: 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_PORT`: port of the mail server (default: 25)
|
||||||
* `SMS_HANDLER_MAIL_SERVER_START_TLS`: initiate mail server connection with TLS (default: no)
|
* `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
|
### In foreground
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
fastapi run server:app
|
sms-handler
|
||||||
```
|
```
|
||||||
|
|
||||||
Try `fastapi --help` for configuration of the server:
|
Set port and listen address:
|
||||||
port, address to listen on, etc. For example:
|
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
fastapi run server:app --port 8025
|
sms-handler --port 80125 --host 192.168.100.55
|
||||||
```
|
```
|
||||||
|
|
||||||
### As a deamon (Systemd)
|
### 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,
|
Pass the settings for the web server (listen address, port) in the ExecStart statement,
|
||||||
and the parameters as `Environment=MAIL_SERVER_START_TLS=yes`.
|
and the parameters as `Environment=MAIL_SERVER_START_TLS=yes`.
|
||||||
|
|
||||||
|
```systemd
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=SMS handler
|
Description=SMS handler
|
||||||
|
|
||||||
[Service]
|
[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_SENDER=snoopy@peanuts.com
|
||||||
Environment=SMS_HANDLER_MAIL_TO=snoopy@peanuts.com
|
Environment=SMS_HANDLER_MAIL_TO=snoopy@peanuts.com
|
||||||
Restart=on-failure
|
Restart=on-failure
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=default.target
|
WantedBy=default.target
|
||||||
|
```
|
||||||
|
|
||||||
### Container
|
### Container
|
||||||
|
|
||||||
Use `podman` or `docker`:
|
Use `podman` or `docker`:
|
||||||
|
|
||||||
|
```sh
|
||||||
podman run tiptop:5000/sms_handler
|
podman run tiptop:5000/sms_handler
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
**Note**: the container is not published publicly yet.
|
||||||
|
|
||||||
Pass parameters like this:
|
Pass parameters like this:
|
||||||
|
|
||||||
```sh
|
```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`:
|
For a rootless container, create a file in `.config/containers/systemd/sms-handler.container`:
|
||||||
|
|
||||||
|
```systemd
|
||||||
[Container]
|
[Container]
|
||||||
ContainerName=sms-handler
|
ContainerName=sms-handler
|
||||||
Environment=SMS_HANDLER_MAIL_SENDER=snoopy@peanuts.com
|
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]
|
[Install]
|
||||||
WantedBy=default.target
|
WantedBy=default.target
|
||||||
|
```
|
||||||
|
|
||||||
Request systemd to reload configuration, creating the service for this container:
|
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`:
|
For a rootless container, create a file in `/etc/containers/systemd/sms-handler.container`:
|
||||||
|
|
||||||
|
```systemd
|
||||||
[Container]
|
[Container]
|
||||||
ContainerName=sms-handler
|
ContainerName=sms-handler
|
||||||
Environment=SMS_HANDLER_MAIL_SENDER=snoopy@peanuts.com
|
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]
|
[Install]
|
||||||
WantedBy=default.target
|
WantedBy=default.target
|
||||||
|
```
|
||||||
|
|
||||||
Request systemd to reload configuration, creating the service for this container:
|
Request systemd to reload configuration, creating the service for this container:
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue