-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_instance.py
More file actions
executable file
·29 lines (24 loc) · 911 Bytes
/
create_instance.py
File metadata and controls
executable file
·29 lines (24 loc) · 911 Bytes
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
#!/usr/bin/python
from optparse import OptionParser
import tomcat
import mysql
import nginx
# parameters for DB and nginx
db_host = "localhost"
db_user = "root"
db_pass = "123"
nginx_host = "jtalks.org"
nginx_user = "nginxconf"
nginx_key_file = "/home/tomcat/.ssh/id_rsa"
# parse command-line arguments
parser = OptionParser()
parser.add_option("-n", "--name", dest="instance_name",
help="instance NAME", metavar="NAME")
parser.add_option("-p", "--port", dest="port",
help="port number for Tomcat server", metavar="PORT")
(options, args) = parser.parse_args()
# install tomcat, create database and configure nginx
tomcat.install(options.instance_name, options.port)
mysql.create(db_host, options.instance_name, db_user, db_pass)
nginx.add(nginx_host, nginx_user, nginx_key_file, options.instance_name, options.port)
nginx.restart(nginx_host, nginx_user, nginx_key_file)