Skip to content

Instantly share code, notes, and snippets.

@bphermansson
Last active October 23, 2018 07:03
Show Gist options
  • Save bphermansson/d023e281bf2fe698103b0a98f0ae6d0c to your computer and use it in GitHub Desktop.
Save bphermansson/d023e281bf2fe698103b0a98f0ae6d0c to your computer and use it in GitHub Desktop.
Script that waits for a service on another server
# Started by a Systemd script called 'waitformqtt.service':
#
# [Unit]
# Description=Checks if Mosquitto is running
# After=network-online.target
# [Service]
# User=rock64
# Type=oneshot
# ExecStart=/home/rock64/waitForMosquitto
# [Install]
# WantedBy=multi-user.target
# -----------------------#
# Install the start script:
# cp waitformqtt.service ~/.config/systemd/user/
# systemctl --user enable waitformqtt
# -----------------------#
# The script itself:
while true;
do
status=$(systemctl -H pi@192.168.1.79 is-active mosquitto)
if [ "$status" = "active" ]
then
echo "Mosquitto started"
break
fi
sleep 3
echo "Waiting"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment