parent
9a2dcd5a77
commit
01ef678823
1 changed files with 51 additions and 44 deletions
95
README.md
95
README.md
|
@ -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`.
|
||||
|
||||
[Unit]
|
||||
Description=SMS handler
|
||||
|
||||
[Service]
|
||||
ExecStart=fastapi run server:app
|
||||
Environment=SMS_HANDLER_MAIL_SENDER=snoopy@peanuts.com
|
||||
Environment=SMS_HANDLER_MAIL_TO=snoopy@peanuts.com
|
||||
Restart=on-failure
|
||||
|
||||
[Install]
|
||||
WantedBy=default.target
|
||||
```systemd
|
||||
[Unit]
|
||||
Description=SMS handler
|
||||
|
||||
[Service]
|
||||
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,19 +87,21 @@ Systemd can "orchestrate" containers easily thanks to podman.
|
|||
|
||||
For a rootless container, create a file in `.config/containers/systemd/sms-handler.container`:
|
||||
|
||||
[Container]
|
||||
ContainerName=sms-handler
|
||||
Environment=SMS_HANDLER_MAIL_SENDER=snoopy@peanuts.com
|
||||
Environment=SMS_HANDLER_MAIL_TO=snoopy@peanuts.com
|
||||
Image=tiptop:5000/sms_handler
|
||||
Network=podman
|
||||
PublishPort=80°25:8025
|
||||
|
||||
[Service]
|
||||
Restart=always
|
||||
|
||||
[Install]
|
||||
WantedBy=default.target
|
||||
```systemd
|
||||
[Container]
|
||||
ContainerName=sms-handler
|
||||
Environment=SMS_HANDLER_MAIL_SENDER=snoopy@peanuts.com
|
||||
Environment=SMS_HANDLER_MAIL_TO=snoopy@peanuts.com
|
||||
Image=tiptop:5000/sms_handler
|
||||
Network=podman
|
||||
PublishPort=80°25:8025
|
||||
|
||||
[Service]
|
||||
Restart=always
|
||||
|
||||
[Install]
|
||||
WantedBy=default.target
|
||||
```
|
||||
|
||||
Request systemd to reload configuration, creating the service for this container:
|
||||
|
||||
|
@ -120,19 +125,21 @@ sudo loginctl enable-linger snoopy
|
|||
|
||||
For a rootless container, create a file in `/etc/containers/systemd/sms-handler.container`:
|
||||
|
||||
[Container]
|
||||
ContainerName=sms-handler
|
||||
Environment=SMS_HANDLER_MAIL_SENDER=snoopy@peanuts.com
|
||||
Environment=SMS_HANDLER_MAIL_TO=snoopy@peanuts.com
|
||||
Image=tiptop:5000/sms_handler
|
||||
Network=podman
|
||||
PublishPort=80°25:8025
|
||||
|
||||
[Service]
|
||||
Restart=always
|
||||
|
||||
[Install]
|
||||
WantedBy=default.target
|
||||
```systemd
|
||||
[Container]
|
||||
ContainerName=sms-handler
|
||||
Environment=SMS_HANDLER_MAIL_SENDER=snoopy@peanuts.com
|
||||
Environment=SMS_HANDLER_MAIL_TO=snoopy@peanuts.com
|
||||
Image=tiptop:5000/sms_handler
|
||||
Network=podman
|
||||
PublishPort=80°25:8025
|
||||
|
||||
[Service]
|
||||
Restart=always
|
||||
|
||||
[Install]
|
||||
WantedBy=default.target
|
||||
```
|
||||
|
||||
Request systemd to reload configuration, creating the service for this container:
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue