#!/bin/bash

# Check if root
if [ "$EUID" -ne 0 ]
  then echo "Please run as root"
  exit 1
fi

# Stop the service if is active
if (systemctl -q is-active device-mqtt.service)
then
    systemctl stop device-mqtt
    MQTT=true
else
    MQTT=false
fi

if $MQTT
then
    systemctl start device-mqtt
fi
