forked from jbossdemocentral/rhdm7-loan-demo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.ps1
242 lines (209 loc) · 11.4 KB
/
init.ps1
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
Param(
[switch]$h,
[switch]$o
)
. .\init-properties.ps1
# Additional properties
$PROJECT_GIT_BRANCH="master"
$PROJECT_GIT_DIR="$PROJECT_HOME\support\demo_project_git"
$OFFLINE_MODE="false"
# wipe screen
Clear-Host
If ($h) {
Write-Host "Usage: init.ps1 [args...]"
Write-Host "where args include:"
Write-Host " -o run this script in offline mode. The project's Git repo will not be downloaded. Instead a cached version will be used if available."
Write-Host " -h prints this help."
exit
}
Write-Host "#################################################################"
Write-Host "## ##"
Write-Host "## Setting up the ${DEMO} ##"
Write-Host "## ##"
Write-Host "## ##"
Write-Host "## #### # # #### # # ##### # # ##"
Write-Host "## # # # # # # # # # # # # # ##"
Write-Host "## #### ##### # # # # # ### # ##"
Write-Host "## # # # # # # # # # # # ##"
Write-Host "## # # # # #### # # # # # # ##"
Write-Host "## ##"
Write-Host "## brought to you by, ##"
Write-Host "## %AUTHORS% ##"
Write-Host "## ##"
Write-Host "## ##"
Write-Host "## %PROJECT% ##"
Write-Host "## ##"
Write-Host "#################################################################`n"
#Test whether Maven is available.
if ((Get-Command "npm" -ErrorAction SilentlyContinue) -eq $null)
{
Write-Host "npm is required but not installed yet... aborting.`n"
exit
}
If (Test-Path "$SRC_DIR\$EAP") {
Write-Host "Product sources are present...`n"
} Else {
Write-Host "Need to download $EAP package from the Customer Support Portal"
Write-Host "and place it in the $SRC_DIR directory to proceed...`n"
exit
}
#If (Test-Path "$SRC_DIR\$EAP_PATCH") {
# Write-Host "Product patches are present...`n"
#} Else {
# Write-Host "Need to download $EAP_PATCH package from the Customer Support Portal"
# Write-Host "and place it in the $SRC_DIR directory to proceed...`n"
# exit
#}
If (Test-Path "$SRC_DIR\$DM_DECISION_CENTRAL") {
Write-Host "Product sources are present...`n"
} Else {
Write-Host "Need to download $DM_DECISION_CENTRAL package from the Customer Support Portal"
Write-Host "and place it in the $SRC_DIR directory to proceed...`n"
exit
}
If (Test-Path "$SRC_DIR\$DM_KIE_SERVER") {
Write-Host "Product sources are present...`n"
} Else {
Write-Host "Need to download $DM_KIE_SERVER package from the Customer Support Portal"
Write-Host "and place it in the $SRC_DIR directory to proceed...`n"
exit
}
#Test whether Java is available.
#if ((Get-Command "java.exe" -ErrorAction SilentlyContinue) -eq $null)
#{
# Write-Host "The 'java' command is required but not available. Please install Java and add it to your PATH.`n"
# exit
#}
#if ((Get-Command "javac.exe" -ErrorAction SilentlyContinue) -eq $null)
#{
# Write-Host "The 'javac' command is required but not available. Please install Java and add it to your PATH.`n"
# exit
#}
# Test whether 7Zip is available.
# We use 7Zip because it seems to be one of the few ways to extract the Decision Manager zip file without hitting the 260 character limit problem of the Windows API.
# This is definitely not ideal, but I can't unzip without problems when using the default Powershell unzip utilities.
# 7-Zip can be downloaded here: http://www.7-zip.org/download.html
if ((Get-Command "7z.exe" -ErrorAction SilentlyContinue) -eq $null)
{
Write-Host "The '7z.exe' command is required but not available. Please install 7-Zip.`n"
Write-Host "7-Zip is used to overcome the Windows 260 character limit on paths while extracting the Red Hat Decision Manager ZIP file.`n"
Write-Host "7-Zip can be donwloaded here: http://www.7-zip.org/download.html`n"
Write-Host "Please make sure to add '7z.exe' to your 'PATH' after installation.`n"
exit
}
# Remove the old installation if it exists
If (Test-Path "$JBOSS_HOME") {
Write-Host "Removing existing installation.`n"
# The "\\?\" prefix is a trick to get around the 256 path-length limit in Windows.
# If we don't do this, the Remove-Item command fails when it tries to delete files with a name longer than 256 characters.
Remove-Item "\\?\$JBOSS_HOME" -Force -Recurse
}
#Run installers.
Write-Host "Deploying JBoss EAP now..."
# Using 7-Zip. This currently seems to be the only way to overcome the Windows 260 character path limit.
$argList = "x -o$TARGET -y $SRC_DIR\$EAP"
$unzipProcess = (Start-Process -FilePath 7z.exe -ArgumentList $argList -Wait -PassThru -NoNewWindow)
If ($unzipProcess.ExitCode -ne 0) {
Write-Error "Error occurred during JBoss EAP installation."
exit
}
<#
Write-Host "Applying JBoss EAP patch now...`n"
Write-Host "The patch process will run in a separate window. Please wait for the 'Press any key to continue ...' message...`n"
$argList = '--command="patch apply ' + "$SRC_DIR\$EAP_PATCH" + ' --override-all"'
$patchProcess = (Start-Process -FilePath "$JBOSS_HOME\bin\jboss-cli.bat" -ArgumentList $argList -Wait -PassThru)
Write-Host "Process finished with return code: " $patchProcess.ExitCode
Write-Host ""
If ($patchProcess.ExitCode -ne 0) {
Write-Error "Error occurred during JBoss EAP patch installation."
exit
}
Write-Host "JBoss EAP patch applied succesfully!`n"
#>
Write-Host "Deploying Decision Manager Decision Central now..."
# Using 7-Zip. This currently seems to be the only way to overcome the Windows 260 character path limit.
$argList = "x -o$TARGET -y $SRC_DIR\$DM_DECISION_CENTRAL"
$unzipProcess = (Start-Process -FilePath 7z.exe -ArgumentList $argList -Wait -PassThru -NoNewWindow)
If ($unzipProcess.ExitCode -ne 0) {
Write-Error "Error occurred during Decision Manager Decision Central installation."
exit
}
Write-Host "Deploying Decision Manager Decision Server now..."
# Using 7-Zip. This currently seems to be the only way to overcome the Windows 260 character path limit.
$argList = "x -o$JBOSS_HOME\standalone\deployments -y $SRC_DIR\$DM_KIE_SERVER"
$unzipProcess = (Start-Process -FilePath 7z.exe -ArgumentList $argList -Wait -PassThru -NoNewWindow)
If ($unzipProcess.ExitCode -ne 0) {
Write-Error "Error occurred during Decision Manager Decision Server installation."
exit
}
New-Item -ItemType file $JBOSS_HOME\standalone\deployments\kie-server.war.dodeploy
Write-Host ""
Write-Host "- enabling demo accounts setup ...`n"
$argList1 = "-a -r ApplicationRealm -u dmAdmin -p 'redhatdm1!' -ro 'analyst,admin,manager,user,kie-server,kiemgmt,rest-all' --silent"
$argList2 = "-a -r ApplicationRealm -u kieserver -p 'kieserver1!' -ro 'kie-server,rest-all' --silent"
try {
Invoke-Expression "$JBOSS_HOME\bin\add-user.ps1 $argList1"
Invoke-Expression "$JBOSS_HOME\bin\add-user.ps1 $argList2"
} catch {
Write-Error "Error occurred during user account setup."
exit
}
################################# Begin setup demo projects ##########################################
Write-Host "- Setting up demo projects...`n"
If (Test-Path "$SERVER_BIN\.niogit\") {
Remove-Item "$SERVER_BIN\.niogit\" -Force -Recurse
}
New-Item -ItemType directory -Path "$SERVER_BIN\.niogit\" | Out-Null
Copy-Item "$SUPPORT_DIR\rhdm7-demo-niogit\*" "$SERVER_BIN\.niogit\" -force -recurse
If (! $o) {
# Not in offline mode, so downloading the latest repo. We first download the repo in a temp dir and we only delete the old, cached repo, when the download is succesful.
Write-Host " - cloning the project's Git repo from: $PROJECT_GIT_REPO`n"
If (Test-Path "$PROJECT_HOME\target\temp") {
Remove-Item "$PROJECT_HOME\target\temp" -Force -Recurse
}
$argList = "clone --bare $PROJECT_GIT_REPO $PROJECT_HOME\target\temp\$PROJECT_GIT_REPO_NAME"
$gitProcess = (Start-Process -FilePath "git" -ArgumentList $argList -Wait -PassThru -NoNewWindow)
If ($gitProcess.ExitCode -ne 0) {
Write-Host "Error cloning the project's Git repo. If there is no Internet connection available, please run this script in 'offline-mode' ('-o') to use a previously downloaded and cached version of the project's Git repo... Aborting"
exit 1
}
Write-Host ""
Write-Host " - replacing cached project git repo: $PROJECT_GIT_DIR/$PROJECT_GIT_REPO_NAME`n"
If (Test-Path "$PROJECT_GIT_DIR") {
Remove-Item "$PROJECT_GIT_DIR" -Force -Recurse
}
New-Item -ItemType directory -Path "$PROJECT_GIT_DIR"
Copy-Item "$PROJECT_HOME\target\temp\$PROJECT_GIT_REPO_NAME" "$PROJECT_GIT_DIR\$PROJECT_GIT_REPO_NAME" -Force -Recurse
Remove-Item "$PROJECT_HOME\target\temp" -Force -Recurse
} else {
Write-Host " - running in offline-mode, using cached project's Git repo.`n"
If (-Not (Test-Path "$PROJECT_GIT_DIR\$PROJECT_GIT_REPO_NAME")) {
Write-Host "No project Git repo found. Please run the script without the 'offline' ('-o') option to automatically download the required Git repository!`n"
exit 1
}
}
# Copy the repo to the JBoss BPMSuite installation directory.
Remove-Item "$SERVER_BIN\.niogit\$NIOGIT_PROJECT_GIT_REPO" -Force -Recurse
Copy-Item "$PROJECT_GIT_DIR\$PROJECT_GIT_REPO_NAME" "$SERVER_BIN\.niogit\$NIOGIT_PROJECT_GIT_REPO" -force -recurse
################################# End setup demo projects ##########################################
Write-Host "- setting up standalone.xml configuration adjustments...`n"
Copy-Item "$SUPPORT_DIR\standalone-full.xml" "$SERVER_CONF\standalone.xml" -force
Write-Host "- setup email task notification user...`n"
Copy-Item "$SUPPORT_DIR\userinfo.properties" "$SERVER_DIR\decision-central.war\WEB-INF\classes\" -force
Write-Host "======================================================================================="
Write-Host "= ="
Write-Host "= You can now start the $PRODUCT with: ="
Write-Host "= ="
Write-Host "= $SERVER_BIN\standalone.ps1 ="
Write-Host "= or ="
Write-Host "= $SERVER_BIN\standalone.bat ="
Write-Host "= ="
Write-Host "= Login into Decision Central at: ="
Write-Host "= ="
Write-Host "= http://localhost:8080/decision-central (u:dmAdmin / p:redhatdm1!) ="
Write-Host "= ="
Write-Host "= See README.md for general details to run the various demo cases. ="
Write-Host "= ="
Write-Host "= $PRODUCT $VERSION $DEMO Setup Complete. ="
Write-Host "= ="
Write-Host "======================================================================================="