Last active
          October 16, 2019 06:11 
        
      - 
      
- 
        Save rms1000watt/40419c06757b19885baf859dbda6b8d6 to your computer and use it in GitHub Desktop. 
    Update All (Update all github repos in a directory once every 5 minutes)
  
        
  
    
      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
    
  
  
    
  | #!/usr/bin/env bash | |
| # Usage: ./update-all.sh $GOPATH/src/github.com/rms1000watt | |
| B='\033[0;34m' | |
| NC='\033[0m' | |
| MAIN_DIR=$1 | |
| if [ -z $MAIN_DIR ]; then | |
| echo "No directory to walk and update" | |
| exit 1 | |
| fi | |
| if [ ! -d $MAIN_DIR ]; then | |
| echo "Directory $MAIN_DIR does not exist" | |
| exit 1 | |
| fi | |
| echo "Walking: $MAIN_DIR" | |
| while true; do | |
| for CHILD_DIR in $(ls -d $MAIN_DIR/*/); do | |
| if [ ! -d "$CHILD_DIR.git" ]; then | |
| continue | |
| fi | |
| cd $CHILD_DIR | |
| git pull upstream master --no-edit | |
| echo -e "${B}'git pull upstream master' from $(pwd)${NC}" | |
| cd $MAIN_DIR | |
| echo | |
| done | |
| echo "Sleeping for 5 min" | |
| sleep 300 | |
| clear | |
| printf '\e[3J' | |
| done | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment