# Path: install/packages.py
# def install(installType):
# 
# Path: install/bro.py
# def install(chosenInterface,webServer):
# 
# Path: install/criticalStack.py
# def get_user_input(input_string):
# def install(csKey):
# 
# Path: install/logstash.py
# def get_user_input(input_string):
# def install(esServer,esUser,esPass):
# 
# Path: install/kibana.py
# def install(chosenInterfaceIP):
# def importDashboard(jsonFileName):
# def importIndexMapping(jsonFileName):
# 
# Path: install/sweetSecurity.py
# def installClient(chosenInterface):
# def installServer():
# def addWebCreds(address,user,pwd,location):
# 
# Path: install/apache.py
# def get_user_input(input_string):
# def install(installType,chosenInterface,chosenIP):
# 
# Path: install/fail2ban.py
# def install():


import argparse, fcntl, getpass, json, os, re, shutil, socket, sqlite3, struct, sys
from time import sleep
from install import packages
from install import bro
from install import criticalStack
from install import elasticSearch
from install import logstash
from install import kibana
from install import sweetSecurity
from install import apache
from install import fail2ban
            while True:
                installCriticalStack = get_user_input(
                    "\033[1mInstall Critical Stack Threat Intel For Bro IDS (Y/n)\033[0m: ")
                if installCriticalStack.lower() not in ('y', 'n', ''):
                    print "Must choose Y or N."
                else:
                    break
            if installCriticalStack.lower() == 'y' or len(installCriticalStack) == 0:
                installCriticalStack = 'y'
                while True:
                    csKey = get_user_input("    \033[1mEnter Your Critical Stack API Key\033[0m: ")
                    if not re.match(r'[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}',
                                    csKey):
                        print("        Not a valid API key.")
                    else:
                        break
        bro.install(chosenInterface, 'localhost')
        if criticalStackInstalled == False and installCriticalStack.lower() == 'y':
            criticalStack.install(csKey)
        else:
            print "Skipping Critical Stack Install"
        # Check if We Should Install Fail2Ban
        # while True:
        #	installFail2Ban = get_user_input("\033[1mInstall Fail2Ban (Y/n)\033[0m: ")
        #	if installFail2Ban.lower() not in ('y', 'n', ''):
        #		print "Must choose Y or N."
        #	else:
        #		break
        # if installFail2Ban == 'y' or installFail2Ban == '':
        #	fail2ban.install()

# Path: install/packages.py
# def install(installType):
# 
# Path: install/bro.py
# def install(chosenInterface,webServer):
# 
# Path: install/criticalStack.py
# def get_user_input(input_string):
# def install(csKey):
# 
# Path: install/logstash.py
# def get_user_input(input_string):
# def install(esServer,esUser,esPass):
# 
# Path: install/kibana.py
# def install(chosenInterfaceIP):
# def importDashboard(jsonFileName):
# def importIndexMapping(jsonFileName):
# 
# Path: install/sweetSecurity.py
# def installClient(chosenInterface):
# def installServer():
# def addWebCreds(address,user,pwd,location):
# 
# Path: install/apache.py
# def get_user_input(input_string):
# def install(installType,chosenInterface,chosenIP):
# 
# Path: install/fail2ban.py
# def install():


# Path: setup.py
import argparse, fcntl, getpass, json, os, re, shutil, socket, sqlite3, struct, sys
from time import sleep
from install import packages
from install import bro
from install import criticalStack
from install import elasticSearch
from install import logstash
from install import kibana
from install import sweetSecurity
from install import apache
from install import fail2ban

            while True:
                installCriticalStack = get_user_input(
                    "\033[1mInstall Critical Stack Threat Intel For Bro IDS (Y/n)\033[0m: ")
                if installCriticalStack.lower() not in ('y', 'n', ''):
                    print "Must choose Y or N."
                else:
                    break
            if installCriticalStack.lower() == 'y' or len(installCriticalStack) == 0:
                installCriticalStack = 'y'
                while True:
                    csKey = get_user_input("    \033[1mEnter Your Critical Stack API Key\033[0m: ")
                    if not re.match(r'[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}',
                                    csKey):
                        print("        Not a valid API key.")
                    else:
                        break
        bro.install(chosenInterface, 'localhost')
        if criticalStackInstalled == False and installCriticalStack.lower() == 'y':
            criticalStack.install(csKey)
        else:
            print "Skipping Critical Stack Install"
        # Check if We Should Install Fail2Ban
        # while True:
        #	installFail2Ban = get_user_input("\033[1mInstall Fail2Ban (Y/n)\033[0m: ")
        #	if installFail2Ban.lower() not in ('y', 'n', ''):
        #		print "Must choose Y or N."
        #	else:
        #		break
        # if installFail2Ban == 'y' or installFail2Ban == '':
        #	fail2ban.install()

        apache.install(installType, chosenInterface, chosenInterfaceIP)