22
33SETLOCAL
44
5- SET dlurl = https://storage.googleapis. com/ig-build/org.hl7.fhir. publisher.jar
6- SET publisher_jar = org.hl7.fhir. publisher.jar
5+ SET dlurl = https://github. com/HL7/fhir- ig-publisher/releases/latest/download/ publisher.jar
6+ SET publisher_jar = publisher.jar
77SET input_cache_path = %CD% \input-cache\
88SET skipPrompts = false
99
@@ -16,11 +16,10 @@ set update_sh_url=https://raw.githubusercontent.com/FHIR/sample-ig/master/_updat
1616
1717IF " %~1 " == " /f" SET skipPrompts = true
1818
19- ECHO " %skipPrompts% "
20-
2119
20+ ECHO .
2221ECHO Checking internet connection...
23- PING tx.fhir.org -n 1 -w 1000 | FINDSTR TTL && GOTO isonline
22+ PING tx.fhir.org -4 - n 1 -w 1000 | FINDSTR TTL && GOTO isonline
2423ECHO We're offline, nothing to do...
2524GOTO end
2625
@@ -39,6 +38,7 @@ IF DEFINED ARG (
3938
4039FOR %%x IN (" %CD% " ) DO SET upper_path = %%~dpx
4140
41+ ECHO .
4242IF NOT EXIST " %input_cache_path%%publisher_jar% " (
4343 IF NOT EXIST " %upper_path%%publisher_jar% " (
4444 SET jarlocation = " %input_cache_path%%publisher_jar% "
@@ -64,13 +64,14 @@ IF DEFINED FORCE (
6464 MKDIR " %input_cache_path% " 2 > NUL
6565 GOTO download
6666)
67- ECHO Will place publisher jar here: %input_cache_path%%publisher_jar%
67+
6868IF " %skipPrompts% " == " true" (
6969 SET create = " Y"
7070) ELSE (
7171 SET /p create = " Ok? (Y/N) "
7272)
7373IF /I " %create% " == " Y" (
74+ ECHO Will place publisher jar here: %input_cache_path%%publisher_jar%
7475 MKDIR " %input_cache_path% " 2 > NUL
7576 GOTO download
7677)
@@ -129,7 +130,8 @@ GOTO done
129130
130131
131132
132- ECHO Will place publisher jar here: %input_cache_path%%publisher_jar%
133+ ECHO .
134+ ECHO Updating scripts
133135IF " %skipPrompts% " == " true" (
134136 SET updateScripts = " Y"
135137) ELSE (
@@ -147,32 +149,70 @@ REM Download all batch files (and this one with a new name)
147149
148150SETLOCAL DisableDelayedExpansion
149151
150- REM ==== For getting the sources online...
151-
152-
153- rem POWERSHELL -command if ('System.Net.WebClient' -as [type]) {(new-object System.Net.WebClient).DownloadFile(\"%update_sh_url%\",\"_updatePublisher.sh\") } else { Invoke-WebRequest -Uri "%update_sh_url%" -Outfile "_updatePublisher.new.sh" }
154-
155-
156- rem POWERSHELL -command if ('System.Net.WebClient' -as [type]) {(new-object System.Net.WebClient).DownloadFile(\"%gen_bat_url%\",\"_genonce.bat\") } else { Invoke-WebRequest -Uri "%gen_bat_url%" -Outfile "_genonce.bat" }
157152
158- rem POWERSHELL -command if ('System.Net.WebClient' -as [type]) {(new-object System.Net.WebClient).DownloadFile(\"%gencont_bat_url%\",\"_gencontinuous.bat\") } else { Invoke-WebRequest -Uri "%gencont_bat_url%" -Outfile "_gencontinuous.bat" }
159-
160- rem POWERSHELL -command if ('System.Net.WebClient' -as [type]) {(new-object System.Net.WebClient).DownloadFile(\"%gen_sh_url%\",\"_genonce.sh\") } else { Invoke-WebRequest -Uri "%gen_sh_url%" -Outfile "_genonce.sh" }
161-
162- rem POWERSHELL -command if ('System.Net.WebClient' -as [type]) {(new-object System.Net.WebClient).DownloadFile(\"%gencont_sh_url%\",\"_gencontinuous.sh\") } else { Invoke-WebRequest -Uri "%gencont_sh_url%" -Outfile "_gencontinuous.sh" }
163153
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
164205call 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" }
165-
166- if %ERRORLEVEL% == 0 goto next
167- echo " Errors encountered during execution. Exited with status: %errorlevel% "
206+ if %ERRORLEVEL% == 0 goto upd_script_6
207+ echo " Errors encountered during download: %errorlevel% "
168208goto end
169- :next
170- ECHO Updating this file...
171- start copy /y " _updatePublisher.new.bat" " _updatePublisher2.bat" ^ &^ & del " _updatePublisher.new.bat" ^ &^ & exit
172- REM ============================
209+ :upd_script_6
210+ start copy /y " _updatePublisher.new.bat" " _updatePublisher.bat" ^ &^ & del " _updatePublisher.new.bat" ^ &^ & exit
211+
173212
174213:end
175214
215+
176216IF " %skipPrompts% " == " true" (
177217 PAUSE
178218}
0 commit comments