This repository has been archived by the owner on Dec 21, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathupdate_config.py
executable file
·87 lines (67 loc) · 1.86 KB
/
update_config.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/usr/bin/env python
import difflib
import json
import os
import random
import string
import sys
import yaml
CONFIG = json.load(open('config/config.json'))
HEADER = '# This file is generated by update_config.py\n\n'
def Add(compose, name):
compose[name] = {
'build': name,
'links': ['master'],
'volumes': ['./config:/config'],
'volumes_from': ['volumes'],
}
def CreatePassword():
return ''.join(
random.choice(string.ascii_letters + string.digits)
for _ in range(16))
def WriteComposeYaml():
compose = {
'master': {
'build': 'master',
'ports': [
'8010:8010',
'9989:9989',
],
'volumes': [
'./config:/config',
'/var/www/clementine-player.org:/var/www/clementine-player.org',
],
'volumes_from': ['volumes'],
},
'volumes': {
'command': '/bin/true',
'image': 'ubuntu',
'volumes': ['/persistent-data'],
}
}
for distro, versions in CONFIG['linux'].iteritems():
for version in versions:
for bits in [64, 32]:
Add(compose, str('slave-%s-%s-%d' % (distro, version, bits)))
for slave in CONFIG['special_slaves']:
Add(compose, str('slave-' + slave))
with open('docker-compose.yml', 'w') as fh:
fh.write(HEADER)
yaml.dump(compose, fh, indent=2)
print 'Wrote docker-compose.yml'
def WritePasswords():
slaves = []
slaves.extend(CONFIG['special_slaves'])
for distro, versions in CONFIG['linux'].iteritems():
for version in versions:
for bits in [64, 32]:
slaves.append('%s-%s-%d' % (distro, version, bits))
passwords = {name: CreatePassword() for name in slaves}
with open('config/passwords.json', 'w') as fh:
json.dump(passwords, fh, indent=2, sort_keys=True)
print 'Wrote config/passwords.json'
def main():
WriteComposeYaml()
WritePasswords()
if __name__ == '__main__':
main()