public
Last active

node.js knockout 2011 StackScript

  • Download Gist
StackScript.sh
Shell
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
#!/bin/bash
 
# <UDF name="ssh_key" Label="Paste in your public SSH key" default="" example="" optional="false" />
 
# root ssh keys
mkdir /root/.ssh
echo $SSH_KEY >> /root/.ssh/authorized_keys
chmod 0700 /root/.ssh
 
# update to latest
apt-get update -y
apt-get upgrade -y
 
# install dependencies
apt-get install -y build-essential curl
apt-get install -y git || apt-get install -y git-core
 
# install node
apt-get install -y python-software-properties
add-apt-repository ppa:chris-lea/node.js
apt-get update
apt-get install -y nodejs
 
# install npm
curl http://npmjs.org/install.sh | clean=no sh
 
# setup a deploy user
useradd -U -s /bin/bash -m deploy
 
## NODE_ENV=production
echo 'export NODE_ENV=production' >> /home/deploy/.profile
 
## ssh directory
mkdir /home/deploy/.ssh
chmod 0700 /home/deploy/.ssh
 
## github known_hosts
cat <<EOF > /home/deploy/.ssh/known_hosts
|1|w8rL5TpJWjFsLe/KELv1839MbwU=|UCFegywpxF4ziwmF/GPYhuII4j4= ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==
|1|vP9WJ+xqyudty0nl6qqM+23NF+Q=|JsLmCcxKptEgKuPjUPmje6VrN28= ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==
EOF
 
## ssh keys
echo $SSH_KEY >> /home/deploy/.ssh/authorized_keys
curl http://nodeknockout.com/id_nko2.pub >> /home/deploy/.ssh/authorized_keys
chmod 600 /home/deploy/.ssh/authorized_keys
 
## permissions
chown -R deploy:deploy /home/deploy/.ssh
 
# upstart script
cat <<'EOF' > /etc/init/node.conf
description "node server"
 
start on filesystem or runlevel [2345]
stop on runlevel [!2345]
 
respawn
respawn limit 10 5
umask 022
 
script
HOME=/home/deploy
. $HOME/.profile
exec /usr/bin/node $HOME/app/current/app.js >> $HOME/app/shared/logs/node.log 2>&1
end script
 
post-start script
HOME=/home/deploy
PID=`status node | awk '/post-start/ { print $4 }'`
echo $PID > $HOME/app/shared/pids/node.pid
end script
 
post-stop script
HOME=/home/deploy
rm -f $HOME/app/shared/pids/node.pid
end script
EOF
 
# sudoers
cat <<EOF > /etc/sudoers.d/node
deploy ALL=NOPASSWD: /sbin/restart node
deploy ALL=NOPASSWD: /sbin/stop node
deploy ALL=NOPASSWD: /sbin/start node
EOF
chmod 0440 /etc/sudoers.d/node

What's the comment -
UDF name="ssh_key" Label="Paste in your public SSH key" default="" example="" optional="false" for?

it's so linode will prompt for an ssh key to install in their linode setup ui.

On Aug 28, 2011, at 5:03 AM, orsenthil wrote:

What's the comment - # for?

Reply to this email directly or view it on GitHub:
https://gist.github.com/1165971

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.