Merge pull request #22 from costateixeira/self-updating-scripts
Self updating scripts
This commit is contained in:
commit
4fe9d74dfe
@ -19,6 +19,15 @@ IF "%~1"=="/f" SET skipPrompts=true
|
|||||||
ECHO "%skipPrompts%"
|
ECHO "%skipPrompts%"
|
||||||
|
|
||||||
|
|
||||||
|
ECHO Checking internet connection...
|
||||||
|
PING tx.fhir.org -n 1 -w 1000 | FINDSTR TTL && GOTO isonline
|
||||||
|
ECHO We're offline, nothing to do...
|
||||||
|
GOTO end
|
||||||
|
|
||||||
|
:isonline
|
||||||
|
ECHO We're online
|
||||||
|
|
||||||
|
|
||||||
:processflags
|
:processflags
|
||||||
SET ARG=%1
|
SET ARG=%1
|
||||||
IF DEFINED ARG (
|
IF DEFINED ARG (
|
||||||
@ -41,19 +50,19 @@ IF NOT EXIST "%input_cache_path%%publisher_jar%" (
|
|||||||
ECHO IG Publisher FOUND in parent folder
|
ECHO IG Publisher FOUND in parent folder
|
||||||
SET jarlocation="%upper_path%%publisher_jar%"
|
SET jarlocation="%upper_path%%publisher_jar%"
|
||||||
SET jarlocationname=Parent folder
|
SET jarlocationname=Parent folder
|
||||||
GOTO:upgrade
|
GOTO upgrade
|
||||||
)
|
)
|
||||||
) ELSE (
|
) ELSE (
|
||||||
ECHO IG Publisher FOUND in input-cache
|
ECHO IG Publisher FOUND in input-cache
|
||||||
SET jarlocation="%input_cache_path%%publisher_jar%"
|
SET jarlocation="%input_cache_path%%publisher_jar%"
|
||||||
SET jarlocationname=Input Cache
|
SET jarlocationname=Input Cache
|
||||||
GOTO:upgrade
|
GOTO upgrade
|
||||||
)
|
)
|
||||||
|
|
||||||
:create
|
:create
|
||||||
IF DEFINED FORCE (
|
IF DEFINED FORCE (
|
||||||
MKDIR "%input_cache_path%" 2> NUL
|
MKDIR "%input_cache_path%" 2> NUL
|
||||||
GOTO:download
|
GOTO download
|
||||||
)
|
)
|
||||||
ECHO Will place publisher jar here: %input_cache_path%%publisher_jar%
|
ECHO Will place publisher jar here: %input_cache_path%%publisher_jar%
|
||||||
IF "%skipPrompts%"=="true" (
|
IF "%skipPrompts%"=="true" (
|
||||||
@ -61,11 +70,11 @@ IF "%skipPrompts%"=="true" (
|
|||||||
) ELSE (
|
) ELSE (
|
||||||
SET /p create="Ok? (Y/N) "
|
SET /p create="Ok? (Y/N) "
|
||||||
)
|
)
|
||||||
IF /I %create%=="Y" (
|
IF /I "%create%"=="Y" (
|
||||||
MKDIR "%input_cache_path%" 2> NUL
|
MKDIR "%input_cache_path%" 2> NUL
|
||||||
GOTO:download
|
GOTO download
|
||||||
)
|
)
|
||||||
GOTO:done
|
GOTO done
|
||||||
|
|
||||||
:upgrade
|
:upgrade
|
||||||
IF "%skipPrompts%"=="true" (
|
IF "%skipPrompts%"=="true" (
|
||||||
@ -74,10 +83,10 @@ IF "%skipPrompts%"=="true" (
|
|||||||
SET /p overwrite="Overwrite %jarlocation%? (Y/N) "
|
SET /p overwrite="Overwrite %jarlocation%? (Y/N) "
|
||||||
)
|
)
|
||||||
|
|
||||||
IF /I %overwrite%=="Y" (
|
IF /I "%overwrite%"=="Y" (
|
||||||
GOTO:download
|
GOTO download
|
||||||
)
|
)
|
||||||
GOTO:done
|
GOTO done
|
||||||
|
|
||||||
:download
|
:download
|
||||||
ECHO Downloading most recent publisher to %jarlocationname% - 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
|
||||||
@ -98,34 +107,72 @@ CALL POWERSHELL -command if ('System.Net.WebClient' -as [type]) {(new-object Sys
|
|||||||
GOTO done
|
GOTO done
|
||||||
|
|
||||||
:win7
|
:win7
|
||||||
CALL bitsadmin /transfer GetPublisher /download /priority normal "%dlurl%" "%jarlocation%"
|
rem this may be triggering the antivirus - bitsadmin.exe is a known threat
|
||||||
|
rem CALL bitsadmin /transfer GetPublisher /download /priority normal "%dlurl%" "%jarlocation%"
|
||||||
|
|
||||||
|
rem this didn't work in win 10
|
||||||
|
rem CALL Start-BitsTransfer /priority normal "%dlurl%" "%jarlocation%"
|
||||||
|
|
||||||
|
rem this should work - untested
|
||||||
|
call (New-Object Net.WebClient).DownloadFile('%dlurl%', '%jarlocation%')
|
||||||
GOTO done
|
GOTO done
|
||||||
|
|
||||||
:win8.1
|
:win8.1
|
||||||
:win8
|
:win8
|
||||||
:vista
|
:vista
|
||||||
ECHO This script does not yet support Windows %winver%. Please ask for help on http://chat.fhir.org
|
|
||||||
GOTO done
|
GOTO done
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
:done
|
:done
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ECHO Will place publisher jar here: %input_cache_path%%publisher_jar%
|
||||||
|
IF "%skipPrompts%"=="true" (
|
||||||
|
SET updateScripts="Y"
|
||||||
|
) ELSE (
|
||||||
|
SET /p updateScripts="Update scripts? (Y/N) "
|
||||||
|
)
|
||||||
|
IF /I "%updateScripts%"=="Y" (
|
||||||
|
GOTO scripts
|
||||||
|
)
|
||||||
|
GOTO end
|
||||||
|
|
||||||
|
|
||||||
|
:scripts
|
||||||
|
|
||||||
REM Download all batch files (and this one with a new name)
|
REM Download all batch files (and this one with a new name)
|
||||||
|
|
||||||
SETLOCAL DisableDelayedExpansion
|
SETLOCAL DisableDelayedExpansion
|
||||||
|
|
||||||
REM ==== For getting the sources online...
|
REM ==== For getting the sources online...
|
||||||
rem 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" }
|
|
||||||
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" }
|
|
||||||
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" }
|
|
||||||
|
|
||||||
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" }
|
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" }
|
||||||
|
|
||||||
|
|
||||||
|
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" }
|
||||||
|
|
||||||
|
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" }
|
||||||
|
|
||||||
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" }
|
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" }
|
||||||
|
|
||||||
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" }
|
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" }
|
||||||
|
|
||||||
rem ECHO Updating this file...
|
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" }
|
||||||
rem start copy /y "_updatePublisher.new.bat" "_updatePublisher.bat" ^&^& del "_updatePublisher.new.bat" ^&^& exit
|
|
||||||
|
if %ERRORLEVEL% == 0 goto next
|
||||||
|
echo "Errors encountered during execution. Exited with status: %errorlevel%"
|
||||||
|
goto end
|
||||||
|
:next
|
||||||
|
ECHO Updating this file...
|
||||||
|
start copy /y "_updatePublisher.new.bat" "_updatePublisher.bat" ^&^& del "_updatePublisher.new.bat" ^&^& exit
|
||||||
REM ============================
|
REM ============================
|
||||||
|
|
||||||
|
:end
|
||||||
|
|
||||||
IF "%skipPrompts%"=="true" (
|
IF "%skipPrompts%"=="true" (
|
||||||
PAUSE
|
PAUSE
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user