From c2d8195b6a779752ae16628fa0a06d040066bc1c Mon Sep 17 00:00:00 2001 From: Lukasz Woznicki <75632179+makr11st@users.noreply.github.com> Date: Tue, 7 Dec 2021 21:42:25 +0000 Subject: #596 Declare supported operations (#652) * Add operations to tedge_mapper * Add operations directory on install, remove supported ops from sm-c8y mapper * Update install command in postinst script to correctly create ops files Signed-off-by: Lukasz Woznicki --- configuration/debian/tedge_mapper/postinst | 11 ++++++++++ configuration/debian/tedge_mapper/postrm | 35 ++++++++++++++++++++++++++---- 2 files changed, 42 insertions(+), 4 deletions(-) (limited to 'configuration/debian/tedge_mapper') diff --git a/configuration/debian/tedge_mapper/postinst b/configuration/debian/tedge_mapper/postinst index 17e45367..9e27c5ce 100644 --- a/configuration/debian/tedge_mapper/postinst +++ b/configuration/debian/tedge_mapper/postinst @@ -13,4 +13,15 @@ if ! getent passwd tedge-mapper >/dev/null; then adduser --quiet --system --no-create-home --ingroup tedge-mapper --shell /usr/sbin/nologin tedge-mapper fi +### Create supported cloud operations directories +install -g tedge -o tedge -m 755 -d /etc/tedge/operations/c8y +install -g tedge -o tedge -m 755 -d /etc/tedge/operations/az + +### Create operation file. +# This allows thin-edge.io components to list and declare supported operations for the cloud provider. +# Some of the examples for Cumulocity IoT supported opertations: https://cumulocity.com/api/10.11.0/#section/Device-management-library/Miscellaneous +install -g tedge -o tedge -m 664 /dev/null /etc/tedge/operations/c8y/c8y_SoftwareUpdate +install -g tedge -o tedge -m 664 /dev/null /etc/tedge/operations/c8y/c8y_Restart +install -g tedge -o tedge -m 664 /dev/null /etc/tedge/operations/c8y/c8y_LogfileRequest + #DEBHELPER# diff --git a/configuration/debian/tedge_mapper/postrm b/configuration/debian/tedge_mapper/postrm index 942ff29c..eec30fbb 100644 --- a/configuration/debian/tedge_mapper/postrm +++ b/configuration/debian/tedge_mapper/postrm @@ -1,9 +1,36 @@ #!/bin/sh set -e -### Remove user tedge-mapper -if getent passwd tedge-mapper >/dev/null; then - deluser --quiet --system tedge-mapper -fi +remove_tedge_mapper_user() { + if getent passwd tedge-mapper >/dev/null; then + pkill -u tedge-mapper || true + deluser --quiet --system tedge-mapper + fi +} + +purge_operations() { + if [ -d "/etc/tedge/operations" ]; then + rm -rf /etc/tedge/operations + fi +} + +case "$1" in + purge) + remove_tedge_mapper_user + purge_operations + ;; + + remove) + remove_tedge_mapper_user + ;; + + upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) + ;; + + *) + echo "tedge postrm called with unknown argument \`$1\`" >&2 + exit 1 + ;; +esac #DEBHELPER# -- cgit v1.2.3