From b270e6b5db4be18628ca4181fc67463891b13aa0 Mon Sep 17 00:00:00 2001 From: Lloyd McKenzie Date: Thu, 19 Dec 2019 00:04:22 -0700 Subject: [PATCH] Cleaned up launch scripts --- _genonce.bat | 38 +++++++------- _genonce.sh | 26 +++++----- _updatePublisher.bat | 116 ++++++++++++++++++++++--------------------- _updatePublisher.sh | 63 +++++++++++++---------- 4 files changed, 132 insertions(+), 111 deletions(-) diff --git a/_genonce.bat b/_genonce.bat index 1bb6f56..d44c150 100644 --- a/_genonce.bat +++ b/_genonce.bat @@ -1,25 +1,27 @@ -@echo off +@ECHO OFF +SET publisher_jar=org.hl7.fhir.publisher.jar +SET input_cache_path=%CD%\input-cache\ + +ECHO Checking internet connection... +PING tx.fhir.org -n 1 -w 1000 | FINDSTR TTL && GOTO isonline +ECHO We're offline... +SET txoption=-tx n/a +GOTO igpublish -echo Checking internet connection... -Ping tx.fhir.org -n 1 -w 1000 | findstr TTL && goto isonline -echo We're offline... -set txoption=-tx n/a -goto igpublish :isonline -echo We're online -set txoption= +ECHO We're online +SET txoption= :igpublish +SET JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF-8 -@SET JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF-8 +IF EXIST "%input_cache_path%\%publisher_jar%" ( + JAVA -jar input-cache/org.hl7.fhir.publisher.jar -ig ig.ini %txoption% +) ELSE If exist "..\%publisher_jar%" ( + JAVA -jar ../%publisher_jar% -ig ig.ini %txoption% +) ELSE ( + ECHO IG Publisher NOT FOUND in input-cache or parent folder... aborting +) -If exist "input-cache\org.hl7.fhir.publisher.jar" ( - JAVA -jar input-cache/org.hl7.fhir.publisher.jar -ig ig.ini %txoption% -) ELSE If exist "..\org.hl7.fhir.publisher.jar" ( - JAVA -jar ../org.hl7.fhir.publisher.jar -ig ig.ini %txoption% - ) Else ( -@ECHO IG Publisher NOT FOUND in input-cache or parent folder... aborting - ) - -@PAUSE \ No newline at end of file +PAUSE \ No newline at end of file diff --git a/_genonce.sh b/_genonce.sh index bb7ba71..5b2efae 100755 --- a/_genonce.sh +++ b/_genonce.sh @@ -1,27 +1,29 @@ #!/bin/bash +publisher_jar=org.hl7.fhir.publisher.jar +input_cache_path=./input-cache/ set -e echo Checking internet connection... wget -q --spider tx.fhir.org if [ $? -eq 0 ]; then - echo "Online" - txoption="" + echo "Online" + txoption="" else - echo "Offline" - txoption="-tx n/a" + echo "Offline" + txoption="-tx n/a" fi echo "$txoption" -publisher=./input-cache/org.hl7.fhir.publisher.jar +publisher=$input_cache_path/$publisher_jar if test -f "$publisher"; then - JAVA -jar ./input-cache/org.hl7.fhir.publisher.jar -ig ig.ini $txoption + JAVA -jar $publisher -ig ig.ini $txoption else - publisher=../org.hl7.fhir.publisher.jar - if test -f "$publisher"; then - JAVA -jar ../org.hl7.fhir.publisher.jar -ig ig.ini $txoption - else - echo IG Publisher NOT FOUND in input-cache or parent folder... aborting - fi + publisher=../$publisher_jar + if test -f "$publisher"; then + JAVA -jar $publisher -ig ig.ini $txoption + else + echo IG Publisher NOT FOUND in input-cache or parent folder... aborting + fi fi diff --git a/_updatePublisher.bat b/_updatePublisher.bat index 1608834..3176eac 100644 --- a/_updatePublisher.bat +++ b/_updatePublisher.bat @@ -1,69 +1,73 @@ -@echo off +@ECHO OFF +SET dlurl=https://fhir.github.io/latest-ig-publisher/org.hl7.fhir.publisher.jar +SET publisher_jar=org.hl7.fhir.publisher.jar +SET input_cache_path=%CD%\input-cache\ -for /f "tokens=4-5 delims=. " %%i in ('ver') do set VERSION=%%i.%%j -if "%version%" == "10.0" set winver=10 -if "%version%" == "6.3" set winver=8.1 -if "%version%" == "6.2" set winver=8 -if "%version%" == "6.1" set winver=7 -if "%version%" == "6.0" set winver=vista +FOR %%x IN ("%CD%") DO SET upper_path=%%~dpx -for %%x in ("%CD%") do set upper_path=%%~dpx -set current_path=%cd% - -@Set location= -rem echo inputcachepath -rem echo "%current_path%\input-cache\org.hl7.fhir.publisher.jar" - -If not exist "%current_path%\input-cache\org.hl7.fhir.publisher.jar" ( - If not exist "%upper_path%org.hl7.fhir.publisher.jar" ( - @ECHO IG Publisher is not in input-cache or parent folder... - @Set filelocation="%current_path%\input-cache\org.hl7.fhir.publisher.jar" - echo %filelocation% - @goto:download - - ) else ( - @ECHO IG Publisher FOUND in parent folder - @Set location=parent - @Set filelocation="%upper_path%org.hl7.fhir.publisher.jar" - @set filelocationname=Parent folder - echo %filelocation% - @goto:upgrade - +IF NOT EXIST "%input_cache_path%%publisher_jar%" ( + IF NOT EXIST "%upper_path%%publisher_jar%" ( + SET jarlocation=%input_cache_path%%publisher_jar% + SET jarlocationname=Input Cache + ECHO IG Publisher is not yet in input-cache or parent folder. + REM we don't use jarlocation below because it will be empty because we're in a bracketed if statement + GOTO create + ) ELSE ( + ECHO IG Publisher FOUND in parent folder + SET jarlocation=%upper_path%%publisher_jar% + SET jarlocationname=Parent folder + GOTO:upgrade ) - -) else ( - @ECHO IG Publisher FOUND in input-cache - @Set location=cache - @Set filelocation="%current_path%\input-cache\org.hl7.fhir.publisher.jar" - @set filelocationname=Input Cache - echo %filelocation% - @goto:upgrade - +) ELSE ( + ECHO IG Publisher FOUND in input-cache + SET jarlocation=%input_cache_path%%publisher_jar% + SET jarlocationname=Input Cache + GOTO:upgrade ) -echo Done -goto:eof +:create +ECHO Will place publisher jar here: %input_cache_path%%publisher_jar% +SET /p create="Ok? (Y/N)" +IF /I "%create%"=="Y" ( + MKDIR "%input_cache_path%" 2> NUL + GOTO:download +) +GOTO:done :upgrade -set /p overwrite="Overwrite? " -if /I "%overwrite%"=="Y" ( - goto:download +SET /p overwrite="Overwrite %jarlocation%? (Y/N)" +IF /I "%overwrite%"=="Y" ( + GOTO:download ) - -goto:eof +GOTO:done :download -set dlurl=https://fhir.github.io/latest-ig-publisher/org.hl7.fhir.publisher.jar -@ECHO Downloading most recent publisher to %filelocationname% - it's ~100 MB, so this may take a bit +ECHO Downloading most recent publisher to %jarlocationname% - it's ~100 MB, so this may take a bit -if /I "%winver%"=="10" ( - @POWERSHELL -command Invoke-WebRequest -Uri %dlurl% -Outfile %filelocation% - ) +FOR /f "tokens=4-5 delims=. " %%i IN ('ver') DO SET VERSION=%%i.%%j +IF "%version%" == "10.0" GOTO win10 +IF "%version%" == "6.3" GOTO win8.1 +IF "%version%" == "6.2" GOTO win8 +IF "%version%" == "6.1" GOTO win7 +IF "%version%" == "6.0" GOTO vista -if /I "%winver%"=="7" ( - bitsadmin /transfer GetPublisher /download /priority normal %dlurl% %filelocation% -) +ECHO Unrecognized version: %version% +GOTO done -@ECHO "Done" -pause -:eof +:win10 +POWERSHELL -command if ('System.Net.WebClient' -as [type]) {(new-object System.Net.WebClient).DownloadFile(\"%dlurl%\",\"%jarlocation%\") } else { Invoke-WebRequest -Uri "%dlurl%" -Outfile "%jarlocation%" } + +GOTO done + +:win7 +bitsadmin /transfer GetPublisher /download /priority normal "%dlurl%" "%jarlocation%" +GOTO done + +:win8.1 +:win8 +:vista +ECHO This script does not yet support Windows %winver%. Please ask for help on http://chat.fhir.org +GOTO done + +:done +PAUSE \ No newline at end of file diff --git a/_updatePublisher.sh b/_updatePublisher.sh index 9a29145..a4471c8 100755 --- a/_updatePublisher.sh +++ b/_updatePublisher.sh @@ -1,35 +1,48 @@ #!/bin/bash +dlurl=https://fhir.github.io/latest-ig-publisher/org.hl7.fhir.publisher.jar +publisher_jar=org.hl7.fhir.publisher.jar +input_cache_path=./input-cache/ + set -e if ! type "curl" > /dev/null; then - echo "ERROR: Script needs curl to download latest IG Publisher. Please install curl." - exit 1 + echo "ERROR: Script needs curl to download latest IG Publisher. Please install curl." + exit 1 +fi -publisher=./input-cache/org.hl7.fhir.publisher.jar +publisher="$input_cache_dir$publisher_jar" if test -f "$publisher"; then - jarlocation="./input-cache/org.hl7.fhir.publisher.jar" - echo "IG Publisher FOUND in input-cache" + echo "IG Publisher FOUND in input-cache" + jarlocation="$publisher" + jarlocationname=Input Cache + upgrade=true else - publisher=../org.hl7.fhir.publisher.jar - upgrade=true - if test -f "$publisher"; then - echo "IG Publisher FOUND in parent folder" - jarlocation="../org.hl7.fhir.publisher.jar" - upgrade=true - else - echo IG Publisher NOT FOUND in input-cache or parent folder... - jarlocation="./input-cache/org.hl7.fhir.publisher.jar" - upgrade=true - fi + publisher="../$publisher_jar" + upgrade=true + if test -f "$publisher"; then + echo "IG Publisher FOUND in parent folder" + jarlocation="$publisher" + jarlocationname=Input Cache + upgrade=true + else + echo IG Publisher NOT FOUND in input-cache or parent folder... + jarlocation="$input_cache_dir$publisher_jar" + jarlocationname=Input Cache + upgrade=false + fi fi if $upgrade ; then - read -r -p "Download? [y/N] " response - if [[ "$response" =~ ^([yY][eE][sS]|[yY])$ ]] - then - echo "Downloading most recent publisher to $jarlocation - it's ~100 MB, so this may take a bit" -# wget "https://fhir.github.io/latest-ig-publisher/org.hl7.fhir.publisher.jar" -O "$jarlocation" - curl https://fhir.github.io/latest-ig-publisher/org.hl7.fhir.publisher.jar -o "$jarlocation" --create-dirs - else - echo cancel... - fi + message = "Overwrite $jarlocation? [Y/N] " +else + echo Will place publisher jar here: $input_cache_path$publisher_jar + message = "Ok? [Y/N] " fi + +read -r -p $message response +if [[ "$response" =~ ^([yY])$ ]] then + echo "Downloading most recent publisher to $jarlocationname - it's ~100 MB, so this may take a bit" +# wget "https://fhir.github.io/latest-ig-publisher/org.hl7.fhir.publisher.jar" -O "$jarlocation" + curl $dlurl -o "$jarlocation" --create-dirs +else + echo cancel... +fi \ No newline at end of file