Skip to content

Commit

Permalink
switch to tedge-configuration-plugin
Browse files Browse the repository at this point in the history
Signed-off-by: Reuben Miller <[email protected]>
  • Loading branch information
reubenmiller committed Oct 26, 2023
1 parent 85b1e73 commit 86f9d2c
Show file tree
Hide file tree
Showing 38 changed files with 280 additions and 79 deletions.
2 changes: 1 addition & 1 deletion ci/package_list.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ RELEASE_PACKAGES=(
tedge-watchdog
tedge-apt-plugin
tedge-log-plugin
c8y-configuration-plugin
tedge-configuration-plugin
c8y-remote-access-plugin
c8y-firmware-plugin
)
Expand Down
2 changes: 1 addition & 1 deletion configuration/init/systemd/75-tedge.preset
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#
# Device management
enable tedge-log-plugin.service
enable c8y-configuration-plugin.service
enable tedge-configuration-plugin.service
enable c8y-firmware-plugin.service

# Agent
Expand Down
12 changes: 12 additions & 0 deletions configuration/init/systemd/tedge-configuration-plugin.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Unit]
Description=thin-edge.io configuration management
After=syslog.target network.target mosquitto.service

[Service]
ExecStart=/usr/bin/tedge-configuration-plugin
Restart=on-failure
RestartPreventExitStatus=255
RestartSec=5

[Install]
WantedBy=multi-user.target
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# yaml-language-server: $schema=https://nfpm.goreleaser.com/static/schema.json
---
name: tedge-configuration-plugin
description: |
thin-edge.io configuration management
arch: "${PKG_ARCH}"
platform: "linux"
version: "${GIT_SEMVER}"
release: "${RELEASE}"
section: misc
priority: "optional"
maintainer: "thin-edge.io team <[email protected]>"
vendor: "thin-edge.io"
homepage: "https://thin-edge.io"
license: "Apache-2.0"

depends:
- tedge
replaces:
- c8y_configuration_plugin
- c8y-configuration-plugin
conflicts:
- c8y_configuration_plugin (<= 0.8.1)
- c8y-configuration-plugin

deb:
fields:
Vcs-Browser: ${CI_PROJECT_URL}
Vcs-Git: ${CI_PROJECT_URL}
compression: xz
breaks:
- c8y_configuration_plugin (<= 0.8.1)
- c8y-configuration-plugin

contents:
# service definitions
- src: ./configuration/init/systemd/tedge-configuration-plugin.service
dst: /lib/systemd/system/
file_info:
mode: 0644
packager: deb

- src: ./configuration/init/systemd/tedge-configuration-plugin.service
dst: /lib/systemd/system/
file_info:
mode: 0644
packager: rpm

overrides:
apk:
scripts:
preinstall: configuration/package_scripts/_generated/tedge-configuration-plugin/apk/preinst
postinstall: configuration/package_scripts/_generated/tedge-configuration-plugin/apk/postinst
preremove: configuration/package_scripts/_generated/tedge-configuration-plugin/apk/prerm
postremove: configuration/package_scripts/_generated/tedge-configuration-plugin/apk/postrm

rpm:
scripts:
preinstall: configuration/package_scripts/_generated/tedge-configuration-plugin/rpm/preinst
postinstall: configuration/package_scripts/_generated/tedge-configuration-plugin/rpm/postinst
preremove: configuration/package_scripts/_generated/tedge-configuration-plugin/rpm/prerm
postremove: configuration/package_scripts/_generated/tedge-configuration-plugin/rpm/postrm

deb:
scripts:
preinstall: configuration/package_scripts/_generated/tedge-configuration-plugin/deb/preinst
postinstall: configuration/package_scripts/_generated/tedge-configuration-plugin/deb/postinst
preremove: configuration/package_scripts/_generated/tedge-configuration-plugin/deb/prerm
postremove: configuration/package_scripts/_generated/tedge-configuration-plugin/deb/postrm
6 changes: 3 additions & 3 deletions configuration/package_manifests/virtual/nfpm.tedge-full.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ overrides:
# - tedge-watchdog = ${GIT_SEMVER}
- tedge-apt-plugin = ${GIT_SEMVER}
- tedge-log-plugin = ${GIT_SEMVER}
- c8y-configuration-plugin = ${GIT_SEMVER}
- tedge-configuration-plugin = ${GIT_SEMVER}
- c8y-remote-access-plugin = ${GIT_SEMVER}
- c8y-firmware-plugin = ${GIT_SEMVER}
rpm:
Expand All @@ -48,7 +48,7 @@ overrides:
# tedge-apt-plugin does not make sense on rpm
# - tedge-apt-plugin = ${GIT_SEMVER}-1
- tedge-log-plugin = ${GIT_SEMVER}-1
- c8y-configuration-plugin = ${GIT_SEMVER}-1
- tedge-configuration-plugin = ${GIT_SEMVER}-1
- c8y-remote-access-plugin = ${GIT_SEMVER}-1
- c8y-firmware-plugin = ${GIT_SEMVER}-1
deb:
Expand All @@ -59,7 +59,7 @@ overrides:
- tedge-watchdog (= ${GIT_SEMVER})
- tedge-apt-plugin (= ${GIT_SEMVER})
- tedge-log-plugin (= ${GIT_SEMVER})
- c8y-configuration-plugin (= ${GIT_SEMVER})
- tedge-configuration-plugin (= ${GIT_SEMVER})
- c8y-remote-access-plugin (= ${GIT_SEMVER})
- c8y-firmware-plugin (= ${GIT_SEMVER})

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
set -e

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
set -e

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
set -e
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
set -e
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/sh
set -e
# Automatically added by thin-edge.io
if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then
# This will only remove masks created by d-s-h on package removal.
deb-systemd-helper unmask tedge-configuration-plugin.service >/dev/null || true

# was-enabled defaults to true, so new installations run enable.
if deb-systemd-helper --quiet was-enabled tedge-configuration-plugin.service; then
# Enables the unit on first installation, creates new
# symlinks on upgrades if the unit file has changed.
deb-systemd-helper enable tedge-configuration-plugin.service >/dev/null || true
else
# Update the statefile to add new symlinks (if any), which need to be
# cleaned up on purge. Also remove old symlinks.
deb-systemd-helper update-state tedge-configuration-plugin.service >/dev/null || true
fi
fi
# End automatically added section
# Automatically added by thin-edge.io
if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then
if [ -d /run/systemd/system ]; then
systemctl --system daemon-reload >/dev/null || true
if [ -n "$2" ]; then
_dh_action=restart
else
_dh_action=start
fi
deb-systemd-invoke $_dh_action tedge-configuration-plugin.service >/dev/null || true
fi
fi
# End automatically added section
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/sh
set -e
# Automatically added by thin-edge.io
if [ -d /run/systemd/system ]; then
systemctl --system daemon-reload >/dev/null || true
fi
# End automatically added section
# Automatically added by thin-edge.io
if [ "$1" = "remove" ]; then
if [ -x "/usr/bin/deb-systemd-helper" ]; then
deb-systemd-helper mask tedge-configuration-plugin.service >/dev/null || true
fi
fi

if [ "$1" = "purge" ]; then
if [ -x "/usr/bin/deb-systemd-helper" ]; then
deb-systemd-helper purge tedge-configuration-plugin.service >/dev/null || true
deb-systemd-helper unmask tedge-configuration-plugin.service >/dev/null || true
fi
fi
# End automatically added section
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
set -e
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh
set -e
# Automatically added by thin-edge.io
if [ -d /run/systemd/system ] && [ "$1" = remove ]; then
deb-systemd-invoke stop tedge-configuration-plugin.service >/dev/null || true
fi
# End automatically added section
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/sh
set -e
# Automatically added by thin-edge.io
if [ $1 -eq 1 ] && [ -x "/usr/lib/systemd/systemd-update-helper" ]; then
# Initial installation
/usr/lib/systemd/systemd-update-helper install-system-units tedge-configuration-plugin.service || :
fi
# End automatically added section
# Automatically added by thin-edge.io
if [ -d /run/systemd/system ]; then
systemctl --system daemon-reload >/dev/null || true
if [ $1 -eq 2 ]; then
_dh_action=restart
else
_dh_action=start
fi
systemctl $_dh_action tedge-configuration-plugin.service >/dev/null || true
fi
# End automatically added section
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh
set -e
# Automatically added by thin-edge.io
if [ -d /run/systemd/system ]; then
systemctl --system daemon-reload >/dev/null || true
fi
# End automatically added section
# Automatically added by thin-edge.io
if [ $1 -ge 1 ] && [ -x "/usr/lib/systemd/systemd-update-helper" ]; then
# Package upgrade, not uninstall
/usr/lib/systemd/systemd-update-helper mark-restart-system-units tedge-configuration-plugin.service || :
fi

# End automatically added section
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
set -e
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh
set -e
# Automatically added by thin-edge.io
if [ $1 -eq 0 ] && [ -x "/usr/lib/systemd/systemd-update-helper" ]; then
# Package removal, not upgrade
/usr/lib/systemd/systemd-update-helper remove-system-units tedge-configuration-plugin.service || :
fi
# End automatically added section
5 changes: 5 additions & 0 deletions configuration/package_scripts/packages.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
{"name": "c8y-configuration-plugin", "enable": true, "start": true, "restart_after_upgrade": true, "stop_on_upgrade": true}
]
},
"tedge-configuration-plugin": {
"services": [
{"name": "tedge-configuration-plugin", "enable": true, "start": true, "restart_after_upgrade": true, "stop_on_upgrade": true}
]
},
"c8y-log-plugin": {
"services": [
{"name": "c8y-log-plugin", "enable": true, "start": true, "restart_after_upgrade": true, "stop_on_upgrade": true}
Expand Down
2 changes: 1 addition & 1 deletion docs/src/contribute/DEBIAN_PACKAGE_HOSTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ curl -1sLf \
tedge-mapper \
tedge-agent \
tedge-watchdog \
c8y-configuration-plugin \
tedge-configuration-plugin \
tedge-apt-plugin \
c8y-firmware-plugin \
c8y-remote-access-plugin \
Expand Down
4 changes: 2 additions & 2 deletions tests/RobotFramework/tasks/build_install_rpi.robot
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ Install tedge apt plugin
Install Tedge logfile request plugin
${rc}= Execute Command sudo dpkg -i ./tedge-log-plugin_${Version}_arm*.deb return_stdout=False return_rc=True
Should Be Equal ${rc} ${0}
Install C8y configuration plugin
${rc}= Execute Command sudo dpkg -i ./c8y-configuration-plugin_${Version}_arm*.deb return_stdout=False return_rc=True
Install Tedge configuration plugin
${rc}= Execute Command sudo dpkg -i ./tedge-configuration-plugin_${Version}_arm*.deb return_stdout=False return_rc=True
Should Be Equal ${rc} ${0}
Install Watchdog
${rc}= Execute Command sudo dpkg -i ./tedge-watchdog_${Version}_arm*.deb return_stdout=False return_rc=True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ tedge-log-plugin health status
Should Contain ${messages[0]} "pid":${pid}
Should Contain ${messages[0]} "status":"up"

c8y-configuration-plugin health status
Execute Command sudo systemctl start c8y-configuration-plugin.service

tedge-configuration-plugin health status
Execute Command sudo systemctl start tedge-configuration-plugin.service
Sleep 5s reason=It fails without this! It needs a better way of queuing requests
${pid}= Execute Command pgrep -f '^/usr/bin/c8y[_-]configuration[_-]plugin' strip=${True}
Execute Command sudo tedge mqtt pub 'te/device/main/service/c8y-configuration-plugin/cmd/health/check' ''
${messages}= Should Have MQTT Messages te/device/main/service/c8y-configuration-plugin/status/health minimum=1 maximum=2
${pid}= Execute Command pgrep -f '^/usr/bin/tedge-configuration-plugin' strip=${True}
Execute Command sudo tedge mqtt pub 'te/device/main/service/tedge-configuration-plugin/cmd/health/check' ''
${messages}= Should Have MQTT Messages te/device/main/service/tedge-configuration-plugin/status/health minimum=1 maximum=2
Should Contain ${messages[0]} "pid":${pid}
Should Contain ${messages[0]} "status":"up"
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,31 @@ Suite Teardown Get Logs

*** Test Cases ***

Stop c8y-configuration-plugin
Execute Command sudo systemctl stop c8y-configuration-plugin.service
Stop tedge-configuration-plugin
Execute Command sudo systemctl stop tedge-configuration-plugin.service

Update the service file
Execute Command cmd=sudo sed -i '9iWatchdogSec=30' /lib/systemd/system/c8y-configuration-plugin.service
Execute Command cmd=sudo sed -i '9iWatchdogSec=30' /lib/systemd/system/tedge-configuration-plugin.service

Reload systemd files
Execute Command sudo systemctl daemon-reload

Start c8y-configuration-plugin
Execute Command sudo systemctl start c8y-configuration-plugin.service
Start tedge-configuration-plugin
Execute Command sudo systemctl start tedge-configuration-plugin.service

Start watchdog service
Execute Command sudo systemctl start tedge-watchdog.service
Sleep 10s

Check PID of c8y-configuration-plugin
${pid}= Execute Command pgrep -f '^/usr/bin/c8y-configuration-plugin' strip=${True}
Check PID of tedge-configuration-plugin
${pid}= Execute Command pgrep -f '^/usr/bin/tedge-configuration-plugin' strip=${True}
Set Suite Variable ${pid}

Kill the PID
Kill Process ${pid}

Recheck PID of c8y-configuration-plugin
${pid1}= Execute Command pgrep -f '^/usr/bin/c8y-configuration-plugin' strip=${True}
Recheck PID of tedge-configuration-plugin
${pid1}= Execute Command pgrep -f '^/usr/bin/tedge-configuration-plugin' strip=${True}
Set Suite Variable ${pid1}

Compare PID change
Expand All @@ -45,4 +45,4 @@ Stop watchdog service
Execute Command sudo systemctl stop tedge-watchdog.service

Remove entry from service file
Execute Command sudo sed -i '9d' /lib/systemd/system/c8y-configuration-plugin.service
Execute Command sudo sed -i '9d' /lib/systemd/system/tedge-configuration-plugin.service
Loading

0 comments on commit 86f9d2c

Please sign in to comment.