From 9ef6f286634fade0c6d6ac0b6751d646de508fdf Mon Sep 17 00:00:00 2001 From: Meet Gandhi Date: Mon, 3 Mar 2025 21:18:52 +0530 Subject: [PATCH] Fixed systemctl command handling Signed-off-by: Meet Gandhi --- zenoh-bridge-ros2dds/.deb/postinst | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/zenoh-bridge-ros2dds/.deb/postinst b/zenoh-bridge-ros2dds/.deb/postinst index 7644a106..89ce4ade 100644 --- a/zenoh-bridge-ros2dds/.deb/postinst +++ b/zenoh-bridge-ros2dds/.deb/postinst @@ -20,14 +20,15 @@ set -e case "$1" in configure) - if ! command -v systemctl &> /dev/null - then - echo "WARNING: 'systemctl' not found - cannot install zenoh-bridge-ros2dds as a service." - exit 0 - fi + SYSTEMCTL_CMD=$(command -v systemctl) + if [ -z "$SYSTEMCTL_CMD" ]; then + echo "WARNING: 'systemctl' not found - cannot install zenoh-bridge-ros2dds as a service." + exit 0 + fi + echo "Found $SYSTEMCTL_CMD" id -u zenoh-bridge-ros2dds &> /dev/null || useradd -r -s /bin/false zenoh-bridge-ros2dds - systemctl daemon-reload - systemctl disable zenoh-bridge-ros2dds + "$SYSTEMCTL_CMD" daemon-reload + "$SYSTEMCTL_CMD" disable zenoh-bridge-ros2dds ;; abort-upgrade|abort-remove|abort-deconfigure)