Skip to content

Commit

Permalink
Multitenancy support (#17)
Browse files Browse the repository at this point in the history
add multitenancy (multiple agent instances with different cloud servers) support
  • Loading branch information
lostpoint-ru authored Apr 10, 2024
1 parent 28907c7 commit 13996e6
Show file tree
Hide file tree
Showing 11 changed files with 234 additions and 101 deletions.
6 changes: 6 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
wb-cloud-agent (1.4.0) stable; urgency=medium

* Add multi-provider support

-- Aleksandr Kazadaev <[email protected]> Tue, 2 Apr 2024 15:49:17 +0500

wb-cloud-agent (1.3.3) stable; urgency=medium

* Confirm unknown events without handling
Expand Down
4 changes: 2 additions & 2 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Depends: ${misc:Depends},
telegraf-wb-cloud-agent | telegraf,
frpc,
curl,
python3-wb-common (>= 2.1.1)
Recommends: wb-mqtt-homeui (>= 2.77.0~~)
python3-wb-common (>= 2.1.3)
Recommends: wb-mqtt-homeui (>= 2.82.5~~)
Description: Wiren Board Cloud agent
This package provides Wiren Board Cloud agent service.
3 changes: 3 additions & 0 deletions debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@

override_dh_installsystemd:
dh_installsystemd --name=wb-cloud-agent
dh_installsystemd --name=wb-cloud-agent@ --no-start --no-enable
dh_installsystemd --name=wb-cloud-agent-telegraf --no-start --no-enable
dh_installsystemd --name=wb-cloud-agent-telegraf@ --no-start --no-enable
dh_installsystemd --name=wb-cloud-agent-frpc --no-start --no-enable
dh_installsystemd --name=wb-cloud-agent-frpc@ --no-start --no-enable
8 changes: 5 additions & 3 deletions debian/wb-cloud-agent.postinst
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ cert_is_valid() {

ORIGINAL_CERT=/etc/ssl/certs/device_bundle.crt.pem
TARGET_CERT=/var/lib/wb-cloud-agent/device_bundle.crt.pem
AGENT_CONFIG="/mnt/data/etc/wb-cloud-agent.conf"

if [ ! -f "$ORIGINAL_CERT" ]; then
echo "Can't find device certificate!"
exit 1
fi

mkdir -p /var/lib/wb-cloud-agent
mkdir -p /var/lib/wb-cloud-agent/providers
mkdir -p /mnt/data/etc/wb-cloud-agent/providers

# create correct certificate for agent to use
if [ ! -f "$TARGET_CERT" ] || ! cert_is_valid "$TARGET_CERT"; then
Expand Down Expand Up @@ -46,9 +48,9 @@ fi
wb_source of

if of_machine_match "wirenboard,wirenboard-720"; then
sed -i 's/ATECCx08:00:../ATECCx08:00:02/g' /mnt/data/etc/wb-cloud-agent.conf
sed -i 's/ATECCx08:00:../ATECCx08:00:02/g' "$AGENT_CONFIG"
elif of_machine_match "contactless,imx6ul-wirenboard60"; then
sed -i 's/ATECCx08:00:../ATECCx08:00:04/g' /mnt/data/etc/wb-cloud-agent.conf
sed -i 's/ATECCx08:00:../ATECCx08:00:04/g' "$AGENT_CONFIG"
fi

#DEBHELPER#
2 changes: 1 addition & 1 deletion debian/wb-cloud-agent.wb-cloud-agent-frpc.service
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[Unit]
Description=telegraf metric sender for Wiren Board Cloud
Description=telegraf metric sender for Wiren Board Cloud (default)
After=wb-cloud-agent.service
StartLimitIntervalSec=3600
StartLimitBurst=100
Expand Down
14 changes: 14 additions & 0 deletions debian/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[Unit]
Description=telegraf metric sender for Wiren Board Cloud (%i)
After=wb-cloud-agent.service
StartLimitIntervalSec=3600
StartLimitBurst=100

[Service]
ExecCondition=/usr/bin/test -f /var/lib/wb-cloud-agent/providers/%i/frpc.conf
ExecStart=/usr/bin/frpc --config /var/lib/wb-cloud-agent/providers/%i/frpc.conf
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target
2 changes: 1 addition & 1 deletion debian/wb-cloud-agent.wb-cloud-agent-telegraf.service
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[Unit]
Description=telegraf metric sender for Wiren Board Cloud
Description=telegraf metric sender for Wiren Board Cloud (default)
After=wb-cloud-agent.service
StartLimitIntervalSec=3600
StartLimitBurst=100
Expand Down
14 changes: 14 additions & 0 deletions debian/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[Unit]
Description=telegraf metric sender for Wiren Board Cloud (%i)
After=wb-cloud-agent.service
StartLimitIntervalSec=3600
StartLimitBurst=100

[Service]
ExecCondition=/usr/bin/test -f /var/lib/wb-cloud-agent/providers/%i/telegraf.conf
ExecStart=/usr/bin/telegraf --config /var/lib/wb-cloud-agent/providers/%i/telegraf.conf
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target
4 changes: 2 additions & 2 deletions debian/wb-cloud-agent.wb-cloud-agent.service
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[Unit]
Description=Wiren Board Cloud Agent
Description=Wiren Board Cloud Agent (default)
StartLimitIntervalSec=3600
StartLimitBurst=100

[Service]
ExecStart=/usr/bin/wb-cloud-agent --daemon
ExecStart=/usr/bin/wb-cloud-agent --daemon --provider default
Restart=always
RestartSec=10

Expand Down
12 changes: 12 additions & 0 deletions debian/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Unit]
Description=Wiren Board Cloud Agent (%i)
StartLimitIntervalSec=3600
StartLimitBurst=100

[Service]
ExecStart=/usr/bin/wb-cloud-agent --daemon --provider %i
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target
Loading

0 comments on commit 13996e6

Please sign in to comment.