Last active
October 23, 2018 07:03
-
-
Save bphermansson/d023e281bf2fe698103b0a98f0ae6d0c to your computer and use it in GitHub Desktop.
Script that waits for a service on another server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 [email protected] 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