Permalink
Browse files

Updated npm scripts, moved a bunch of deployment scripts around (tryi…

…ng to find a smooth provisioning + deployment solution that's node-based ideally)
  • Loading branch information...
hunterloftis committed Mar 29, 2012
1 parent c182b30 commit 1c2480b0d204c8ffe0d7226139a75541a85a0d25
File renamed without changes.
View
@@ -0,0 +1,16 @@
+{
+ "type": "joyent",
+ "setup": {
+
+ },
+ "install": {
+ "redis":"2.4.9",
+ "mongodb":"2.0.4",
+ "node":"0.6.12"
+ },
+ "keys": [
+ "davidbecher.pub",
+ "jimsnodgrass.pub",
+ "hunterloftis.pub"
+ ]
+}
View
@@ -25,7 +25,7 @@
"scripts": {
"start": "./run",
"lock": "scripts/module_lock.js",
- "postinstall": "scripts/postinstall.js",
+ "postinstall": "scripts/npm/postinstall.js",
"test": "vows test/*.vows.js"
},
"constants": {
File renamed without changes.
File renamed without changes.
View
@@ -0,0 +1,39 @@
+#!/usr/bin/env bash
+
+. ./common.sh
+
+setup() {
+ export remotename="joyent-$ENV"
+ export host_ip=`config_get host`
+ hr
+ log "Adding $remotename as git remote"
+ git remote add $remotename node@$host_ip:repo
+}
+
+deploy() {
+ export remotename="joyent-$ENV"
+ git push $remotename master
+}
+
+require_env() {
+ config_section $ENV || abort "[$ENV] config section not defined"
+ test -z "$ENV" && abort "<env> required"
+}
+
+while test $# -ne 0; do
+ arg=$1; shift
+ case $arg in
+ setup) require_env; setup $@; exit ;;
+ *)
+ if test -z "$ENV"; then
+ ENV=$arg;
+ else
+ REF="$REF $arg";
+ fi
+ ;;
+ esac
+done
+
+require_env
+
+deploy
View
@@ -0,0 +1,88 @@
+#!/usr/bin/env bash
+
+. ./common.sh
+
+log "PROVISIONING JOYENT ($@)"
+
+environment() {
+ hr
+ log "setting up environment"
+ run "admin" "pkgin -y up"
+ run "admin" "pkgin -y in ImageMagick-6.6.6.5"
+}
+
+mongo() {
+ if [[ `config_get stack` != 'node' ]]; then return 0; fi
+ hr
+ log "installing mongo"
+ run "admin" "curl -O http://wiki.joyent.com/download/attachments/1639170/mongodbnode.sh"
+ run "admin" "bash mongodbnode.sh 2.0.2"
+ run "admin" "source ~/.bashrc"
+ run "admin" "pfexec svcadm enable mongodb"
+}
+
+redis() {
+ if [[ `config_get stack` != 'node' ]]; then return 0; fi
+ hr
+ log "installing redis"
+ run "admin" "pkgin -y in redis"
+ run "admin" "svccfg import /opt/local/share/smf/manifest/redis.xml"
+ run "admin" "svcadm enable redis"
+}
+
+#
+# Provision
+#
+
+provision() {
+ environment
+ mongo
+ redis
+}
+
+#
+# Require environment arg.
+#
+
+require_env() {
+ config_section $ENV || abort "[$ENV] config section not found in deploy.conf"
+ test -z "$ENV" && usage && exit
+
+ # settings that can be computed from the deploy.conf vars
+ PROJECTNAME=`config_get project`
+ test -z "$PROJECTNAME" && abort "project name must be specified in deploy.conf"
+ REMOTEPATH="/home/$PROJECTNAME/app"
+}
+
+# parse argv
+
+while test $# -ne 0; do
+ arg=$1; shift
+ case $arg in
+ -h|--help) usage; exit ;;
+ -V|--version) version; exit ;;
+ -C|--chdir) log cd $1; cd $1; shift ;;
+ all) require_env; all; exit ;;
+ keys) require_env; keys; exit ;;
+ deployer) require_env; deployer; exit ;;
+ environment) require_env; environment; exit ;;
+ node) require_env; node; exit ;;
+ upstart) require_env; upstart; exit;;
+ mongo) require_env; mongo; exit ;;
+ redis) require_env; redis; exit ;;
+ nginx) require_env; nginx; exit ;;
+ config) config $@; exit ;;
+ *)
+ if test -z "$ENV"; then
+ ENV=$arg;
+ else
+ REF="$REF $arg";
+ fi
+ ;;
+ esac
+done
+
+require_env
+
+# provision
+provision
File renamed without changes.
@@ -4,8 +4,9 @@ var path = require('path'),
fs = require('fs'),
util = require('util');
-var src = __dirname + '/../env/default.env.json',
- dst = __dirname + '/../.env.json';
+var dir = process.cwd();
+var src = dir + '/config/default.env.json',
+ dst = dir + '/.env.json';
path.exists(dst, function(exists) {
if (exists) {
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,62 @@
+#!/usr/bin/env node
+
+var cmd = require('commander');
+
+cmd
+ .version('0.0.1')
+ .usage('[options] <ip> <file>')
+ .option('-s, --setup', 'Perform initial setup')
+ .option('-u, --user', 'Create deploy user')
+ .option('-k, --keys', 'Install public ssh keys')
+ .option('-i, --install', 'Install software')
+ .parse(process.argv);
+
+var config;
+var ip = cmd.args[0];
+var config_file = process.cwd() + '/' + cmd.args[1];
+var script_set;
+
+try {
+ config = require(config_file);
+}
+catch(e) {
+ process.stdout.write(cmd.helpInformation());
+ return;
+}
+
+function section(name) {
+ console.log('\n=== ' + name + ' ===');
+}
+
+script_set = require('./types/' + config.type)(config);
+
+init();
+
+function init() {
+ console.log('\nProvisioning ' + ip );
+ console.log('Using ' + config_file);
+
+ if (cmd.setup) setup();
+ if (cmd.user) user();
+ if (cmd.keys) keys();
+ if (cmd.install) install();
+
+ console.log('\ndone.');
+}
+
+function setup() {
+ section('Setup');
+ script_set.setup();
+}
+
+function user() {
+ section('User');
+}
+
+function keys() {
+ section('Keys');
+}
+
+function install() {
+ section('Install');
+}
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,10 @@
+module.exports = function(config) {
+ return {
+
+ setup: function() {
+ console.log("Setting up for Joyent");
+ console.log("Config is:", config);
+ }
+
+ };
+};
File renamed without changes.

0 comments on commit 1c2480b

Please sign in to comment.