summaryrefslogtreecommitdiffstats
path: root/configuration
diff options
context:
space:
mode:
authorLukasz Woznicki <75632179+makr11st@users.noreply.github.com>2021-12-07 21:42:25 +0000
committerGitHub <noreply@github.com>2021-12-07 21:42:25 +0000
commitc2d8195b6a779752ae16628fa0a06d040066bc1c (patch)
treea6001216a3652ae149d0c1ae244712e317a792d1 /configuration
parent13c6cd0195bbcf0ebc917d02d8dea4bf744635a7 (diff)
#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 <lukasz.woznicki@softwareag.com>
Diffstat (limited to 'configuration')
-rwxr-xr-xconfiguration/debian/tedge/postinst4
-rw-r--r--configuration/debian/tedge_mapper/postinst11
-rw-r--r--configuration/debian/tedge_mapper/postrm35
3 files changed, 46 insertions, 4 deletions
diff --git a/configuration/debian/tedge/postinst b/configuration/debian/tedge/postinst
index 08f36052..2f0dfee1 100755
--- a/configuration/debian/tedge/postinst
+++ b/configuration/debian/tedge/postinst
@@ -25,6 +25,10 @@ install -g tedge -o tedge -m 755 -d /etc/tedge
install -g tedge -o tedge -m 755 -d /etc/tedge/mosquitto-conf
install -g mosquitto -o mosquitto -m 755 -d /etc/tedge/device-certs
+# Create a directory for the operations added by the user.
+install -g tedge -o tedge -m 755 -d /etc/tedge/operations
+install -g tedge -o tedge -m 755 -d /etc/tedge/plugins
+
# Create directory for logs
install -g tedge -o tedge -m 755 -d /var/log/tedge
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#