Skip to content

Commit 4008ecc

Browse files
committed
Respond to Chris' comments
1 parent 464aaad commit 4008ecc

File tree

7 files changed

+274
-45
lines changed

7 files changed

+274
-45
lines changed

_gencontinuous.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
@ECHO OFF
2-
CALL _genonce.bat -watch
2+
CALL ./_genonce.bat -watch

_genonce.bat

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
@ECHO OFF
2-
SET publisher_jar=org.hl7.fhir.publisher.jar
2+
SET publisher_jar=publisher.jar
33
SET input_cache_path=%CD%\input-cache
44

55
ECHO Checking internet connection...
6-
PING tx.fhir.org -n 1 -w 1000 | FINDSTR TTL && GOTO isonline
6+
PING tx.fhir.org -4 -n 1 -w 1000 | FINDSTR TTL && GOTO isonline
77
ECHO We're offline...
88
SET txoption=-tx n/a
99
GOTO igpublish
@@ -17,11 +17,11 @@ SET txoption=
1717
SET JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF-8
1818

1919
IF EXIST "%input_cache_path%\%publisher_jar%" (
20-
JAVA -jar "%input_cache_path%\%publisher_jar%" -ig ig.ini %txoption% %*
20+
JAVA -jar "%input_cache_path%\%publisher_jar%" -ig . %txoption% %*
2121
) ELSE If exist "..\%publisher_jar%" (
22-
JAVA -jar "..\%publisher_jar%" -ig ig.ini %txoption% %*
22+
JAVA -jar "..\%publisher_jar%" -ig . %txoption% %*
2323
) ELSE (
2424
ECHO IG Publisher NOT FOUND in input-cache or parent folder. Please run _updatePublisher. Aborting...
2525
)
2626

27-
PAUSE
27+
PAUSE

_genonce.sh

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
#!/bin/bash
2-
publisher_jar=org.hl7.fhir.publisher.jar
2+
publisher_jar=publisher.jar
33
input_cache_path=./input-cache/
4-
set -e
54
echo Checking internet connection...
6-
wget -q --spider tx.fhir.org
5+
curl -sSf tx.fhir.org > /dev/null
76

87
if [ $? -eq 0 ]; then
98
echo "Online"
@@ -17,12 +16,12 @@ echo "$txoption"
1716

1817
publisher=$input_cache_path/$publisher_jar
1918
if test -f "$publisher"; then
20-
JAVA -jar $publisher -ig ig.ini $txoption $*
19+
java -jar $publisher -ig . $txoption $*
2120

2221
else
2322
publisher=../$publisher_jar
2423
if test -f "$publisher"; then
25-
JAVA -jar $publisher -ig ig.ini $txoption $*
24+
java -jar $publisher -ig . $txoption $*
2625
else
2726
echo IG Publisher NOT FOUND in input-cache or parent folder. Please run _updatePublisher. Aborting...
2827
fi

_updatePublisher.bat

Lines changed: 159 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,44 @@
11
@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
47
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+
)
538

639
FOR %%x IN ("%CD%") DO SET upper_path=%%~dpx
740

41+
ECHO.
842
IF NOT EXIST "%input_cache_path%%publisher_jar%" (
943
IF NOT EXIST "%upper_path%%publisher_jar%" (
1044
SET jarlocation="%input_cache_path%%publisher_jar%"
@@ -16,30 +50,44 @@ IF NOT EXIST "%input_cache_path%%publisher_jar%" (
1650
ECHO IG Publisher FOUND in parent folder
1751
SET jarlocation="%upper_path%%publisher_jar%"
1852
SET jarlocationname=Parent folder
19-
GOTO:upgrade
53+
GOTO upgrade
2054
)
2155
) ELSE (
2256
ECHO IG Publisher FOUND in input-cache
2357
SET jarlocation="%input_cache_path%%publisher_jar%"
2458
SET jarlocationname=Input Cache
25-
GOTO:upgrade
59+
GOTO upgrade
2660
)
2761

2862
: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+
)
3173
IF /I "%create%"=="Y" (
74+
ECHO Will place publisher jar here: %input_cache_path%%publisher_jar%
3275
MKDIR "%input_cache_path%" 2> NUL
33-
GOTO:download
76+
GOTO download
3477
)
35-
GOTO:done
78+
GOTO done
3679

3780
: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+
3987
IF /I "%overwrite%"=="Y" (
40-
GOTO:download
88+
GOTO download
4189
)
42-
GOTO:done
90+
GOTO done
4391

4492
:download
4593
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
60108
GOTO done
61109

62110
: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%')
64119
GOTO done
65120

66121
:win8.1
67122
:win8
68123
:vista
69-
ECHO This script does not yet support Windows %winver%. Please ask for help on http://chat.fhir.org
70124
GOTO done
71125

126+
127+
72128
: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

Comments
 (0)