Created
August 7, 2016 00:59
-
-
Save manishrjain/a295d51b0da7da8d2f0840954ab239e1 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env bash | |
set -e | |
BLACK='\033[30;1m' | |
RED='\033[91;1m' | |
GREEN='\033[32;1m' | |
CYAN='\033[36;1m' | |
RESET='\033[0m' | |
print_error() { | |
printf "$RED$1$RESET\n" | |
} | |
print_good() { | |
printf "$GREEN$1$RESET\n" | |
} | |
print_warning() { | |
printf "$BLACK$1$RESET\n" | |
} | |
check_git_repo() { | |
if [ ! -d $1 ]; then | |
print_warning "Does not exist: $1" | |
return | |
fi | |
cd $1 | |
if [[ ! -z $(git status -s) ]]; then | |
print_error "DIRTY: $1" | |
exit 1 | |
fi | |
if [[ $(git cherry -v) ]]; then | |
print_warning "NEEDS PUSH: $1" | |
print_warning "Attempting push" | |
git push | |
fi | |
print_warning "Updating remote: $1" | |
if [[ $(git pull > /dev/null) -ne 0 ]]; then | |
print_error "PULL failed: $1" | |
fi | |
# git remote update > /dev/null | |
if [[ $(git status -uno | grep -q "Your branch is up-to-date") -ne 0 ]]; then | |
print_error "NOT SYNCED: $1" | |
exit 1 | |
fi | |
print_good "OK: $1" | |
} | |
check_git_repo "$HOME/.password-store" | |
check_git_repo "$HOME/dotfiles" | |
check_git_repo "$GOPATH/src/github.com/dgraph-io/benchmarks" | |
check_git_repo "$GOPATH/src/github.com/dgraph-io/dgraph" | |
check_git_repo "$GOPATH/src/github.com/dgraph-io/experiments" | |
check_git_repo "$GOPATH/src/github.com/dgraph-io/gru" | |
check_git_repo "$GOPATH/src/github.com/dgraph-io/tools" | |
check_git_repo "$HOME/open" | |
check_git_repo "$HOME/open/public" | |
print_good "Shutting down the system. Goodbye!" | |
sleep 5 | |
/usr/bin/poweroff |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment