copied from internal repo
This commit is contained in:
72
main.py
Normal file
72
main.py
Normal file
@@ -0,0 +1,72 @@
|
||||
import argparse
|
||||
import configparser
|
||||
import os
|
||||
import pathlib
|
||||
|
||||
from conpeek_setup.file_generator import (generate_bind9, generate_env, generate_freeswitch,
|
||||
generate_kamailio, generate_mariadb,
|
||||
generate_metrics, generate_mongodb, generate_nginx,
|
||||
generate_mail_relay, generate_rabbitmq,
|
||||
generate_tokens, generate_cert)
|
||||
|
||||
from conpeek_setup import util
|
||||
|
||||
|
||||
def validate_config(config):
|
||||
sections_to_validate = [
|
||||
"deployment_purpose",
|
||||
"bind9",
|
||||
"new_machine_network",
|
||||
"machine_secrets",
|
||||
"operator"
|
||||
]
|
||||
|
||||
for section in sections_to_validate:
|
||||
if not config.has_section(section):
|
||||
util.print_red(f"No {section} section in config")
|
||||
raise Exception(f"No {section} section in config")
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser(description="")
|
||||
parser.add_argument("--action", type=str, required=True, help="Action")
|
||||
parser.add_argument("--config", type=str, required=True, help="Path to the config file")
|
||||
parser.add_argument("--output-path", type=str, required=False, help="Path to the output")
|
||||
parser.add_argument("--dev", help="Developer mode", action="store_true")
|
||||
|
||||
args = parser.parse_args()
|
||||
action = args.action
|
||||
config = configparser.ConfigParser()
|
||||
|
||||
config_directory = args.config
|
||||
if not os.path.abspath(config_directory):
|
||||
config_directory = os.path.join(pathlib.Path(__file__).parent.resolve(), config_directory)
|
||||
|
||||
config.read(config_directory)
|
||||
if args.output_path:
|
||||
util.Settings.output_directory = args.output_path
|
||||
|
||||
validate_config(config)
|
||||
generate_tokens.run(config)
|
||||
|
||||
if action == "mariadb" or action == "all":
|
||||
generate_mariadb.run(config)
|
||||
if action == "mongodb" or action == "all":
|
||||
generate_mongodb.run(config)
|
||||
if action == "rabbitmq" or action == "all":
|
||||
generate_rabbitmq.run(config)
|
||||
if action == "bind9" or action == "all":
|
||||
generate_bind9.run(config, args.dev)
|
||||
if action == "nginx" or action == "all":
|
||||
generate_nginx.run(config, args.dev)
|
||||
if action == "freeswitch" or action == "all":
|
||||
generate_freeswitch.run(config)
|
||||
if action == "kamailio" or action == "all":
|
||||
generate_kamailio.run(config)
|
||||
if action == "metrics" or action == "all":
|
||||
generate_metrics.run(config)
|
||||
if action == "mail_relay" or action == "all":
|
||||
generate_mail_relay.run(config)
|
||||
if action == "cert" or action == "all":
|
||||
generate_cert.run(config)
|
||||
if action == "env" or action == "all":
|
||||
generate_env.run(config)
|
||||
Reference in New Issue
Block a user