#!/bin/sh

sudo systemctl start mosquitto.service

topic='test/topic'


(
    echo "[mosquitto_sub] listening"
    mosquitto_sub -v -t $topic
) & listener_pid=$!

(
    echo "[mosquitto_pub] publishing"
    mosquitto_pub -t $topic -m 'helloWorld'
)

sleep 1s
kill $listener_pid


sudo systemctl stop mosquitto.service
