Created
November 17, 2011 06:07
-
-
Save wookiehangover/1372488 to your computer and use it in GitHub Desktop.
node.js build script w/ redis & couch
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 -x | |
# C2 build script which runs as "root" on first boot | |
# | |
# NOTE: variables that start with a percent-sign will be substituted | |
# using /var/cache/c2/build-inputs.json. | |
# | |
# Use double-percent to escape percent signs. | |
# Update System | |
apt-get -y update | |
# Install help app | |
apt-get -y install libssl-dev git-core pkg-config build-essential curl gcc g++ couchdb | |
# Download & Unpack Node.js - v. 0.6.1 | |
mkdir /home/ubuntu/node-src | |
cd /home/ubuntu/node-src | |
wget http://nodejs.org/dist/v0.6.1/node-v0.6.1.tar.gz | |
tar -zxf node-v0.6.1.tar.gz | |
# Install Node.js | |
cd node-v0.6.1 | |
./configure && make && make install | |
echo 'Node.js install completed' | |
# Install Redis | |
cd /tmp | |
mkdir redis && cd redis | |
wget http://redis.googlecode.com/files/redis-2.4.2.tar.gz | |
tar -zxf redis-2.4.2.tar.gz | |
cd redis-2.4.2 | |
make && make install | |
wget https://github.com/ijonas/dotfiles/raw/master/etc/init.d/redis-server | |
wget https://github.com/ijonas/dotfiles/raw/master/etc/redis.conf | |
mv redis-server /etc/init.d/redis-server | |
chmod +x /etc/init.d/redis-server | |
mv redis.conf /etc/redis.conf | |
useradd redis | |
mkdir -p /var/lib/redis | |
mkdir -p /var/log/redis | |
chown redis.redis /var/lib/redis | |
chown redis.redis /var/log/redis | |
update-rc.d redis-server defaults | |
# download/install user-specified packages | |
apt-get install -y --force-yes %(additional_packages)s | |
# install npm/coffeescript | |
export clean=yes | |
curl http://npmjs.org/install.sh | sh | |
npm install -g coffee-script | |
# bootstrap application | |
cd /home/ubuntu/repo | |
npm install | |
# install upstart daemon | |
cat > /etc/init/nodejs.conf <<EOF | |
#!upstart | |
description "node.js dev server" | |
author "OpDemand" | |
start on (local-filesystems and net-device-up IFACE=eth0) | |
stop on shutdown | |
script | |
export HOME="/home/ubuntu" | |
exec sudo -u ubuntu -i node /home/ubuntu/repo/app.js 2>&1 >> /var/log/nodejs.log | |
end script | |
EOF | |
# start the daemon | |
start nodejs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment