/
openshift-quickstarter
executable file
·110 lines (94 loc) · 4.38 KB
/
openshift-quickstarter
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/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
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# 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 <http://www.gnu.org/licenses/>.
#
# Author: Luke Macken <lmacken@redhat.com>
import os, sys, subprocess
python = 'wsgi-3.2'
perl = 'perl-5.10'
java = 'jbossas-7.0'
ruby = 'rack-1.1'
php = 'php-5.3'
db = 'mysql-5.1'
openshift_repo = 'git://github.com/openshift/%s-example.git'
openshift_alt_repo = 'git://github.com/openshift/%s-openshift-quickstart.git'
lmacken_repo = 'git://github.com/lmacken/%s-openshift-quickstart.git'
lmacken_fork_repo = 'git://github.com/lmacken/%s-example.git'
quickstarts = {
'pyramid': {'type': python, 'db': True, 'repo': lmacken_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},
}
run = lambda cmd, **kw: subprocess.call(cmd, shell=True, **kw)
if len(sys.argv) != 5:
print(file('README.md').read())
sys.exit(1)
prog, login, domain, app_name, quickstart = sys.argv
if os.path.isdir(app_name):
print("Application '%s' already exists in current directory" % app_name)
sys.exit(1)
# Create the application & database
app = quickstarts[quickstart]
run('rhc-create-app -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-ctl-app -a %s -e add-%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"', cwd=app_name)
elif quickstart == 'piwik':
run('rm -fr php/*', cwd=app_name)
# Pull in the appropriate quickstart template
run('git remote add upstream -m master %s' % app['repo'] % quickstart,
cwd=app_name)
run('git pull -s recursive -X theirs upstream master', cwd=app_name)
# 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("\nComplete!")
print("You can view your application at http://%s-%s.rhcloud.com" % (
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)