Permalink
Browse files

Add appdir/ generation

added -a option

copy the entire apps site into myapps

Added apps.mozillalabs.com submodule

A bunch of changes to support deploying the appsync server successfully
  • Loading branch information...
1 parent 093278b commit 4edbb53d40223e107b4356a3717e7b292f9f3d0b @ianb ianb committed Nov 10, 2011
Showing with 16 additions and 226 deletions.
  1. +3 −0 .gitmodules
  2. +1 −0 site/tools/apps.mozillalabs.com
  3. +0 −224 site/tools/build_server
  4. +12 −2 site/tools/build_static
View
@@ -17,3 +17,6 @@
[submodule "site/tests/serverjs/djangode"]
path = site/tests/serverjs/djangode
url = https://github.com/mozilla/djangode.git
+[submodule "site/tools/apps.mozillalabs.com"]
+ path = site/tools/apps.mozillalabs.com
+ url = https://github.com/mozilla/apps.mozillalabs.com.git
View
@@ -1,224 +0,0 @@
-#!/bin/bash
-
-## This script sets up a server ala myapps.mozillalabs.com This
-## includes the JSAPI, the HTML implementation, the dashboard, and
-## /getmanifest (a small Python app)
-
-## This all has been tested with Ubuntu Natty Narwhal and Lucid (more
-## recently). It doesn't work with some older versions, though
-## probably only because of package name changes.
-
-# quit if there are any errors:
-set -e
-
-############################################################
-## Argument and ssh handling:
-############################################################
-
-OWA_BRANCH=develop
-OWA_REPO=https://github.com/mozilla/openwebapps.git
-SERVER_NAME=myapps.mozillalabs.com
-EXTRA_SERVER_NAMES=""
-SETUP=""
-
-help () {
- echo "Usage: $(basename $0) [OPTIONS]"
- echo "Sets up the server."
- echo "Options:"
- echo " -b BRANCH"
- echo " Sets the branch to check out (default $OWA_BRANCH)"
- echo " -r REPO"
- echo " Sets the repository to check out of (default $OWA_REPO)"
- echo " -s HOSTNAME"
- echo " Sets the hostname to setup (default $SERVER_NAME)"
- echo " -S EXTRA_HOSTNAME"
- echo " Adds another hostname which will respond"
- echo " -i"
- echo " Setup/initialize server; must be run as root."
- echo " This sets up nginx, etc. Otherwise this will just freshen the files"
-}
-
-while getopts hib:r:s:S: o ; do
- case "$o" in
- b)
- OWA_BRANCH="$OPTARG"
- ;;
- r)
- OWA_REPO="$OPTARG"
- ;;
- s)
- SERVER_NAME="$OPTARG"
- ;;
- S)
- EXTRA_SERVER_NAMES="$OPTARG $EXTRA_SERVER_NAMES"
- ;;
- h)
- help
- exit
- ;;
- i)
- SETUP="on"
- ;;
- [?])
- help
- exit 1
- ;;
- esac
-done
-shift $(($OPTIND-1))
-
-if [ -z "$SETUP" ] ; then
- if [ "$(whoami)" != "manager" ] ; then
- echo "Unless you use -i (initialize) you must run this as manager"
- exit 3
- fi
-fi
-
-echo "Checking out source from:"
-echo " $OWA_REPO branch $OWA_BRANCH"
-
-PREFIX="/var/www/$SERVER_NAME"
-
-OS_VERSION="$(awk '{print $2}' < /etc/issue)"
-
-## Note: only one OWA version is explicily supported right now, but
-## other versions could be added below:
-case "$OS_VERSION" in
- 10.04.1)
- # On later versions it's "nginx-full"
- NGINX_NAME="nginx"
- # On later versions it's "python-tornado"
- TORNADO_NAME=""
- ;;
- *)
- echo "Unknown Ubuntu version: $OS_VERSION"
- exit 2
- ;;
-esac
-
-## This sets up the server, and must be run as root:
-
-setup_server () {
-
- apt-get update
- apt-get --yes install \
- git-core \
- $NGINX_NAME \
- daemontools-run \
- $TORNADO_NAME \
- unzip \
- openjdk-6-jre-headless \
- python-lxml
-
- if [ -e /etc/nginx/sites-enabled/default ] ; then
- rm /etc/nginx/sites-enabled/default
- fi
-
- CONFIG="
-server {
- root $PREFIX/htdocs;
- index index.html;
- server_name $SERVER_NAME $EXTRA_SERVER_NAMES;
- location /getmanifest {
- proxy_pass http://127.0.0.1:8700/getmanifest;
- }
- #error_page 404 /404.html;
-}
-"
-
- echo "$CONFIG" > /etc/nginx/sites-available/${SERVER_NAME}.conf
- if [ ! -e /etc/nginx/sites-enabled/${SERVER_NAME}.conf ] ; then
- (
- cd /etc/nginx/sites-enabled
- ln -s ../sites-available/${SERVER_NAME}.conf
- )
- fi
-
- adduser --system manager || echo "manager already exists"
-
- /etc/init.d/nginx restart
-}
-
-## Note: this does *not* use $PREFIX, and there's only one instance per VM:
-setup_getmanifest () {
- if [ "$OWA_BRANCH" != "develop" ] ; then
- echo "Not recreating /getmanifest service"
- exit
- fi
- install -d -o manager -g www-data /var/www/getmanifest-service
- if [ -z "$TORNADO_NAME" ] ; then
- (
- cd $PREFIX/src/openwebapps/site/server
- mkdir -p deps
- cd deps
- wget https://github.com/downloads/facebook/tornado/tornado-2.1.tar.gz
- tar zfx tornado-2.1.tar.gz && rm tornado-2.1.tar.gz
- cd tornado-2.1
- python setup.py install --install-lib=$PREFIX/src/openwebapps/site/server/deps
- )
- fi
-
- echo "#!/bin/sh
-
-cd $PREFIX/src/openwebapps/site/server
-PYTHONPATH=\$PYTHONPATH:$PREFIX/src/openwebapps/site/server/deps
-export PYTHONPATH
-exec su www-data -c 'python server.py $PREFIX/log/getmanifest.log >> $PREFIX/log/getmanifest.log 2>&1'
-" > /var/www/getmanifest-service/run
- chmod +x /var/www/getmanifest-service/run
-
- update-service --add /var/www/getmanifest-service
-
- start svscan || echo "svscan already started"
-}
-
-setup_site () {
- install -o manager -g www-data -d $PREFIX $PREFIX/src $PREFIX/htdocs
- install -o www-data -g www-data -d $PREFIX/log
- checkout_site
- chown -R manager:www-data $PREFIX/htdocs
- chown -R manager:users $PREFIX/src
-}
-
-checkout_site () {
- (
- SRC_DIR=$PREFIX/src
- if [ ! -d $SRC_DIR ] ; then
- echo "Error: $SRC_DIR does not exist"
- echo "You probably need to run this with -i first"
- exit 2
- fi
- cd $SRC_DIR
- if [ ! -d openwebapps ] ; then
- git clone $OWA_REPO
- else
- cd openwebapps
- git pull
- fi
- )
-
- if [ ! -z "$OWA_BRANCH" ] ; then
- (
- cd $PREFIX/src/openwebapps
- if git branch | grep -q $OWA_BRANCH ; then
- # The branch is already checked out
- git checkout $OWA_BRANCH
- else
- git checkout -b $OWA_BRANCH origin/$OWA_BRANCH
- fi
- )
- fi
-
- rm -rf $PREFIX/htdocs/*
- $PREFIX/src/openwebapps/site/tools/build_static $PREFIX/htdocs
-
-}
-
-
-if [ ! -z "$SETUP" ] ; then
- setup_server
- setup_site
- setup_getmanifest
-else
- checkout_site
-fi
View
@@ -16,17 +16,23 @@ regex_escape () {
SITE="$(dirname $(dirname $(abspath $BASH_SOURCE)))"
HOST="https://myapps.mozillalabs.com"
ORIG_HOST="$HOST"
+APPDIR=""
help () {
- echo "Usage: $(basename $0) [-H https://...] DEST"
+ echo "Usage: $(basename $0) [-H https://...] [-a APPDIR] DEST"
echo "Builds the site in $SITE and puts it in DEST"
+ echo "-H sets the hostname (default $HOST)"
+ echo "-a gives the location of a checkout of apps.mozillalabs.com"
}
-while getopts H:h o ; do
+while getopts H:a:h o ; do
case "$o" in
H)
HOST="$OPTARG"
;;
+ a)
+ APPDIR="$OPTARG"
+ ;;
h)
help
exit
@@ -61,6 +67,10 @@ fi
cp --recursive --dereference ${SITE}/*.html ${SITE}/*.js ${SITE}/icongrid ${SITE}/css ${SITE}/fonts ${SITE}/img ${SITE}/js ${SITE}/jsapi $DEST
+if [ ! -z "$APPDIR" ] ; then
+ cp --recursive --dereference ${APPDIR}/ ${DEST}/apps
+fi
+
if [ "$HOST" != "$ORIG_HOST" ] ; then
echo "Replacing $ORIG_HOST with $HOST"
find "$DEST" \( -name "*.js" -o -name "*.html" \) -exec \

0 comments on commit 4edbb53

Please sign in to comment.