Skip to content

Instantly share code, notes, and snippets.

@tbaschak
Created July 10, 2025 00:43
Show Gist options
  • Select an option

  • Save tbaschak/117a869b801ca57a1a8cb98d95d14752 to your computer and use it in GitHub Desktop.

Select an option

Save tbaschak/117a869b801ca57a1a8cb98d95d14752 to your computer and use it in GitHub Desktop.
waits for a successful ping, then notifies over discord
#!/bin/bash
DEFAULT_IP="1.1.1.1"
# Assign the first argument to IP, or use DEFAULT_IP if $1 is empty or unset
IP="${1:-$DEFAULT_IP}"
# loops until success, a single ping at a time, one a second
while [ "$RETURNCODE" != "0" ]; do
ping -c 1 $IP &> /dev/null
RETURNCODE=$? # ; echo $?
sleep 1
done
# notify over discord, with a custom message
# uses https://github.com/NoireNetworks/notify_discord
notify_discord.sh "Host $IP is up"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment