-
Notifications
You must be signed in to change notification settings - Fork 0
/
VistA-docker.ps1
261 lines (261 loc) · 11.8 KB
/
VistA-docker.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
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
#
# Check to see if Docker is installed. If not, download and install Docker Desktop for Windows. Then pull and run VistA EHR image in container
#
param ([String] $action="install", [switch]$help = $false )
If ($help) {
Write-Host ""
Write-Host "This script runs a World VistA EHR server in a Docker Container after first installing the Docker Desktop dependancy if required"
Write-Host "https://github.com/RamSailopal/Powershell-VistA-CPRS"
Write-Host ""
Write-Host "Additional flags:"
Write-Host ""
Write-Host -ForegroundColor "yellow" "-help"
Write-Host -ForegroundColor "green" "Print help"
Write-Host ""
Write-Host -ForegroundColor "yellow" "-action install"
Write-Host -ForegroundColor "green" "Install the World VistA EHR container plus dependancies if necessary (default)"
Write-Host ""
Write-Host -ForegroundColor "yellow" "-action noint-install"
Write-Host -ForegroundColor "green" "Install the World VistA EHR container plus dependancies if necessary in none interactive mode"
Write-Host ""
Write-Host -ForegroundColor "yellow" "-action status"
Write-Host -ForegroundColor "green" "Print the status of the World VistA EHR container"
Write-Host ""
Write-Host -ForegroundColor "yellow" "-action start"
Write-Host -ForegroundColor "green" "Start the World VistA EHR container"
Write-Host ""
Write-Host -ForegroundColor "yellow" "-action stop"
Write-Host -ForegroundColor "green" "Stop the World VistA EHR container"
Write-Host ""
Write-Host -ForegroundColor "yellow" "-action restart"
Write-Host -ForegroundColor "green" "Restart the World VistA EHR container"
Write-Host ""
exit
}
if ($action.ToUpper() -eq "RESTART") {
try {
$contid=""
$fnd=0
Get-Process | ForEach-Object {
if ( $_.Name -eq "Docker Desktop" ) {
$fnd=1
}
}
if ($fnd -eq 0 ) {
Write-Host -ForegroundColor Red "Docker Desktop is not running. Starting now ..."
& '~\Desktop\Docker Desktop.lnk'
Start-Sleep 60
}
if (docker ps -a --format "{{.Names}}" | Select-String "wv") {
docker ps -a | Select-String "wv" | ForEach-Object {
$bits=$_.toString().split(" ")
if ($bits[0] -notmatch "CONTAINER") {
$contid = $bits[0]
}
docker rm -f $contid | Out-Null
docker run -d -p 2222:22 -p 8001:8001 -p 8080:8080 -p 9430:9430 -p 9080:9080 --name=wv worldvista/worldvista-ehr | Out-Null
Write-Host -ForegroundColor green "VistA EHR is now running in Docker. Use the install.ps1 script to install the client CPRS software if needed"
exit
}
}
if ($contid -eq "") {
$ans3 = Read-Host -Prompt "There was an error recreating the VistA EHR container. Do you wish to create one now? (Y/N)"
if ($ans3.ToUpper() -eq "Y") {
docker run -d -p 2222:22 -p 8001:8001 -p 8080:8080 -p 9430:9430 -p 9080:9080 --name=wv worldvista/worldvista-ehr | Out-Null
Write-Host -ForegroundColor green "VistA EHR is now running in Docker. Use the install.ps1 script to install the client CPRS software if needed"
exit
}
}
}
catch {
Write-Host -ForegroundColor Red "There was an error recreating the VistA EHR container"
}
exit
}
elseif ($action.ToUpper() -eq "STOP") {
try {
$contid=""
if (docker ps -a --format "{{.Names}}" | Select-String "wv") {
docker ps -a | Select-String "wv" | ForEach-Object {
$bits=$_.toString().split(" ")
if ($bits[0] -notmatch "CONTAINER") {
$contid = $bits[0]
}
docker rm -f $contid | Out-Null
Write-Host -ForegroundColor green "VistA EHR is stopped and container removed"
exit
}
}
if ($contid -eq "") {
Write-Host -ForegroundColor Green "The VistA EHR container is not running"
}
}
catch {
Write-Host -ForegroundColor Red "There was an error recreating the VistA EHR container"
}
exit
}
elseif ($action.ToUpper() -eq "START") {
try {
$contid=""
$fnd=0
Get-Process | ForEach-Object {
if ( $_.Name -eq "Docker Desktop" ) {
$fnd=1
}
}
if ($fnd -eq 0 ) {
Write-Host -ForegroundColor Red "Docker Desktop is not running. Starting now ..."
& '~\Desktop\Docker Desktop.lnk'
Start-Sleep 60
}
if (docker ps -a --format "{{.Names}}" | Select-String "wv" ) {
docker ps -a | Select-String "wv" | ForEach-Object {
$bits=$_.toString().split(" ")
if ($bits[0] -notmatch "CONTAINER") {
$contid = $bits[0]
}
}
}
if ($fnd -eq 0 ) {
docker rm -f $contid | Out-Null
docker run -d -p 2222:22 -p 8001:8001 -p 8080:8080 -p 9430:9430 -p 9080:9080 --name=wv worldvista/worldvista-ehr | Out-Null
Write-Host -ForegroundColor green "VistA EHR is now running in Docker. Use the install.ps1 script to install the client CPRS software if needed"
exit
}
elseif ($contid -eq "") {
docker run -d -p 2222:22 -p 8001:8001 -p 8080:8080 -p 9430:9430 -p 9080:9080 --name=wv worldvista/worldvista-ehr | Out-Null
Write-Host -ForegroundColor green "VistA EHR is now running in Docker. Use the install.ps1 script to install the client CPRS software if needed"
exit
}
else {
Write-Host -ForegroundColor Green "The VistA EHR container is already running"
}
}
catch {
Write-Host -ForegroundColor Red "There was an error recreating the VistA EHR container"
}
exit
}
elseif ($action.ToUpper() -eq "STATUS") {
try {
$contid=""
if (docker ps -a --format "{{.Names}}" | Select-String "wv") {
docker ps -a | Select-String "wv" | ForEach-Object {
$bits=$_.toString().split(" ")
if ($bits[0] -notmatch "CONTAINER") {
$contid = $bits[0]
}
}
}
if ($contid -eq "") {
Write-Host -ForegroundColor Green "The VistA EHR container is not running"
exit
}
else {
$contdet = docker ps -a --format "{{.ID}}:{{.RunningFor}}" | ForEach-Object {
$contdetsp = $_.split(":")
$runfor = $contdetsp[1]
}
Write-Host -ForegroundColor Green "The VistA EHR container has been running since $runfor"
exit
}
}
catch {
Write-Host -ForegroundColor Red "There was an error recreating the VistA EHR container"
}
exit
}
elseif ($action.ToUpper() -eq "NOINT-INSTALL") {
try {
docker version | Out-Null
Write-Host -ForegroundColor green "Docker Desktop already installed"
if (docker ps -a --format "{{.Names}}" | Select-String "wv") {
docker ps -a | Select-String "wv" | ForEach-Object {
$bits=$_.toString().split(" ")
if ($bits[0] -notmatch "CONTAINER") {
$contid = $bits[0]
}
}
docker rm -f $contid | Out-Null
docker run -d -p 2222:22 -p 8001:8001 -p 8080:8080 -p 9430:9430 -p 9080:9080 --name=wv worldvista/worldvista-ehr | Out-Null
Write-Host -ForegroundColor green "VistA EHR is now running in Docker. Use the install.ps1 script to install the client CPRS software if needed"
exit
}
docker run -d -p 2222:22 -p 8001:8001 -p 8080:8080 -p 9430:9430 -p 9080:9080 --name=wv worldvista/worldvista-ehr | Out-Null
Write-Host -ForegroundColor green "VistA EHR is now running in Docker. Use the install.ps1 script to install the client CPRS software if needed"
exit
}
catch {
Write-Host -ForegroundColor green "Downloading ..."
try {
Invoke-WebRequest 'https://desktop.docker.com/win/main/amd64/Docker%20Desktop%20Installer.exe' -OutFile ~/Downloads/DockerInstall.exe
}
catch {
Write-Host -ForegroundColor red "Issue downloading Docker Desktop for Windows"
}
try {
& ~\Downloads\DockerInstall.exe
Write-Host -ForegroundColor green "Please follow screen option to continue"
Write-Host -ForegroundColor green "Running Docker Desktop"
& '~\Docker Desktop.lnk'
Start-Sleep 60
Write-Host -ForegroundColor green "Running VistA EHR in Docker"
docker run -d -p 2222:22 -p 8001:8001 -p 8080:8080 -p 9430:9430 -p 9080:9080 --name=wv worldvista/worldvista-ehr | Out-Null
Write-Host -ForegroundColor green "VistA EHR is now running in Docker. Use the install.ps1 script to install the client CPRS software if needed"
}
catch {
Write-Host -ForegroundColor red "Issue running Docker Desktop Install"
}
}
}
try {
docker version | Out-Null
Write-Host -ForegroundColor green "Docker Desktop already installed"
$ans=Read-Host -Prompt "Would you like to run VistA EHR in Docker? (Y/N)"
if ($ans.ToUpper() -eq "Y") {
if (docker ps -a --format "{{.Names}}" | Select-String "wv") {
$ans2=Read-Host -Prompt "Would you like to remove the existing and recreate a container running VistA EHR? (Y/N)"
if ( $ans2.ToUpper() -eq "Y") {
docker ps -a | Select-String "wv" | ForEach-Object {
$bits=$_.toString().split(" ")
if ($bits[0] -notmatch "CONTAINER") {
$contid = $bits[0]
}
}
docker rm -f $contid | Out-Null
docker run -d -p 2222:22 -p 8001:8001 -p 8080:8080 -p 9430:9430 -p 9080:9080 --name=wv worldvista/worldvista-ehr | Out-Null
Write-Host -ForegroundColor green "VistA EHR is now running in Docker. Use the install.ps1 script to install the client CPRS software if needed"
exit
}
}
docker run -d -p 2222:22 -p 8001:8001 -p 8080:8080 -p 9430:9430 -p 9080:9080 --name=wv worldvista/worldvista-ehr | Out-Null
Write-Host -ForegroundColor green "VistA EHR is now running in Docker. Use the install.ps1 script to install the client CPRS software if needed"
exit
}
}
catch {
$resp = Read-Host "Docker Desktop is not installed. Initiate download and install now? (Y/N)"
If ( $resp.ToUpper() -eq "Y") {
Write-Host -ForegroundColor green "Downloading ..."
try {
Invoke-WebRequest 'https://desktop.docker.com/win/main/amd64/Docker%20Desktop%20Installer.exe' -OutFile ~/Downloads/DockerInstall.exe
}
catch {
Write-Host -ForegroundColor red "Issue downloading Docker Desktop for Windows"
}
try {
& ~\Downloads\DockerInstall.exe
Write-Host -ForegroundColor green "Please follow screen option to continue"
Write-Host -ForegroundColor green "Running Docker Desktop"
& '~\Docker Desktop.lnk'
Start-Sleep 60
Write-Host -ForegroundColor green "Running VistA EHR in Docker"
docker run -d -p 2222:22 -p 8001:8001 -p 8080:8080 -p 9430:9430 -p 9080:9080 --name=wv worldvista/worldvista-ehr | Out-Null
Write-Host -ForegroundColor green "VistA EHR is now running in Docker. Use the install.ps1 script to install the client CPRS software if needed"
}
catch {
Write-Host -ForegroundColor red "Issue running Docker Desktop Install"
}
}
}