-
Notifications
You must be signed in to change notification settings - Fork 1
/
rooter.py
executable file
·65 lines (55 loc) · 1.51 KB
/
rooter.py
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
#!/usr/bin/env python
#coding: utf-8
import optparse
from config import *
import vhosts
parser = optparse.OptionParser()
parser.add_option('-a', '--add',
help="Add Vhost",
dest="add",
action="store_true",
)
parser.add_option('-d', '--delete', help="Remove Vhost",
action="store_true",
dest="delete"
)
parser.add_option('-t', '--type',
type='choice',
action='store',
dest='vhost_type',
choices=['php', 'uwsgi'],
default='php',
help='Vhost type. Choices: php / uwsgi',)
parser.add_option('--domain',
help="Domain Name",
type="string",
dest="domain_name"
)
parser.add_option('--root',
help="Document Root",
type="string",
dest="docroot"
)
(opts, args) = parser.parse_args()
if opts.add and opts.delete:
print "Use only one mode --add OR --delete\n"
parser.print_help()
exit(-1)
if opts.delete:
if not opts.domain_name:
print "Bad usage. No domain name given."
parser.print_help()
exit(-1)
else:
vhosts.delete_vhost(opts.domain_name)
if opts.add:
if opts.domain_name and opts.docroot and opts.vhost_type:
vhosts.add_vhost(
domain_name=opts.domain_name,
document_root=opts.docroot,
vhost_type=opts.vhost_type
)
else:
print "Bad usage. Domain name, Document Root and Vhost type required"
parser.print_help()
exit(-1)