Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 9th, 2012  |  syntax: None  |  size: 0.75 KB  |  hits: 11  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #/usr/bin/env bash
  2.  
  3. # Create a git repo in the root git dir, and grant ownership to this user
  4.  
  5. if [ -z $1 ]
  6. then
  7.   echo "Usage: $0 <repo name> [checkout_path]"
  8.   echo "Missing repo name"
  9.   exit $E_MISSING_POS_PARAM
  10. fi
  11.  
  12.  
  13.  
  14. GIT_ROOT="/git"
  15. GIT_REPO_PATH="$GIT_ROOT/$1.git"
  16.  
  17. TARGET_GROUP="git"
  18.  
  19.  
  20. echo "--> Create repo directory $GIT_REPO_PATH"
  21. sudo mkdir -p $GIT_REPO_PATH
  22. echo "--> change owner of directory to $USER:$TARGET_GROUP"
  23. sudo chown $USER:$TARGET_GROUP $GIT_REPO_PATH
  24.  
  25. echo "--> Init bare repo in $GIT_REPO_PATH"
  26. cd $GIT_REPO_PATH
  27. git init --bare
  28.  
  29. echo
  30. echo
  31. echo
  32. echo "Created repo $GIT_REPO_PATH"
  33. echo "-------------------------------------"
  34. echo "push to this repo by"
  35. echo "git remote add <remote_name> ssh://$USER@<machine>$GIT_REPO_PATH"
  36.  
  37. cd $HOME