Created
October 10, 2011 13:11
-
-
Save tapajos/1275282 to your computer and use it in GitHub Desktop.
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
| function setBackground() { | |
| osascript -e "tell application \"iTerm\" | |
| tell current terminal | |
| tell current session | |
| set background color to $1 | |
| end tell | |
| end tell | |
| end tell" | |
| } | |
| function ec2ssh() { | |
| INSTANCE="$1" | |
| shift | |
| if [[ -z "$INSTANCE" ]] | |
| then | |
| echo 'use: ec2ssh $INSTANCE' >&2 | |
| return 2 | |
| fi | |
| DESCRIBE=$(ec2-describe-instances "$INSTANCE") | |
| ADDRESS=$(echo "$DESCRIBE" | awk '$1 ~ /^INSTANCE$/ { print $4; }') | |
| ADDRESS="${ADDRESS% *}" | |
| if [[ -n "$ADDRESS" ]] | |
| then | |
| if echo "$DESCRIBE" | awk '$1 ~ /^TAG$/ && $4 ~ /groupName$/ { print $5; }' | grep production &>/dev/null | |
| then | |
| setBackground "{15000,0,0}" | |
| else | |
| setBackground "{0,0,15000}" | |
| fi | |
| ssh "$ADDRESS" $@ | |
| setBackground "{0,0,0}" | |
| else | |
| return 1 | |
| fi | |
| } | |
| function ec2log() { | |
| INSTANCE="$1" | |
| if [[ -z "$INSTANCE" ]] | |
| then | |
| echo "Use: $0 instance [logfile]" >&2 | |
| return 1 | |
| fi | |
| LOGFILE="${2:-/var/log/bootstrap.log}" | |
| ec2ssh "$INSTANCE" "tail -f '$LOGFILE'" | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment