Skip to content

Instantly share code, notes, and snippets.

@abhi11210646
Last active May 21, 2018 15:28
Show Gist options
  • Save abhi11210646/46402f7358e1b1a013c2dc86ca6caf7f to your computer and use it in GitHub Desktop.
Save abhi11210646/46402f7358e1b1a013c2dc86ca6caf7f to your computer and use it in GitHub Desktop.
Shell script for connecting to EC2 instance and pulling code from github
#Make life easier by aliasing daily used commands
### edit .bashrc file
Step 1:- Move to home directory by typing.
>CD
Step 2:- Open .bashrc file.
>vim .bashrc
or
>nano .bashrc
Step 3:- Write aliases...
Hit "I" for vim editor to come in insert mode
alias gp='git pull'
alias pull-server='sh ~Desktop/pull-server.sh'
runProject() {
cd E:/Project/Node-api // mode to project directory
code . // run visual code editor
npm start // run nodeJs server
}
alias runProject='runProject' // now all these commands will run by typing "runProject" only
Step 4:- close and save file.
Hit esc key for Vim editor and type :wq to save and exit.
Hit ctr-O to save and ctr-x to exit for nano editor
#! /bin/sh
if [ "$1" = "cricket" ]; then
pwd="/home/outgrow/og-build/";
branch="cricket";
elif [ "$1" = "lazyCalc" ]; then
pwd="/home/outgrow/livec/og-build/";
branch="satnamoutgrow";
else
echo "Bad Argument!! $1. Allowed arguments are 'cricket' for frontend and 'lazyCalc' for live calculators"; exit;
fi
ssh -T -i ~/Desktop/ubuntu-ec2.pem [email protected] <<EOF
cd $pwd
echo Branch to be Pulled...
git branch
sudo git pull origin $branch
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment