Browse Source

Docker, check if systemctl exists before using it

release/3.x.x
Damian Wolgast 3 years ago
parent
commit
9cb12ac2ce
No known key found for this signature in database GPG Key ID: 97F36CC6D201E31B
3 changed files with 26 additions and 11 deletions
  1. +12
    -7
      Build/deb-meta/DEBIAN/postinst
  2. +7
    -2
      Build/deb-meta/DEBIAN/postrm
  3. +7
    -2
      Build/deb-meta/DEBIAN/prerm

+ 12
- 7
Build/deb-meta/DEBIAN/postinst View File

@@ -9,12 +9,12 @@ INSTALLPATH=$BASEPATH/MQTTnetServer

# If user does not exist, create it
if (( $USEREXISTS == 1 )); then
useradd -d $INSTALLPATH -r $USER
EC=$(echo $?)
useradd -d $INSTALLPATH -r $USER
EC=$(echo $?)

if (( $EC == 1 )); then
exit 1;
fi
if (( $EC == 1 )); then
exit 1;
fi
fi

# Set permissions on files
@@ -30,5 +30,10 @@ setcap CAP_NET_BIND_SERVICE=+eip $INSTALLPATH/MQTTnet.Server

chmod 644 /etc/systemd/system/mqttnet-server.service

# Reload systemd because of new service file
systemctl daemon-reload
# Check if systemctl exists, does not exist in docker containers
SCTL=$(which systemct1l >/dev/null; echo $?)

if [ "$SCTL" -eq "0" ]; then
# Reload systemd because of new service file
systemctl daemon-reload
fi

+ 7
- 2
Build/deb-meta/DEBIAN/postrm View File

@@ -1,4 +1,9 @@
#!/bin/bash

# Reload systemd because of absent service file
systemctl daemon-reload
# Check if systemctl exists, does not exist in docker containers
SCTL=$(which systemct1l >/dev/null; echo $?)

if [ "$SCTL" -eq "0" ]; then
# Reload systemd because of new service file
systemctl daemon-reload
fi

+ 7
- 2
Build/deb-meta/DEBIAN/prerm View File

@@ -3,8 +3,13 @@
BASEPATH=/opt
INSTALLPATH=$BASEPATH/MQTTnetServer

# Stop service before uninstalling
systemctl stop mqttnet-server
# Check if systemctl exists, does not exist in docker containers
SCTL=$(which systemct1l >/dev/null; echo $?)

if [ "$SCTL" -eq "0" ]; then
# Stop service before uninstalling
systemctl stop mqttnet-server
fi

# Remove permission to open ports
setcap CAP_NET_BIND_SERVICE=-eip $INSTALLPATH/MQTTnet.Server

Loading…
Cancel
Save