-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild__00__settings.ps1
More file actions
147 lines (114 loc) · 3.87 KB
/
build__00__settings.ps1
File metadata and controls
147 lines (114 loc) · 3.87 KB
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
################################################
#
# SCRIPT ROOT
#
################################################
# Load scriptpath
if ($MyInvocation.MyCommand.CommandType -eq "ExternalScript") {
$scriptPath = Split-Path -Parent -Path $MyInvocation.MyCommand.Definition
} else {
$scriptPath = Split-Path -Parent -Path ([Environment]::GetCommandLineArgs()[0])
}
Set-Location -Path $scriptPath
################################################
#
# SETTINGS
#
################################################
# General settings
$functionsSubfolder = "functions"
$settingsFilename = "settings.json"
################################################
#
# FUNCTIONS
#
################################################
Get-ChildItem -Path ".\$( $functionsSubfolder )" | ForEach {
. $_.FullName
}
################################################
#
# SETTINGS
#
################################################
#-----------------------------------------------
# ENCRYPTION KEYS
#-----------------------------------------------
# create encryption keys, dependent on the system
$cspParams = New-Object "System.Security.Cryptography.CspParameters"
$cspParams.KeyContainerName = "XML_ENC_RSA_KEY"
$rsaKey = [System.Security.Cryptography.RSACryptoServiceProvider]::new($cspParams)
# these settings will be used to save credentials e.g. for a database
$encryptionSettings = @{
keyContainerName = $cspParams.KeyContainerName
keyName = "rsaKey"
elementsToEncrypt = @("Objects")
keySize = 256
}
#-----------------------------------------------
# GENERIC SETTINGS
#-----------------------------------------------
# dependent on PROD and TEST
$publishServer = "appservice"
$sourcedatabase = "localhost"
$environment = "PROD"
$buildDir = "D:\Apteco\Build\"
#-----------------------------------------------
# SYSTEM SPECIFIC SETTINGS
#-----------------------------------------------
$systemsSettings = [array]@()
$systemsSettings += @{
Name = "Holidays"
Description = "HolidaysLongerName"
designFile = "$( $buildDir )Holidays\designs\holidays.xml"
SystemVariables = @{
"LOADMONTHS" = 36
"INCLUDEDUMMY" = "'Real'"
}
}
$systemsSettings += @{
Name = "Reisen"
Description = "ReisenLongerName"
designFile = "$( $buildDir )Reisen\designs\reisen.xml"
SystemVariables = @{
"LOADMONTHS" = 12
"INCLUDEDUMMY" = "'Real','Dummy','Transaktion'"
}
}
#-----------------------------------------------
# ENVIRONMENT VARIABLES USED BY DESIGNER
#-----------------------------------------------
# all environment variables
$environmentVariables = @{
"BUILDDIR" = $buildDir
"SOURCEDB" = "Data Source=$( $sourcedatabase );Initial Catalog=customers;Trusted_Connection=True;"
"PS_CONNECTION" = "Data Source=$( $sourcedatabase );Initial Catalog=PS_Holidays;Trusted_Connection=True;"
"RS_CONNECTION" = "Data Source=$( $sourcedatabase );Initial Catalog=RS_Holidays;Trusted_Connection=True;"
"WAITFILE" = "$( $buildDir )#SYSNAME#\temp\build.now"
"DEPLOY"="\\$( $publishServer )\Publish\#SYSNAME#\updates"
"APTCRED"="Apteco WebService #SYSNAME# $( $environment )" #
"ENVIRONMENT"=$environment
}
#-----------------------------------------------
# ALL SETTINGS
#-----------------------------------------------
$settings = @{
systems = $systemsSettings
sleepTime = 60
maxSecondsWaiting = 10800 # seconds
maxAgeForData = 16 # hours
encryption = $encryptionSettings
environment = $environmentVariables
variablesXML = "$( $scriptPath )\variables.xml"
}
################################################
#
# PACK TOGETHER SETTINGS AND SAVE AS JSON
#
################################################
# create json object
$json = $settings | ConvertTo-Json -Depth 8 # -compress
# print settings to console
$json
# save settings to file
$json | Set-Content -path "$( $scriptPath )\$( $settingsFilename )" -Encoding UTF8