1
1
@ ECHO OFF
2
- SET dlurl = https://fhir.github.io/latest-ig-publisher/org.hl7.fhir.publisher.jar
3
- SET publisher_jar = org.hl7.fhir.publisher.jar
2
+
3
+ SETLOCAL
4
+
5
+ SET dlurl = https://github.com/HL7/fhir-ig-publisher/releases/latest/download/publisher.jar
6
+ SET publisher_jar = publisher.jar
4
7
SET input_cache_path = %CD% \input-cache\
8
+ SET skipPrompts = false
9
+
10
+ set update_bat_url = https://raw.githubusercontent.com/FHIR/sample-ig/master/_updatePublisher.bat
11
+ set gen_bat_url = https://raw.githubusercontent.com/FHIR/sample-ig/master/_genonce.bat
12
+ set gencont_bat_url = https://raw.githubusercontent.com/FHIR/sample-ig/master/_gencontinuous.bat
13
+ set gencont_sh_url = https://raw.githubusercontent.com/FHIR/sample-ig/master/_gencontinuous.sh
14
+ set gen_sh_url = https://raw.githubusercontent.com/FHIR/sample-ig/master/_genonce.sh
15
+ set update_sh_url = https://raw.githubusercontent.com/FHIR/sample-ig/master/_updatePublisher.sh
16
+
17
+ IF " %~1 " == " /f" SET skipPrompts = y
18
+
19
+
20
+ ECHO .
21
+ ECHO Checking internet connection...
22
+ PING tx.fhir.org -4 -n 1 -w 1000 | FINDSTR TTL && GOTO isonline
23
+ ECHO We're offline, nothing to do...
24
+ GOTO end
25
+
26
+ :isonline
27
+ ECHO We're online
28
+
29
+
30
+ :processflags
31
+ SET ARG = %1
32
+ IF DEFINED ARG (
33
+ IF " %ARG% " == " -f" SET FORCE = true
34
+ IF " %ARG% " == " --force" SET FORCE = true
35
+ SHIFT
36
+ GOTO processflags
37
+ )
5
38
6
39
FOR %%x IN (" %CD% " ) DO SET upper_path = %%~dpx
7
40
41
+ ECHO .
8
42
IF NOT EXIST " %input_cache_path%%publisher_jar% " (
9
43
IF NOT EXIST " %upper_path%%publisher_jar% " (
10
44
SET jarlocation = " %input_cache_path%%publisher_jar% "
@@ -16,30 +50,44 @@ IF NOT EXIST "%input_cache_path%%publisher_jar%" (
16
50
ECHO IG Publisher FOUND in parent folder
17
51
SET jarlocation = " %upper_path%%publisher_jar% "
18
52
SET jarlocationname = Parent folder
19
- GOTO : upgrade
53
+ GOTO upgrade
20
54
)
21
55
) ELSE (
22
56
ECHO IG Publisher FOUND in input-cache
23
57
SET jarlocation = " %input_cache_path%%publisher_jar% "
24
58
SET jarlocationname = Input Cache
25
- GOTO : upgrade
59
+ GOTO upgrade
26
60
)
27
61
28
62
:create
29
- ECHO Will place publisher jar here: %input_cache_path%%publisher_jar%
30
- SET /p create = " Ok? (Y/N)"
63
+ IF DEFINED FORCE (
64
+ MKDIR " %input_cache_path% " 2 > NUL
65
+ GOTO download
66
+ )
67
+
68
+ IF " %skipPrompts% " == " y" (
69
+ SET create = Y
70
+ ) ELSE (
71
+ SET /p create = " Ok? (Y/N) "
72
+ )
31
73
IF /I " %create% " == " Y" (
74
+ ECHO Will place publisher jar here: %input_cache_path%%publisher_jar%
32
75
MKDIR " %input_cache_path% " 2 > NUL
33
- GOTO : download
76
+ GOTO download
34
77
)
35
- GOTO : done
78
+ GOTO done
36
79
37
80
:upgrade
38
- SET /p overwrite = " Overwrite %jarlocation% ? (Y/N)"
81
+ IF " %skipPrompts% " == " y" (
82
+ SET overwrite = Y
83
+ ) ELSE (
84
+ SET /p overwrite = " Overwrite %jarlocation% ? (Y/N) "
85
+ )
86
+
39
87
IF /I " %overwrite% " == " Y" (
40
- GOTO : download
88
+ GOTO download
41
89
)
42
- GOTO : done
90
+ GOTO done
43
91
44
92
:download
45
93
ECHO Downloading most recent publisher to %jarlocationname% - it's ~100 MB, so this may take a bit
@@ -60,14 +108,111 @@ CALL POWERSHELL -command if ('System.Net.WebClient' -as [type]) {(new-object Sys
60
108
GOTO done
61
109
62
110
:win7
63
- CALL bitsadmin /transfer GetPublisher /download /priority normal " %dlurl% " " %jarlocation% "
111
+ rem this may be triggering the antivirus - bitsadmin.exe is a known threat
112
+ rem CALL bitsadmin /transfer GetPublisher /download /priority normal "%dlurl%" "%jarlocation%"
113
+
114
+ rem this didn't work in win 10
115
+ rem CALL Start-BitsTransfer /priority normal "%dlurl%" "%jarlocation%"
116
+
117
+ rem this should work - untested
118
+ call (New-Object Net.WebClient).DownloadFile('%dlurl% ', '%jarlocation% ')
64
119
GOTO done
65
120
66
121
:win8.1
67
122
:win8
68
123
:vista
69
- ECHO This script does not yet support Windows %winver% . Please ask for help on http://chat.fhir.org
70
124
GOTO done
71
125
126
+
127
+
72
128
:done
73
- PAUSE
129
+
130
+
131
+
132
+
133
+ ECHO .
134
+ ECHO Updating scripts
135
+ IF " %skipPrompts% " == " y" (
136
+ SET updateScripts = Y
137
+ ) ELSE (
138
+ SET /p updateScripts = " Update scripts? (Y/N) "
139
+ )
140
+ IF /I " %updateScripts% " == " Y" (
141
+ GOTO scripts
142
+ )
143
+ GOTO end
144
+
145
+
146
+ :scripts
147
+
148
+ REM Download all batch files (and this one with a new name)
149
+
150
+ SETLOCAL DisableDelayedExpansion
151
+
152
+
153
+
154
+ :dl_script_1
155
+ ECHO Updating _updatePublisher.sh
156
+ call POWERSHELL -command if ('System.Net.WebClient' -as [type]) {(new-object System.Net.WebClient).DownloadFile(\" %update_sh_url% \" ,\" _updatePublisher.new.sh\" ) } else { Invoke-WebRequest -Uri " %update_sh_url% " -Outfile " _updatePublisher.new.sh" }
157
+ if %ERRORLEVEL% == 0 goto upd_script_1
158
+ echo " Errors encountered during download: %errorlevel% "
159
+ goto dl_script_2
160
+ :upd_script_1
161
+ start copy /y " _updatePublisher.new.sh" " _updatePublisher.sh" ^ &^ & del " _updatePublisher.new.sh" ^ &^ & exit
162
+
163
+
164
+ :dl_script_2
165
+ ECHO Updating _genonce.bat
166
+ call POWERSHELL -command if ('System.Net.WebClient' -as [type]) {(new-object System.Net.WebClient).DownloadFile(\" %gen_bat_url% \" ,\" _genonce.new.bat\" ) } else { Invoke-WebRequest -Uri " %gen_bat_url% " -Outfile " _genonce.bat" }
167
+ if %ERRORLEVEL% == 0 goto upd_script_2
168
+ echo " Errors encountered during download: %errorlevel% "
169
+ goto dl_script_3
170
+ :upd_script_2
171
+ start copy /y " _genonce.new.bat" " _genonce.bat" ^ &^ & del " _genonce.new.bat" ^ &^ & exit
172
+
173
+ :dl_script_3
174
+ ECHO Updating _gencontinuous.bat
175
+ call POWERSHELL -command if ('System.Net.WebClient' -as [type]) {(new-object System.Net.WebClient).DownloadFile(\" %gencont_bat_url% \" ,\" _gencontinuous.new.bat\" ) } else { Invoke-WebRequest -Uri " %gencont_bat_url% " -Outfile " _gencontinuous.bat" }
176
+ if %ERRORLEVEL% == 0 goto upd_script_3
177
+ echo " Errors encountered during download: %errorlevel% "
178
+ goto dl_script_4
179
+ :upd_script_3
180
+ start copy /y " _gencontinuous.new.bat" " _gencontinuous.bat" ^ &^ & del " _gencontinuous.new.bat" ^ &^ & exit
181
+
182
+
183
+ :dl_script_4
184
+ ECHO Updating _genonce.sh
185
+ call POWERSHELL -command if ('System.Net.WebClient' -as [type]) {(new-object System.Net.WebClient).DownloadFile(\" %gen_sh_url% \" ,\" _genonce.new.sh\" ) } else { Invoke-WebRequest -Uri " %gen_sh_url% " -Outfile " _genonce.sh" }
186
+ if %ERRORLEVEL% == 0 goto upd_script_4
187
+ echo " Errors encountered during download: %errorlevel% "
188
+ goto dl_script_5
189
+ :upd_script_4
190
+ start copy /y " _genonce.new.sh" " _genonce.sh" ^ &^ & del " _genonce.new.sh" ^ &^ & exit
191
+
192
+ :dl_script_5
193
+ ECHO Updating _gencontinuous.sh
194
+ call POWERSHELL -command if ('System.Net.WebClient' -as [type]) {(new-object System.Net.WebClient).DownloadFile(\" %gencont_sh_url% \" ,\" _gencontinuous.new.sh\" ) } else { Invoke-WebRequest -Uri " %gencont_sh_url% " -Outfile " _gencontinuous.sh" }
195
+ if %ERRORLEVEL% == 0 goto upd_script_5
196
+ echo " Errors encountered during download: %errorlevel% "
197
+ goto dl_script_6
198
+ :upd_script_5
199
+ start copy /y " _gencontinuous.new.sh" " _gencontinuous.sh" ^ &^ & del " _gencontinuous.new.sh" ^ &^ & exit
200
+
201
+
202
+
203
+ :dl_script_6
204
+ ECHO Updating _updatePublisher.bat
205
+ call POWERSHELL -command if ('System.Net.WebClient' -as [type]) {(new-object System.Net.WebClient).DownloadFile(\" %update_bat_url% \" ,\" _updatePublisher.new.bat\" ) } else { Invoke-WebRequest -Uri " %update_bat_url% " -Outfile " _updatePublisher.new.bat" }
206
+ if %ERRORLEVEL% == 0 goto upd_script_6
207
+ echo " Errors encountered during download: %errorlevel% "
208
+ goto end
209
+ :upd_script_6
210
+ start copy /y " _updatePublisher.new.bat" " _updatePublisher.bat" ^ &^ & del " _updatePublisher.new.bat" ^ &^ & exit
211
+
212
+
213
+ :end
214
+
215
+
216
+ IF " %skipPrompts% " == " true" (
217
+ PAUSE
218
+ }
0 commit comments