Last active
February 19, 2016 18:39
-
-
Save stevenmirabito/e20c3849ead960ed526a 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
#!/bin/bash | |
# CS2 Lab Git Repo Creation Script | |
# Author: Steven Mirabito ([email protected]) | |
# Server | |
CS_SERVER="orbison.cs.rit.edu" | |
# Username | |
CS_USER="stm4445" | |
# Lab Number (get from command line args by default) | |
LAB_NUM=$1 | |
# ============================= | |
# DO NOT EDIT BELOW THIS LINE | |
# ============================= | |
if [ "$#" -ne 1 ]; then | |
echo "usage: cs2lab <lab number>" | |
exit 1 | |
fi | |
# Pretty output | |
color=`tput setaf 1` | |
reset=`tput sgr0` | |
# Create the repository on the server and get the path | |
echo "${color}Creating remote repository...${reset}" | |
GIT_REMOTE=$(ssh ${CS_USER}@${CS_SERVER} "mkdir -p ~/Courses/CS2/Labs/Lab${LAB_NUM}.git && cd ~/Courses/CS2/Labs/Lab${LAB_NUM}.git && git init --bare > /dev/null 2>&1 && pwd") | |
# Initialize the local repository | |
echo "${color}Creating local repository...${reset}" | |
mkdir "Lab${LAB_NUM}" | |
cd "Lab${LAB_NUM}" | |
git init | |
# Add remote repo as origin | |
echo "${color}Configuring local repository...${reset}" | |
git remote add origin ${CS_USER}@${CS_SERVER}:${GIT_REMOTE} | |
# Build the .gitignore | |
rm -f .gitignore | |
# IDEs | |
echo "${color}Adding Eclipse to .gitignore...${reset}" | |
wget https://raw.githubusercontent.com/github/gitignore/master/Global/Eclipse.gitignore --quiet -O - >> .gitignore | |
echo "${color}Adding JetBrains to .gitignore...${reset}" | |
wget https://raw.githubusercontent.com/github/gitignore/master/Global/JetBrains.gitignore --quiet -O - >> .gitignore | |
# Operating Systems | |
if [[ "$OSTYPE" == "linux-gnu" ]]; then | |
echo "${color}Adding Linux to .gitignore...${reset}" | |
wget https://raw.githubusercontent.com/github/gitignore/master/Global/Linux.gitignore --quiet -O - >> .gitignore | |
elif [[ "$OSTYPE" == "darwin"* ]]; then | |
echo "${color}Adding OS X to .gitignore...${reset}" | |
wget https://raw.githubusercontent.com/github/gitignore/master/Global/OSX.gitignore --quiet -O - >> .gitignore | |
elif [[ "$OSTYPE" == "cygwin" ]] || [[ "$OSTYPE" == "msys" ]] || [[ "$OSTYPE" == "win32" ]]; then | |
echo "${color}Adding Windows to .gitignore...${reset}" | |
wget https://raw.githubusercontent.com/github/gitignore/master/Global/Windows.gitignore --quiet -O - >> .gitignore | |
fi | |
# Commit and push | |
echo "${color}Performing initial commit...${reset}" | |
git add .gitignore | |
git commit -m "Initial commit" | |
git push -u origin master | |
# Done! | |
echo "${color}Done!${reset}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment