#!/bin/bash

BASEPATH=/opt
INSTALLPATH=$BASEPATH/MQTTnetServer

# Check if systemctl exists, does not exist in docker containers
SCTL=$(which systemctl >/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