Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
node.js knockout 2011 StackScript
#!/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
@orsenthil

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

@visnup
Owner
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.