|
|
@@ -1,5 +1,6 @@ |
|
|
|
#!/usr/bin/env python3 |
|
|
|
|
|
|
|
import os |
|
|
|
from collections import OrderedDict |
|
|
|
import sys |
|
|
|
|
|
|
@@ -85,6 +86,14 @@ def main(): |
|
|
|
|
|
|
|
command = sys.argv[1] |
|
|
|
if command == 'init': |
|
|
|
# Check if a config already exists |
|
|
|
if os.path.exists('config.json'): |
|
|
|
print('A config exists here, overwrite? [y/n, default: n] ', end='', flush=True) |
|
|
|
yesno = input() |
|
|
|
if yesno != 'y': |
|
|
|
print('leaving config unchanged') |
|
|
|
sys.exit(1) |
|
|
|
|
|
|
|
# Make a new config object and read all the properties. |
|
|
|
cfg = {} |
|
|
|
for k in PROPS: |
|
|
@@ -110,6 +119,7 @@ def main(): |
|
|
|
# Load the config. |
|
|
|
cfg = read_config() |
|
|
|
|
|
|
|
# Read the template. |
|
|
|
tmplt = None |
|
|
|
try: |
|
|
|
with open('compose-template.yml', 'r') as f: |
|
|
@@ -118,6 +128,7 @@ def main(): |
|
|
|
print('error reading template:', e) |
|
|
|
sys.exit(1) |
|
|
|
|
|
|
|
# Fill in the template and save it. |
|
|
|
gen = apply_template_settings(tmplt, cfg) |
|
|
|
try: |
|
|
|
with open('docker-compose.yml', 'w') as f: |