Created
January 12, 2020 02:25
-
-
Save AndrewWestberg/e849237a188a50d6c1351a7b7d2ef0cc to your computer and use it in GitHub Desktop.
Check the yaml file for valid peers before starting jormungandr
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
#!/bin/bash | |
cp /home/westbam/cardano/itn_rewards_v1-config.yaml /home/westbam/cardano/itn_rewards_v1-config.yaml.new | |
# find all addresses that are not commented out | |
sed -e '/ address/!d' -e '/^[[:space:]]*#/d' -e '/Brainy/d' -e 's@^.*/ip./\([^/]*\)/tcp/\([0-9]*\).*@\1 \2@' /home/westbam/cardano/itn_rewards_v1-config.yaml | \ | |
while read addr port | |
do | |
echo "Checking $addr:$port" | |
RESULT=$(tcpping -x 1 $addr $port) | |
echo "$RESULT" | |
if [[ $RESULT == *"open"* ]]; then | |
echo "Valid Peer" | |
else | |
# comment out the line | |
sed -i -e "/.*$addr\/tcp\/$port/,+1 s/^/#&/" /home/westbam/cardano/itn_rewards_v1-config.yaml.new | |
echo "Invalid Peer" | |
fi | |
done | |
# find all addresses that are commented out | |
sed -e '/ address/!d' -e '/^[[:space:]]*#/!d' -e '/Brainy/d' -e 's@^.*/ip./\([^/]*\)/tcp/\([0-9]*\).*@\1 \2@' /home/westbam/cardano/itn_rewards_v1-config.yaml | \ | |
while read addr port | |
do | |
echo "Checking $addr:$port" | |
RESULT=$(tcpping -x 1 $addr $port) | |
echo "$RESULT" | |
if [[ $RESULT == *"open"* ]]; then | |
sed -i -e "/.*$addr\/tcp\/$port/,+1 s/^#//" /home/westbam/cardano/itn_rewards_v1-config.yaml.new | |
echo "Valid Peer" | |
else | |
echo "Invalid Peer" | |
fi | |
done | |
mv /home/westbam/cardano/itn_rewards_v1-config.yaml.new /home/westbam/cardano/itn_rewards_v1-config.yaml |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Dependencies: