Skip to content

Commit

Permalink
Merge pull request #3296 from reubenmiller/feat-cloud-profile-mapper-…
Browse files Browse the repository at this point in the history
…service-targets

feat(packaging): manage tedge-mapper cloud profile service instances in install/upgrade/uninstall
  • Loading branch information
reubenmiller authored Dec 16, 2024
2 parents dbb71b3 + 03a5443 commit 37c5073
Show file tree
Hide file tree
Showing 26 changed files with 250 additions and 76 deletions.
2 changes: 1 addition & 1 deletion configuration/init/systemd/tedge-mapper-aws.service
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[Unit]
Description=tedge-mapper-aws checks Thin Edge JSON measurements and forwards to AWS IoT Hub.
Description=tedge-mapper-aws checks Thin Edge JSON measurements and forwards to AWS IoT Core.
After=syslog.target network.target mosquitto.service

[Service]
Expand Down
5 changes: 5 additions & 0 deletions configuration/init/systemd/tedge-mapper-aws.target
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[Unit]
Description=tedge-mapper-aws cloud profile services

[Install]
WantedBy=multi-user.target
3 changes: 2 additions & 1 deletion configuration/init/systemd/[email protected]
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[Unit]
Description=tedge-mapper-aws checks Thin Edge JSON measurements and forwards to AWS IoT Hub.
Description=tedge-mapper-aws checks Thin Edge JSON measurements and forwards to AWS IoT Core.
After=syslog.target network.target mosquitto.service
PartOf=tedge-mapper-aws.target

[Service]
User=tedge
Expand Down
5 changes: 5 additions & 0 deletions configuration/init/systemd/tedge-mapper-az.target
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[Unit]
Description=tedge-mapper-az cloud profile services

[Install]
WantedBy=multi-user.target
1 change: 1 addition & 0 deletions configuration/init/systemd/[email protected]
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[Unit]
Description=tedge-mapper-az checks Thin Edge JSON measurements and forwards to Azure IoT Hub.
After=syslog.target network.target mosquitto.service
PartOf=tedge-mapper-az.target

[Service]
User=tedge
Expand Down
5 changes: 5 additions & 0 deletions configuration/init/systemd/tedge-mapper-c8y.target
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[Unit]
Description=tedge-mapper-c8y cloud profile services

[Install]
WantedBy=multi-user.target
1 change: 1 addition & 0 deletions configuration/init/systemd/[email protected]
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[Unit]
Description=tedge-mapper-c8y converts Thin Edge JSON measurements to Cumulocity JSON format.
After=syslog.target network.target mosquitto.service
PartOf=tedge-mapper-c8y.target

[Service]
User=tedge
Expand Down
33 changes: 33 additions & 0 deletions configuration/package_manifests/nfpm.tedge-mapper.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,17 @@ contents:
mode: 0644
packager: rpm

- src: ./configuration/init/systemd/tedge-mapper-aws.target
dst: /lib/systemd/system/tedge-mapper-aws.target
file_info:
mode: 0644
packager: deb
- src: ./configuration/init/systemd/tedge-mapper-aws.target
dst: /lib/systemd/system/tedge-mapper-aws.target
file_info:
mode: 0644
packager: rpm

- src: ./configuration/init/systemd/[email protected]
dst: /lib/systemd/system/[email protected]
file_info:
Expand All @@ -66,6 +77,17 @@ contents:
mode: 0644
packager: rpm

- src: ./configuration/init/systemd/tedge-mapper-az.target
dst: /lib/systemd/system/tedge-mapper-az.target
file_info:
mode: 0644
packager: deb
- src: ./configuration/init/systemd/tedge-mapper-az.target
dst: /lib/systemd/system/tedge-mapper-az.target
file_info:
mode: 0644
packager: rpm

- src: ./configuration/init/systemd/[email protected]
dst: /lib/systemd/system/[email protected]
file_info:
Expand All @@ -88,6 +110,17 @@ contents:
mode: 0644
packager: rpm

- src: ./configuration/init/systemd/tedge-mapper-c8y.target
dst: /lib/systemd/system/tedge-mapper-c8y.target
file_info:
mode: 0644
packager: deb
- src: ./configuration/init/systemd/tedge-mapper-c8y.target
dst: /lib/systemd/system/tedge-mapper-c8y.target
file_info:
mode: 0644
packager: rpm

- src: ./configuration/init/systemd/[email protected]
dst: /lib/systemd/system/[email protected]
file_info:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
#!/bin/sh
set -e

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

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@ set -e




### Create supported operation files
c8y-remote-access-plugin --init
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
#!/bin/sh
set -e

Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,3 @@ case "$1" in
esac



Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ set -e







enable_start_service() {
name="$1"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,3 @@ case "$1" in
esac



64 changes: 64 additions & 0 deletions configuration/package_scripts/_generated/tedge-mapper/deb/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,70 @@ if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-decon
fi
# End automatically added section
# 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-mapper-aws.target >/dev/null || true

# was-enabled defaults to true, so new installations run enable.
if deb-systemd-helper --quiet was-enabled tedge-mapper-aws.target; then
# Enables the unit on first installation, creates new
# symlinks on upgrades if the unit file has changed.
deb-systemd-helper enable tedge-mapper-aws.target >/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-mapper-aws.target >/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
# This will only remove masks created by d-s-h on package removal.
deb-systemd-helper unmask tedge-mapper-az.target >/dev/null || true

# was-enabled defaults to true, so new installations run enable.
if deb-systemd-helper --quiet was-enabled tedge-mapper-az.target; then
# Enables the unit on first installation, creates new
# symlinks on upgrades if the unit file has changed.
deb-systemd-helper enable tedge-mapper-az.target >/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-mapper-az.target >/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
# This will only remove masks created by d-s-h on package removal.
deb-systemd-helper unmask tedge-mapper-c8y.target >/dev/null || true

# was-enabled defaults to true, so new installations run enable.
if deb-systemd-helper --quiet was-enabled tedge-mapper-c8y.target; then
# Enables the unit on first installation, creates new
# symlinks on upgrades if the unit file has changed.
deb-systemd-helper enable tedge-mapper-c8y.target >/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-mapper-c8y.target >/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-mapper-aws.target tedge-mapper-az.target tedge-mapper-c8y.target >/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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ fi
# Automatically added by thin-edge.io
if [ "$1" = "remove" ]; then
if [ -x "/usr/bin/deb-systemd-helper" ]; then
deb-systemd-helper mask tedge-mapper-aws.service tedge-mapper-az.service tedge-mapper-c8y.service tedge-mapper-collectd.service >/dev/null || true
deb-systemd-helper mask tedge-mapper-aws.service tedge-mapper-az.service tedge-mapper-c8y.service tedge-mapper-collectd.service tedge-mapper-aws.target tedge-mapper-az.target tedge-mapper-c8y.target >/dev/null || true
fi
fi

if [ "$1" = "purge" ]; then
if [ -x "/usr/bin/deb-systemd-helper" ]; then
deb-systemd-helper purge tedge-mapper-aws.service tedge-mapper-az.service tedge-mapper-c8y.service tedge-mapper-collectd.service >/dev/null || true
deb-systemd-helper unmask tedge-mapper-aws.service tedge-mapper-az.service tedge-mapper-c8y.service tedge-mapper-collectd.service >/dev/null || true
deb-systemd-helper purge tedge-mapper-aws.service tedge-mapper-az.service tedge-mapper-c8y.service tedge-mapper-collectd.service tedge-mapper-aws.target tedge-mapper-az.target tedge-mapper-c8y.target >/dev/null || true
deb-systemd-helper unmask tedge-mapper-aws.service tedge-mapper-az.service tedge-mapper-c8y.service tedge-mapper-collectd.service tedge-mapper-aws.target tedge-mapper-az.target tedge-mapper-c8y.target >/dev/null || true
fi
fi
# End automatically added section
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
set -e
# Automatically added by thin-edge.io
if [ -d /run/systemd/system ] && [ "$1" = remove ]; then
deb-systemd-invoke stop tedge-mapper-aws.service tedge-mapper-az.service tedge-mapper-c8y.service tedge-mapper-collectd.service >/dev/null || true
deb-systemd-invoke stop tedge-mapper-aws.service tedge-mapper-az.service tedge-mapper-c8y.service tedge-mapper-collectd.service tedge-mapper-aws.target tedge-mapper-az.target tedge-mapper-c8y.target >/dev/null || true
fi
# End automatically added section
29 changes: 29 additions & 0 deletions configuration/package_scripts/_generated/tedge-mapper/rpm/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,35 @@ if [ $1 -eq 1 ] && [ -x "/usr/lib/systemd/systemd-update-helper" ]; then
fi
# End automatically added section
# 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-mapper-aws.target || :
fi
# End automatically added section
# 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-mapper-az.target || :
fi
# End automatically added section
# 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-mapper-c8y.target || :
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-mapper-aws.target tedge-mapper-az.target tedge-mapper-c8y.target >/dev/null || true
fi
# End automatically added section
# Automatically added by thin-edge.io
if [ $1 -eq 2 ]; then
if [ -d /run/systemd/system ]; then
systemctl --system daemon-reload >/dev/null || true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ fi
# 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-mapper-aws.service tedge-mapper-az.service tedge-mapper-c8y.service tedge-mapper-collectd.service || :
/usr/lib/systemd/systemd-update-helper mark-restart-system-units tedge-mapper-aws.service tedge-mapper-az.service tedge-mapper-c8y.service tedge-mapper-collectd.service tedge-mapper-aws.target tedge-mapper-az.target tedge-mapper-c8y.target || :
fi

# End automatically added section
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ 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-mapper-aws.service tedge-mapper-az.service tedge-mapper-c8y.service tedge-mapper-collectd.service || :
/usr/lib/systemd/systemd-update-helper remove-system-units tedge-mapper-aws.service tedge-mapper-az.service tedge-mapper-c8y.service tedge-mapper-collectd.service tedge-mapper-aws.target tedge-mapper-az.target tedge-mapper-c8y.target || :
fi
# End automatically added section
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
#!/bin/sh
set -e

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

Loading

0 comments on commit 37c5073

Please sign in to comment.