Created
June 22, 2023 19:40
-
-
Save W-A-James/88d04ed5a955acfa06d690ef02d0e4e1 to your computer and use it in GitHub Desktop.
Get host name of named evergreen host
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 | |
# provide evergreen host name as only argument | |
# Returns <user>@<hostname> for the specified host and fails if no host is found | |
USAGE=$(cat << EOM | |
$0 <name> | |
EOM | |
) | |
NAME=$1 | |
if [ -z $NAME ]; then | |
echo 'Must provide name of evergreen host' | |
echo | |
echo $USAGE | |
exit 1 | |
fi | |
SCRIPT=$(cat << EOM | |
# Check for host with name that matches argument | |
/Name: $1;/!d | |
# Extract host user and hostname | |
s/^.*Host name: (.*);(.*)User: (.*)\;.*\$/\3@\1/ | |
p | |
EOM | |
) | |
user_host_string=$(evergreen host list | sed --regexp-extended --quiet -e "${SCRIPT}") | |
if [ -z $user_host_string ]; then | |
echo "No host with name '${NAME}' found" | |
exit 1 | |
fi | |
echo $user_host_string |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment