From 44fb8e61a9e8a7417f1dea0e4d29209812722e7b Mon Sep 17 00:00:00 2001 From: Krispin Date: Fri, 9 Feb 2024 18:31:29 +0100 Subject: [PATCH] fix configs for docker-compose --- Makefile | 2 +- adapters/actor.py | 0 adapters/actor.sh | 4 ++++ adapters/fail-actor.sh | 4 ++++ config/bffh/bffh.dhall | 24 +++++++++++------------- config/mosquitto/mosquitto.conf | 6 +++--- docker-compose.yaml | 8 ++++---- 7 files changed, 27 insertions(+), 21 deletions(-) mode change 100644 => 100755 adapters/actor.py create mode 100755 adapters/actor.sh create mode 100755 adapters/fail-actor.sh diff --git a/Makefile b/Makefile index 0664bd2..d642a21 100644 --- a/Makefile +++ b/Makefile @@ -23,7 +23,7 @@ up: .env ## Start local dev environment with docker-compose @docker-compose -p "${PROJECT}" up --force-recreate down: .env ## Stop local dev environment with docker-compose - @docker-compose -p "${PROJECT}" down + @docker-compose -p "${PROJECT}" down -v ansible-requirements: ## Install ansible requirements via ansible-galaxy. ansible-galaxy collection install -r ./ansible/requirements.yaml diff --git a/adapters/actor.py b/adapters/actor.py old mode 100644 new mode 100755 diff --git a/adapters/actor.sh b/adapters/actor.sh new file mode 100755 index 0000000..704c66f --- /dev/null +++ b/adapters/actor.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +echo "Bash actor called with $@" > /tmp/act +echo "Bash actor called with: $@" diff --git a/adapters/fail-actor.sh b/adapters/fail-actor.sh new file mode 100755 index 0000000..5630f1c --- /dev/null +++ b/adapters/fail-actor.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +echo "This is some error output" > /dev/stderr +exit 115 diff --git a/config/bffh/bffh.dhall b/config/bffh/bffh.dhall index c7e9440..5f4c0b5 100644 --- a/config/bffh/bffh.dhall +++ b/config/bffh/bffh.dhall @@ -21,17 +21,15 @@ -- If you don't specify a port bffh will use the default of `59661` -- 'address' can be a IP address or a hostname -- If bffh can not bind a port for the specified combination if will log an error but *continue with the remaining ports* - { address = "127.0.0.1", port = 59661 }, - { address = "::1", port = 59661 }, - { address = "steak.fritz.box", port = 59661 } + { address = "127.0.0.1", port = 59661 } ], -- Configure TLS. BFFH requires a PEM-encoded certificate and the associated key as two separate files - certfile = "examples/self-signed-cert.pem", - keyfile = "examples/self-signed-key.pem", + certfile = "/etc/cert/cert.pem", + keyfile = "/etc/cert/key.pem", -- BFFH right now requires a running MQTT broker. - mqtt_url = "tcp://localhost:1883", + mqtt_url = "tcp://mosquitto:1883", -- Path to the database file for bffh. bffh will in fact create two files; ${db_path} and ${db_path}.lock. -- BFFH will *not* create any directories so ensure that the directory exists and the user running bffh has write @@ -174,7 +172,7 @@ -- which is configured by the (required) 'cmd' parameter. Paths are relative to PWD of bffh. Systemd -- and similar process managers may change this PWD so it's usually the most future-proof to use -- absolute paths. - cmd = "./examples/actor.sh", + cmd = "/usr/local/lib/bffh/adapters/actor.sh", -- You can pass static args in here, these will be passed to every invocation of the command by this actor. -- args passed here are split by whitespace, so these here will be passed as 5 separate arguments args = "your ad could be here" @@ -182,7 +180,7 @@ }, DoorControl1 = { - -- This actor calls the actor.py script in examples/ + -- This actor calls the actor.py script in /usr/local/lib/bffh/adapters/ -- It gets passed it's own name, so you can have several actors -- from the same script. -- If you need to pass more arguments to the command you can use the `args` key in @@ -190,22 +188,22 @@ module = "Process", -- the `args` are passed in front of all other parameters so they are best suited to -- optional parameters like e.g. the verboseness - params = { cmd = "./examples/actor.py", args = "-vvv" } + params = { cmd = "/usr/local/lib/bffh/adapters/actor.py", args = "-vvv" } }, DoorControl2 = { module = "Process", - params = { cmd = "./examples/actor.py" } + params = { cmd = "/usr/local/lib/bffh/adapters/actor.py" } }, DoorControl3 = { -- This is an example for how it looks like if an actor is misconfigured. -- the actor.py doesn't know anything about DoorControl3 and, if this actor is enabled, -- will return with an error showing up in the server logs. module = "Process", - params = { cmd = "./examples/actor.py" } + params = { cmd = "/usr/local/lib/bffh/adapters/actor.py" } }, - Bash2 = { module = "Process", params = { cmd = "./examples/actor.sh" , args = "this is a different one" }}, - FailBash = { module = "Process", params = { cmd = "./examples/fail-actor.sh" }} + Bash2 = { module = "Process", params = { cmd = "/usr/local/lib/bffh/adapters/actor.sh" , args = "this is a different one" }}, + FailBash = { module = "Process", params = { cmd = "/usr/local/lib/bffh/adapters/fail-actor.sh" }} }, -- Linkng up machines to actors diff --git a/config/mosquitto/mosquitto.conf b/config/mosquitto/mosquitto.conf index d33a1a7..094908a 100644 --- a/config/mosquitto/mosquitto.conf +++ b/config/mosquitto/mosquitto.conf @@ -1,3 +1,3 @@ -persistence true -persistence_location /mosquitto/data/ -log_dest file /mosquitto/log/mosquitto.log \ No newline at end of file +#persistence true +#persistence_location /mosquitto/data/ +#log_dest file /mosquitto/log/mosquitto.log \ No newline at end of file diff --git a/docker-compose.yaml b/docker-compose.yaml index 05351fd..4db504f 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -11,12 +11,12 @@ services: # generate a sample config.toml by running "docker run registry.gitlab.com/fabinfra/fabaccess/bffh:dev-latest --print-default > examples/config.toml" from the project root. You may have to delete the ipv6 listen section. - "./config/bffh:/etc/bffh" - "./adapters:/usr/local/lib/bffh/adapters" - - "./config/cert:/etc/letsencrypt" + - "./config/cert:/etc/cert" - data:/var/lib/bffh - links: - - mqtt + depends_on: + - mosquitto - mqtt: + mosquitto: image: eclipse-mosquitto:1.6.15 ports: - "1883:1883"