Created
July 10, 2025 00:43
-
-
Save tbaschak/117a869b801ca57a1a8cb98d95d14752 to your computer and use it in GitHub Desktop.
waits for a successful ping, then notifies over discord
This file contains hidden or 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
| #!/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