#!python

import os
import subprocess as sp
from getpass import getpass
from xseed_maxbox.sub_modules import installCommonPackagesTools as installCommon
from xseed_maxbox.sub_modules import prerequisiteChecks as checks
from xseed_maxbox.sub_modules import packageCleanUp as cleanup
from xseed_maxbox.sub_modules import configureMasterBox as configure
from xseed_maxbox.sub_modules import dockerCompose as dc
from xseed_maxbox.sub_modules import config
from xseed_maxbox.sub_modules import encryption
from xseed_maxbox.sub_modules import buildInstall

#Code to accept sudo password from user
sudo_password  = getpass("Enter sudo password: ")
miniCampus = input("Enter the miniCampus code:\n")
while True:
    buildEnv = input("Enter the env - Staging/Production:\n")
    if buildEnv.lower() not in ('staging', 'production'):
        print("Not an appropriate choice.")
    else:
        break
buildEnv = buildEnv.lower()
key = '1234'

dbusername = encryption.decode(config.mysql['username'],key)
dbpassword = encryption.decode(config.mysql['password'], key)
dockerusername = encryption.decode(config.docker['username'], key)
dockerpassword = encryption.decode(config.docker['password'], key)

#1. Install common packages and common tools
# installCommon.installCommonPackagesTools(sudo_password)
#
#2. Perform Prerequisite Checks
# checks.checks()

# 3. Configure configureMasterBox
# configure.configureMaster(sudo_password)

#4. Updating dockerCompose
dc.configureDocker(miniCampus, dbusername, dbpassword, dockerusername, dockerpassword, buildEnv)

#5. System cleanUp
# cleanup.cleanUp()

#6. Install builds
buildInstall.getUserInput(buildEnv)
