Last active
April 9, 2019 03:20
-
-
Save rknell/2ef1016ead63168823c13948ab91b40d to your computer and use it in GitHub Desktop.
# What it does Sets up - Nginx, Node LTS, GIT, Creates an SSH key for GIT, Yarn, PM2, Certbot (LetsEncrypt), #
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
#!/bin/sh | |
# What it does | |
# Sets up - Nginx, Node LTS, GIT, Creates an SSH key for GIT, Yarn, PM2, PM2 Logrotate, Certbot (LetsEncrypt), | |
# | |
cd ~ | |
sudo add-apt-repository ppa:certbot/certbot -y | |
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - | |
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list | |
sudo apt update -y | |
sudo apt install nginx git python-certbot-nginx yarn build-essential -y | |
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash | |
export NVM_DIR="$HOME/.nvm" | |
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" | |
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" | |
nvm install lts/* | |
nvm alias default lts/* | |
nvm use lts/* | |
source .bashrc | |
npm install -g pm2 | |
pm2 install pm2-logrotate | |
ssh-keygen -f ~/.ssh/id_rsa -t rsa -N '' | |
### Setup Done ### | |
echo What is the domain name you are setting up? | |
read DOMAINNAME | |
### Set the following to NGINX in /etc/sites-available/default | |
# see http://nginx.org/en/docs/http/ngx_http_upstream_module.html#example | |
sudo echo "upstream backend { | |
server 127.0.0.1:3000 weight=5; | |
} | |
server { | |
listen 80; | |
client_max_body_size 300m; | |
server_name $DOMAINNAME; | |
location / { | |
proxy_pass http://backend; | |
} | |
} | |
" > ~/nginxconfig | |
sudo cp nginxconfig /etc/nginx/sites-available/default | |
rm nginxconfig | |
if [ -z "$DOMAINANME" ]; | |
then | |
sudo certbot --nginx -d $DOMAINNAME; | |
fi; | |
echo "Add the following to your github repo:" | |
echo "----------" | |
cat ~/.ssh/id_rsa.pub | |
echo "" | |
read null | |
echo "Cloning the repo!" | |
echo "What is the repo name? ie [email protected]" | |
read CLONECOMMAND | |
cd ~ && git clone $CLONECOMMAND | |
echo "Please review NGINX config, hit enter to continue" | |
sudo nano /etc/nginx/sites-available/default | |
sudo systemctl restart nginx | |
echo "-------------------------" | |
echo "All done!" | |
echo "-------------------------" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment