Skip to content

Commit

Permalink
start service on post installation and stop service on pre-removal
Browse files Browse the repository at this point in the history
  • Loading branch information
reubenmiller committed Aug 7, 2023
1 parent a0e9090 commit 407b170
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 18 deletions.
31 changes: 25 additions & 6 deletions packages/_scripts/postinstall.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,27 @@
#!/bin/sh

# enable services (only if the binary is found)
command -V tedge-agent >/dev/null 2>&1 && tedgectl enable tedge-agent
command -V tedge-mapper-c8y >/dev/null 2>&1 && tedgectl enable tedge-mapper-c8y
command -V c8y-configuration-plugin >/dev/null 2>&1 && tedgectl enable c8y-configuration-plugin
command -V c8y-log-plugin >/dev/null 2>&1 && tedgectl enable c8y-log-plugin
command -V c8y-firmware-plugin >/dev/null 2>&1 && tedgectl enable c8y-firmware-plugin
# enable and start services (only if the binary is found)
if command -V tedge-agent >/dev/null 2>&1; then
tedgectl enable tedge-agent
tedgectl start tedge-agent
fi

if command -V tedge-mapper-c8y >/dev/null 2>&1; then
tedgectl enable tedge-mapper-c8y
tedgectl start tedge-mapper-c8y
fi

if command -V c8y-configuration-plugin >/dev/null 2>&1; then
tedgectl enable c8y-configuration-plugin
tedgectl start c8y-configuration-plugin
fi

if command -V c8y-log-plugin >/dev/null 2>&1; then
tedgectl enable c8y-log-plugin
tedgectl start c8y-log-plugin
fi

if command -V c8y-firmware-plugin >/dev/null 2>&1; then
tedgectl enable c8y-firmware-plugin
tedgectl start c8y-firmware-plugin
fi
8 changes: 0 additions & 8 deletions packages/_scripts/postremove.sh

This file was deleted.

7 changes: 7 additions & 0 deletions packages/_scripts/preremove.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,10 @@ tedgectl disable tedge-mapper-c8y 2>/dev/null ||:
tedgectl disable c8y-configuration-plugin 2>/dev/null ||:
tedgectl disable c8y-log-plugin 2>/dev/null ||:
tedgectl disable c8y-firmware-plugin 2>/dev/null ||:

# stop services (ignore if not found)
tedgectl stop tedge-agent 2>/dev/null ||:
tedgectl stop tedge-mapper-c8y 2>/dev/null ||:
tedgectl stop c8y-configuration-plugin 2>/dev/null ||:
tedgectl stop c8y-log-plugin 2>/dev/null ||:
tedgectl stop c8y-firmware-plugin 2>/dev/null ||:
1 change: 0 additions & 1 deletion packages/openrc/nfpm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,3 @@ contents:
scripts:
postinstall: ./packages/_scripts/postinstall.sh
preremove: ./packages/_scripts/preremove.sh
postremove: ./packages/_scripts/postremove.sh
1 change: 0 additions & 1 deletion packages/runit/nfpm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,3 @@ contents:
scripts:
postinstall: ./packages/_scripts/postinstall.sh
preremove: ./packages/_scripts/preremove.sh
postremove: ./packages/_scripts/postremove.sh
1 change: 0 additions & 1 deletion packages/s6-overlay/nfpm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,3 @@ contents:
scripts:
postinstall: ./packages/_scripts/postinstall.sh
preremove: ./packages/_scripts/preremove.sh
postremove: ./packages/_scripts/postremove.sh
1 change: 0 additions & 1 deletion packages/sysvinit/nfpm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,3 @@ contents:
scripts:
postinstall: ./packages/_scripts/postinstall.sh
preremove: ./packages/_scripts/preremove.sh
postremove: ./packages/_scripts/postremove.sh

0 comments on commit 407b170

Please sign in to comment.