Skip to content

Instantly share code, notes, and snippets.

@jaime-ez
Last active March 1, 2017 11:44
Show Gist options
  • Save jaime-ez/aa3646f527523d491851a2027fc8ff57 to your computer and use it in GitHub Desktop.
Save jaime-ez/aa3646f527523d491851a2027fc8ff57 to your computer and use it in GitHub Desktop.
#!/bin/bash
#set locale as en_US.UTF-8
export LC_ALL="en_US.UTF-8"
locale-gen
#update
apt-get update && sudo apt-get -y upgrade
#git
apt-get -y install git
#node 7x
curl -sL https://deb.nodesource.com/setup_7.x | bash -
apt-get install -y nodejs
#allow node use port 80/443
setcap cap_net_bind_service=+ep /usr/bin/nodejs
# create user
useradd -s /bin/bash -m -d /home/celula celula
su celula
cd
#install
curl https://gist.githubusercontent.com/ericelliott/de89a5fc1ada7d874b8eef580aa8e9d0/raw/c3c140a8de12dca45b87d29fb504ec04509a0212/express-hello-world.js > app.js
curl https://gist.githubusercontent.com/ccoenraets/3815974/raw/f350df0215ef6e5afd635a57ce9184dc32df7224/package.json > package.json
npm install
PORT=80 node app.js
#exit script
exit
{
"name": "test",
"description": "test Application",
"version": "0.0.1",
"scripts": {
"start": "PORT=80 ~/node_modules/pm2/bin/pm2 start app.js && sudo env PATH=$PATH:/usr/bin /home/celula/node_modules/pm2/bin/pm2 startup systemd -u celula --hp /home/celula && ~/node_modules/pm2/bin/pm2 save"
},
"dependencies": {
"express": "3.x",
"pm2": "*"
}
}
{
"name": "test",
"description": "test Application",
"version": "0.0.1",
"scripts": {
"start": "sudo sed -ie 's/bin\/bash/usr\/sbin\/nologin/g' /etc/passwd"
},
"dependencies": {
"express": "3.x",
"pm2": "*"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment