-
Notifications
You must be signed in to change notification settings - Fork 7
/
_global_config.py
89 lines (76 loc) · 3.77 KB
/
_global_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
88
89
import ast
import configparser
import os
from distutils.util import strtobool
config = configparser.ConfigParser()
config.read('migration-config.cfg')
# General
configSection = str(config['general']['configSection'])
loggingFolder = '.'
logfolderfolders = str(config['general']['neededScriptFolders'])
logfolderfolders = ast.literal_eval(logfolderfolders)
for key, value in logfolderfolders.items():
if key == 'logfolder':
loggingFolder = value
logFile = str(loggingFolder+'/'+config['general']['logFile'])
# KeyHelp
apiServerFqdn = str(config['keyhelp']['apiServerFqdn'])
apiKey = str(config['keyhelp']['apiKey'])
apiTimeout = int(config['keyhelp']['apiTimeout'])
keyhelpUpdatePasswordWithApi = bool(strtobool(str(config['keyhelp']['keyhelpUpdatePasswordWithApi'])))
keyhelpMinPasswordLenght = int(config['keyhelp']['keyhelpMinPasswordLenght'])
apiServerFqdnVerify = bool(strtobool(str(config['keyhelp']['apiServerFqdnVerify'])))
keyhelpConfigfile = str(config['keyhelp']['keyhelpConfigfile'])
keyhelpSleeptime = str(config['keyhelp']['keyhelpSleeptime'])
keyhelpDefaultHostingplan = str(config['keyhelp']['keyhelpDefaultHostingplan'])
keyhelpCreateRandomPassword = str(config['keyhelp']['keyhelpCreateRandomPassword'])
keyhelpSendloginCredentials = str(config['keyhelp']['keyhelpSendloginCredentials'])
keyhelpCreateSystemDomain = str(config['keyhelp']['keyhelpCreateSystemDomain'])
keyhelpDisableDnsForDomain = str(config['keyhelp']['keyhelpDisableDnsForDomain'])
if keyhelpDisableDnsForDomain == 'ask':
keyhelpDisableDnsForDomain = str(keyhelpDisableDnsForDomain)
elif keyhelpDisableDnsForDomain == 'false' or keyhelpDisableDnsForDomain == 'true':
keyhelpDisableDnsForDomain = bool(strtobool(str(config['keyhelp']['keyhelpDisableDnsForDomain'])))
else:
keyhelpDisableDnsForDomain = False
# i-MSCP
imscpServerFqdn = str(config['imscp-'+configSection]['imscpServerFqdn'])
imscpSshUsername = str(config['imscp-'+configSection]['imscpSshUsername'])
imscpSshPort = int(config['imscp-'+configSection]['imscpSshPort'])
imscpSshTimeout = int(config['imscp-'+configSection]['imscpSshTimeout'])
imscpRootPassword = str(config['imscp-'+configSection]['imscpRootPassword'])
imscpRoundcubeContactImport = bool(strtobool(str(config['imscp-'+configSection]['imscpRoundcubeContactImport'])))
imscpMysqlVersion5_7 = bool(strtobool(str(config['imscp-'+configSection]['imscpMysqlVersion5_7'])))
imscpSshPublicKey = str(config['imscp-'+configSection]['imscpSshPublicKey'])
imscpDbDumpFolder = str(config['imscp-'+configSection]['imscpDbDumpFolder'])
def createNeededScriptFolders():
for folderKey, folderName in logfolderfolders.items():
if not os.path.exists(folderName):
os.makedirs(folderName)
def write_log(*logData):
logFileOutputFile = open(logFile, "a+")
line = ' '.join([str(a) for a in logData])
logFileOutputFile.write(line+'\n')
logFileOutputFile.close()
def write_migration_log(migrationLogfile,*logData):
logFileOutputFile = open(migrationLogfile, "a+")
line = ' '.join([str(a) for a in logData])
logFileOutputFile.write(line+'\n')
logFileOutputFile.close()
def ask_Yes_No(answer):
yes = set(['yes', 'y', 'ye', ''])
no = set(['no', 'n'])
while True:
choice = input(answer).lower()
if choice in yes:
return True
elif choice in no:
return False
else:
print('Please respond with "yes" or "no"')
def init():
global loggingFolder, logFile, keyhelpSleeptime, keyhelpDefaultHostingplan, keyhelpSendloginCredentials, \
keyhelpCreateSystemDomain, keyhelpDisableDnsForDomain, apiServerFqdn, apiKey, apiTimeout, \
keyhelpMinPasswordLenght, apiServerFqdnVerify, keyhelpConfigfile, imscpServerFqdn, imscpSshUsername, \
imscpSshPort, imscpSshTimeout, imscpRootPassword, imscpSshPublicKey, imscpDbDumpFolder, \
imscpRoundcubeContactImport, imscpMysqlVersion5_7, keyhelpCreateRandomPassword, keyhelpUpdatePasswordWithApi