Created
October 18, 2024 01:36
-
-
Save suwardhana/abd6662aa2d732dbdc1d7ebd7783f0f3 to your computer and use it in GitHub Desktop.
retry_brew for automatically retry connection reset when install use by ./retry_brew.sh (package_name)
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 | |
| MAX_RETRIES=5 | |
| COUNT=0 | |
| PACKAGE_NAME=$1 | |
| while [ $COUNT -lt $MAX_RETRIES ]; do | |
| brew install $PACKAGE_NAME && break | |
| COUNT=$((COUNT+1)) | |
| echo "Connection reset by peer, retrying... ($COUNT/$MAX_RETRIES)" | |
| sleep 5 | |
| done | |
| if [ $COUNT -eq $MAX_RETRIES ]; then | |
| echo "Failed to execute brew command after $MAX_RETRIES retries." | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment