Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 122 lines (105 sloc) 4.76 KB
#!/usr/bin/env python
# OpenShift Quickstarter
# Deploy a variety of applications to the cloud with a single command.
# Copyright (C) 2011 Red Hat, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <>.
# Author: Luke Macken <>
import os
import sys
import subprocess
python = 'python-2.7'
perl = 'perl-5.10'
java = 'jbossas-7.0'
ruby = 'ruby-1.8'
php = 'php-5.3'
db = 'mysql-5.1'
openshift_repo = 'git://'
openshift_alt_repo = 'git://'
lmacken_repo = 'git://'
lmacken_fork_repo = 'git://'
ryansb_repo = 'git://'
quickstarts = {
'pyramid': {'type': python, 'db': True, 'repo': lmacken_repo},
'cornice': {'type': python, 'db': True, 'repo': ryansb_repo},
'turbogears2': {'type': python, 'db': True, 'repo': lmacken_repo},
'django': {'type': python, 'db': True, 'repo': lmacken_fork_repo},
'pyblosxom': {'type': python, 'db': False, 'repo': lmacken_repo},
'flask': {'type': python, 'db': False, 'repo': openshift_repo},
'rails': {'type': ruby, 'db': True, 'repo': openshift_repo},
'reviewboard': {'type': python, 'db': True, 'repo': openshift_repo},
'mediawiki': {'type': php, 'db': True, 'repo': openshift_repo},
'drupal': {'type': php, 'db': True, 'repo': openshift_repo},
'wordpress': {'type': php, 'db': True, 'repo': openshift_repo},
'cakephp': {'type': php, 'db': True, 'repo': openshift_repo},
'wolfcms': {'type': php, 'db': True, 'repo': openshift_repo},
'frogcms': {'type': php, 'db': True, 'repo': openshift_repo},
'seambooking': {'type': java, 'db': True, 'repo': openshift_repo},
'sqlbuddy': {'type': php, 'db': True, 'repo': openshift_alt_repo},
'dancer': {'type': perl, 'db': False, 'repo': openshift_repo},
'sinatra': {'type': ruby, 'db': False, 'repo': openshift_repo},
'piwik': {'type': php, 'db': True, 'repo': openshift_alt_repo},
'sugarcrm': {'type': php, 'db': True, 'repo': openshift_repo},
'tweetstream': {'type': java, 'db': False, 'repo': openshift_repo,
'manual_config': True},
'joomla': {'type': php, 'db': True, 'repo': openshift_repo},
'phpbb': {'type': php, 'db': True, 'repo': openshift_repo},
def run(cmd, **kw):
status =, shell=True, **kw)
if status != 0:
print "** '%s' failed. Aborting" % cmd
if len(sys.argv) != 5:
print(file(os.path.join(os.path.dirname(__file__), '')).read())
prog, login, domain, app_name, quickstart = sys.argv
if os.path.isdir(app_name):
print("Application '%s' already exists in current directory" % app_name)
# Create the application & database
app = quickstarts[quickstart]
run('rhc app create -a %s -t %s -l %s' % (app_name, app['type'], login))
if app['db']:
print("Adding %s cartridge to %s" % (db, app_name))
run('rhc cartridge add -a %s -c %s -l %s' % (app_name, db, login))
# Pre-merge configuration
if quickstart == 'dancer':
run('git rm -fr perl', cwd=app_name)
run('git commit -a -m "remove stock perl dir to prepare for Dancer"',
elif quickstart == 'piwik':
run('rm -fr php/*', cwd=app_name)
# Pull in the appropriate quickstart template
run('git remote add quickstart -m master %s' % app['repo'] % quickstart,
run('git pull -s recursive -X theirs --no-rebase quickstart master',
# Pre-deployment configuration
if quickstart in ('frogcms', 'wolfcms'):
run('sed -i -e "s/%s-dbvs/%s-%s/" php/config.php' % (
quickstart, app_name, domain), cwd=app_name)
run('git commit -am "Update the base URL"', cwd=app_name)
# Push our code to the cloud
run('git push', cwd=app_name)
print("You can view your application at" % (
app_name, domain))
# Mention required manual configuration for certain apps
if app.get('manual_config'):
print("Manual configuration is required for this application.")
print("See this page for details: %s#readme" %
app['repo'].replace('.git', '').replace('git:', 'http:') % quickstart)