Initial commit

This commit is contained in:
Jeff Morgan
2014-08-27 13:45:22 -07:00
commit bdf0949190
149 changed files with 15588 additions and 0 deletions

58
script/bundle.sh Executable file
View File

@@ -0,0 +1,58 @@
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source $DIR/colors.sh
BASE=$DIR/..
pushd $BASE/meteor
if ! type "mrt" > /dev/null 2>&1; then
cecho "meteorite not found, install using npm install meteorite -g" $red
exit 1
fi
if ! type "demeteorizer" > /dev/null 2>&1; then
cecho "Demeteorizer not found, install using npm install demeteorizer -g" $red
exit 1
fi
rm -rf ../bundle
cecho "-----> Building bundle from Meteor app, this may take a few minutes..." $blue
demeteorizer -o ../bundle
cd ../bundle
awk '!/fibers/' package.json > temp && mv temp package.json
awk '!/node-aes-gcm/' package.json > temp && mv temp package.json
awk '!/kexec/' package.json > temp && mv temp package.json
awk '!/heapdump/' package.json > temp && mv temp package.json
awk '!/bcrypt/' package.json > temp && mv temp package.json
NPM="$BASE/resources/cache/node/bin/npm"
NODE="$BASE/resources/cache/node/bin/node"
cecho "-----> Installing bundle npm packages." $blue
$NPM install
cecho "-----> Installing custom npm packages." $blue
$NPM install fibers@git+https://github.com/usekite/node-fibers.git --save
$NPM install node-aes-gcm@git+https://github.com/usekite/node-aes-gcm.git --save
$NPM install kexec@git+https://github.com/usekite/node-kexec.git --save
$NPM install heapdump@git+https://github.com/usekite/node-heapdump.git --save
$NPM install bcrypt@0.8.0 --save
cecho "-----> Removing unnecessary node_modules" $blue
rm -rf ./programs/ctl/node_modules
cecho "-----> Fixing Fibers for node-webkit" $blue
$NPM install nw-gyp -g
FIBERS_ARCH=$($NODE -p -e 'process.platform + "-" + process.arch + "-v8-" + /[0-9]+\.[0-9]+/.exec(process.versions.v8)[0]')
cd ./node_modules/fibers
$BASE/resources/cache/node/bin/nw-gyp rebuild --target=0.10.2 --arch=x64
mkdir -p ./bin/$FIBERS_ARCH
cp ./build/Release/fibers.node ./bin/$FIBERS_ARCH/fibers.node
cecho "Bundle created." $green
popd

12
script/colors.sh Normal file
View File

@@ -0,0 +1,12 @@
green='\033[00;32m'
purple='\033[00;35m'
blue='\033[00;34m'
red='\033[00;31m'
function cecho {
local default_msg="No message passed."
message=${1:-$default_msg} # Defaults to default message.
color=${2:-$green}
echo -e -n "$color$message"
echo -e '\033[0m'
}

68
script/dist.sh Executable file
View File

@@ -0,0 +1,68 @@
#!/bin/bash
set -e # Auto exit on error
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source $DIR/colors.sh
source $DIR/versions.sh
BASE=$DIR/..
pushd $BASE
if [ ! -d bundle ]; then
cecho "No bundle, run script/bundle.sh first." $red
exit 1
fi
rm -rf dist/osx/Kitematic.app
rm -rf dist/osx/Kitematic.zip
mkdir -p dist/osx/
cecho "-----> Creating Kitematic.app..." $blue
cp -R resources/node-webkit/node-webkit.app dist/osx/
mv dist/osx/node-webkit.app dist/osx/Kitematic.app
mkdir -p dist/osx/Kitematic.app/Contents/Resources/app.nw
cecho "-----> Copying meteor bundle into Kitematic.app..." $blue
cp -R bundle dist/osx/Kitematic.app/Contents/Resources/app.nw/
cecho "-----> Copying node-webkit app into Kitematic.app..." $blue
cp index.html dist/osx/Kitematic.app/Contents/Resources/app.nw/
cp index.js dist/osx/Kitematic.app/Contents/Resources/app.nw/
cp package.json dist/osx/Kitematic.app/Contents/Resources/app.nw/
cp -R node_modules dist/osx/Kitematic.app/Contents/Resources/app.nw/
$DIR/setup.sh
cecho "-----> Copying binary files to Kitematic.app" $blue
mkdir -p dist/osx/Kitematic.app/Contents/Resources/app.nw/resources
cp resources/$BASE_IMAGE_FILE dist/osx/Kitematic.app/Contents/Resources/app.nw/resources/
cp resources/$VIRTUALBOX_FILE dist/osx/Kitematic.app/Contents/Resources/app.nw/resources/
cp resources/$COCOASUDO_FILE dist/osx/Kitematic.app/Contents/Resources/app.nw/resources/
cp resources/$BOOT2DOCKER_CLI_FILE dist/osx/Kitematic.app/Contents/Resources/app.nw/resources/
cp resources/install dist/osx/Kitematic.app/Contents/Resources/app.nw/resources/
cp resources/terminal dist/osx/Kitematic.app/Contents/Resources/app.nw/resources/
cp resources/unison dist/osx/Kitematic.app/Contents/Resources/app.nw/resources/
cp resources/UNISON_LICENSE.txt dist/osx/Kitematic.app/Contents/Resources/app.nw/resources/
cp resources/kite-binaries.tar.gz dist/osx/Kitematic.app/Contents/Resources/app.nw/resources/
cp resources/mongod dist/osx/Kitematic.app/Contents/Resources/app.nw/resources/
cp resources/MONGOD_LICENSE.txt dist/osx/Kitematic.app/Contents/Resources/app.nw/resources/
chmod +x dist/osx/Kitematic.app/Contents/Resources/app.nw/resources/$BOOT2DOCKER_CLI_FILE
chmod +x dist/osx/Kitematic.app/Contents/Resources/app.nw/resources/$COCOASUDO_FILE
chmod +x dist/osx/Kitematic.app/Contents/Resources/app.nw/resources/install
chmod +x dist/osx/Kitematic.app/Contents/Resources/app.nw/resources/terminal
chmod +x dist/osx/Kitematic.app/Contents/Resources/app.nw/resources/unison
if [ -f $DIR/sign.sh ]; then
$DIR/sign.sh $BASE/dist/osx/Kitematic.app
fi
pushd dist/osx
cecho "-----> Creating disributable zip file...." $blue
zip -rq --display-dots Kitematic.zip Kitematic.app
popd
cecho "Done." $green
cecho "Kitematic app available at dist/osx/Kitematic.app" $green
cecho "Kitematic zip distribution available at dist/osx/Kitematic.zip" $green
popd

16
script/run.sh Executable file
View File

@@ -0,0 +1,16 @@
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
BASE=$DIR/..
export ROOT_URL=https://localhost:3000
export DOCKER_HOST=http://192.168.59.103
export DOCKER_PORT=2375
#export METEOR_SETTINGS=`cat $BASE/meteor/settings_dev.json`
#echo $METEOR_SETTINGS
cd $BASE/meteor
exec 3< <(mrt --settings $BASE/meteor/settings_dev.json)
sed '/App running at/q' <&3 ; cat <&3 &
NODE_ENV=development $BASE/resources/node-webkit/node-webkit.app/Contents/MacOS/node-webkit $BASE

75
script/setup.sh Executable file
View File

@@ -0,0 +1,75 @@
#!/bin/bash
set -e # Auto exit on error
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source $DIR/colors.sh
source $DIR/versions.sh
BASE=$DIR/..
pushd $BASE
mkdir -p resources/cache
pushd resources/cache
if [ ! -f $BASE_IMAGE_VERSION_FILE ]; then
cecho "-----> Downloading Kitematic base images..." $purple
curl -L --progress-bar -o $BASE_IMAGE_VERSION_FILE https://s3.amazonaws.com/kite-installer/$BASE_IMAGE_VERSION_FILE
fi
if [ ! -f $BOOT2DOCKER_CLI_VERSION_FILE ]; then
cecho "-----> Downloading Boot2docker CLI..." $purple
curl -L -o $BOOT2DOCKER_CLI_VERSION_FILE https://github.com/boot2docker/boot2docker-cli/releases/download/v${BOOT2DOCKER_CLI_VERSION}/boot2docker-v${BOOT2DOCKER_CLI_VERSION}-darwin-amd64
fi
if [ ! -f kite-node-webkit.tar.gz ]; then
cecho "-----> Downloading node-webkit..." $purple
curl -L -o kite-node-webkit.tar.gz https://s3.amazonaws.com/kite-installer/kite-node-webkit.tar.gz
tar -zxf kite-node-webkit.tar.gz -C ..
fi
if [ ! -f mongodb-osx-x86_64-2.6.3.tgz ]; then
cecho "-----> Downloading mongodb..." $purple
curl -L -o mongodb-osx-x86_64-2.6.3.tgz http://downloads.mongodb.org/osx/mongodb-osx-x86_64-2.6.3.tgz
tar -zxvf mongodb-osx-x86_64-2.6.3.tgz
cp mongodb-osx-x86_64-2.6.3/bin/mongod ..
cp mongodb-osx-x86_64-2.6.3/GNU-AGPL-3.0 ../MONGOD_LICENSE.txt
fi
if [ ! -f "node-v0.11.13-darwin-x64.tar.gz" ]; then
cecho "-----> Downloading Nodejs distribution..." $purple
curl -L -o node-v0.11.13-darwin-x64.tar.gz http://nodejs.org/dist/v0.11.13/node-v0.11.13-darwin-x64.tar.gz
mkdir -p node
tar -xzf node-v0.11.13-darwin-x64.tar.gz --strip-components 1 -C node
fi
popd
pushd resources
if [ ! -f $VIRTUALBOX_FILE ]; then
cecho "-----> Downloading virtualbox installer..." $purple
curl -L --progress-bar -o $VIRTUALBOX_FILE https://s3.amazonaws.com/kite-installer/$VIRTUALBOX_FILE
fi
if [ ! -f $COCOASUDO_FILE ]; then
cecho "-----> Downloading Cocoasudo binary..." $purple
curl -L -o $COCOASUDO_FILE https://github.com/performantdesign/cocoasudo/blob/master/build/Release/cocoasudo
chmod +x $COCOASUDO_FILE
fi
cecho "-----> Creating binary files from cache" $blue
if [ ! -f $BASE_IMAGE_FILE ]; then
cp cache/$BASE_IMAGE_VERSION_FILE $BASE_IMAGE_FILE
fi
if [ ! -f $BOOT2DOCKER_CLI_FILE ]; then
cp cache/$BOOT2DOCKER_CLI_VERSION_FILE $BOOT2DOCKER_CLI_FILE
chmod +x $BOOT2DOCKER_CLI_FILE
fi
popd
popd

11
script/versions.sh Normal file
View File

@@ -0,0 +1,11 @@
BASE_IMAGE_VERSION=0.0.1
BASE_IMAGE_VERSION_FILE=base-images-$BASE_IMAGE_VERSION.tar.gz
BASE_IMAGE_FILE=base-images.tar.gz
VIRTUALBOX_FILE=virtualbox-4.3.12.pkg
BOOT2DOCKER_CLI_VERSION=1.1.2
BOOT2DOCKER_CLI_VERSION_FILE=boot2docker-$BOOT2DOCKER_CLI_VERSION
BOOT2DOCKER_CLI_FILE=boot2docker
COCOASUDO_FILE=cocoasudo