2014-01-30 15:36:40 -05:00
|
|
|
@echo off
|
2014-02-02 16:51:03 -05:00
|
|
|
setlocal EnableDelayedExpansion
|
2014-01-30 15:36:40 -05:00
|
|
|
|
|
|
|
:: Global Variables
|
|
|
|
set "temp-dir=C:\Coco-Temp"
|
|
|
|
set install-log=%temp-dir%\coco-dev-install-log.txt
|
|
|
|
|
2014-02-01 18:47:10 -05:00
|
|
|
:: set correct curl app
|
|
|
|
IF EXIST "%PROGRAMFILES(X86)%" (
|
|
|
|
(set "curl-app=curl\64bit\curl.exe")
|
|
|
|
) ELSE (
|
|
|
|
set "curl-app=curl\32bit\curl.exe"
|
|
|
|
)
|
2014-02-02 16:51:03 -05:00
|
|
|
|
|
|
|
:: TIPS
|
|
|
|
:: + Ask user if he wants to install something
|
|
|
|
:: + Ask user to enter the path of the installed program (git, ...)
|
2014-02-01 18:47:10 -05:00
|
|
|
|
2014-01-30 15:36:40 -05:00
|
|
|
:: Create The Temporary Directory
|
|
|
|
IF EXIST %temp-dir% rmdir %temp-dir% /s /q
|
|
|
|
mkdir %temp-dir%
|
|
|
|
|
|
|
|
:: Create Log File
|
|
|
|
copy /y nul %install-log% > nul
|
|
|
|
|
2014-02-02 16:51:03 -05:00
|
|
|
call:log_sse "Welcome to the automated Installation of the CodeCombat Dev. Environment!"
|
|
|
|
|
|
|
|
:: Read Language Index
|
|
|
|
call:parse_file_new "localisation\languages" lang lang_c
|
|
|
|
|
2014-02-02 17:40:58 -05:00
|
|
|
:: Read Download URLs
|
|
|
|
call:parse_file_new "config\downloads" downloads n
|
|
|
|
call:parse_file_new "config\downloads_32" downloads_32 n
|
|
|
|
call:parse_file_new "config\downloads_64" downloads_64 n
|
|
|
|
call:parse_file_new "config\downloads_vista_32" downloads_vista_32 n
|
|
|
|
call:parse_file_new "config\downloads_vista_64" downloads_vista_64 n
|
|
|
|
call:parse_file_new "config\downloads_7_32" downloads_7_32 n
|
|
|
|
call:parse_file_new "config\downloads_7_64" downloads_7_64 n
|
|
|
|
|
2014-02-02 16:51:03 -05:00
|
|
|
:: Parse all Localisation Files
|
|
|
|
for /L %%i in (1,1,%lang_c%) do (
|
|
|
|
call:parse_file "localisation\%%lang[%%i]%%" languages languages_c
|
|
|
|
)
|
|
|
|
|
|
|
|
set /A "wc = %languages_c% / %lang_c%"
|
|
|
|
|
|
|
|
:: Start install with language question (Localisation)
|
|
|
|
call:log "Which language do you prefer?"
|
|
|
|
|
|
|
|
set /A c=0
|
|
|
|
for /L %%i in (1,%wc%,%languages_c%) do (
|
|
|
|
set /A "n = %%i - 1"
|
|
|
|
call:log " [%%c%%] %%languages[%%i]%%"
|
|
|
|
set /A c+=1
|
|
|
|
)
|
|
|
|
|
2014-02-02 17:40:58 -05:00
|
|
|
set "lang_id=-1"
|
2014-02-02 16:51:03 -05:00
|
|
|
set /p lang_id= "Enter the language ID and press <ENTER>: "
|
2014-02-02 17:40:58 -05:00
|
|
|
goto:user_pick_language
|
|
|
|
|
|
|
|
:user_pick_language
|
|
|
|
set res=false
|
|
|
|
if %lang_id% LSS 0 set res=true
|
|
|
|
if %lang_id% GEQ %lang_c% set res=true
|
|
|
|
if "%res%"=="true" (
|
|
|
|
call:log "Invalid id! Please enter a correct id from the numbers listed above..."
|
|
|
|
call:draw_dss
|
|
|
|
set /p lang_id= "Enter the language ID and press <ENTER>: "
|
|
|
|
goto:user_pick_language
|
|
|
|
)
|
|
|
|
|
|
|
|
call:get_lw word 0
|
|
|
|
call:log_ds "You choose '%word%', from now on all feedback will be logged in it."
|
|
|
|
|
|
|
|
call:log_lw 1
|
2014-02-02 16:51:03 -05:00
|
|
|
call:log_lw_sse 2
|
2014-01-30 16:09:32 -05:00
|
|
|
|
|
|
|
:: downloads for all version...
|
|
|
|
|
|
|
|
:: [TODO] The choice between Cygwin && Git ?! Is
|
2014-02-01 20:55:42 -05:00
|
|
|
|
2014-02-02 16:51:03 -05:00
|
|
|
call:log_lw_sse 3
|
2014-02-01 20:55:42 -05:00
|
|
|
|
2014-02-02 17:40:58 -05:00
|
|
|
call:install_software "git" "%%downloads[1]%%"
|
2014-01-30 15:36:40 -05:00
|
|
|
|
2014-01-30 16:09:32 -05:00
|
|
|
:: [TODO] Add downloads for windows visual studio ?!
|
2014-01-30 15:36:40 -05:00
|
|
|
|
2014-01-30 16:09:32 -05:00
|
|
|
:: architecture specific downloads...
|
2014-01-30 15:36:40 -05:00
|
|
|
IF EXIST "%PROGRAMFILES(X86)%" (GOTO 64BIT) ELSE (GOTO 32BIT)
|
|
|
|
|
2014-02-01 21:46:45 -05:00
|
|
|
:go_to_platform
|
|
|
|
call:log_ds "Windows %~1 detected..."
|
|
|
|
GOTO %~2
|
|
|
|
goto:eof
|
2014-02-01 20:55:42 -05:00
|
|
|
|
2014-02-01 21:46:45 -05:00
|
|
|
:instal_swv_software
|
2014-01-30 15:36:40 -05:00
|
|
|
:: Some installations require specific windows versions
|
|
|
|
for /f "tokens=4-5 delims=. " %%i in ('ver') do set VERSION=%%i.%%j
|
2014-02-01 21:46:45 -05:00
|
|
|
if "%version%" == "5.2" ( call:go_to_platform "XP" ver_XP_%~1 )
|
|
|
|
if "%version%" == "6.0" ( call:go_to_platform "Vista" ver_Vista_%~1 )
|
|
|
|
if "%version%" == "6.1" ( call:go_to_platform "7" ver_Win7_8_%~1 )
|
|
|
|
if "%version%" == "6.2" ( call:go_to_platform "8.0" ver_Win7_8_%~1 )
|
|
|
|
if "%version%" == "6.3" ( call:go_to_platform "8.1" ver_Win7_8_%~1 )
|
2014-01-30 15:36:40 -05:00
|
|
|
GOTO warn_and_exit
|
2014-02-01 21:46:45 -05:00
|
|
|
goto:eof
|
2014-01-30 15:36:40 -05:00
|
|
|
|
2014-02-02 17:40:58 -05:00
|
|
|
:download_install_architecture_specific_software
|
|
|
|
call:log_ds "%~1-bit computer detected..."
|
2014-01-30 15:36:40 -05:00
|
|
|
|
2014-02-02 17:40:58 -05:00
|
|
|
call:install_software "node-js" "%%downloads_%~1[1]%%"
|
2014-02-01 21:46:45 -05:00
|
|
|
call:draw_dss
|
2014-02-02 17:40:58 -05:00
|
|
|
call:install_software "ruby" "%%downloads_%~1[2]%%"
|
2014-01-30 15:36:40 -05:00
|
|
|
|
2014-02-02 17:40:58 -05:00
|
|
|
instal_swv_software %~1
|
|
|
|
goto:eof
|
|
|
|
|
|
|
|
:64BIT
|
|
|
|
call:download_install_architecture_specific_software 64
|
2014-02-01 21:46:45 -05:00
|
|
|
GOTO END
|
|
|
|
|
|
|
|
:32BIT
|
2014-02-02 17:40:58 -05:00
|
|
|
call:download_install_architecture_specific_software 32
|
2014-01-30 15:36:40 -05:00
|
|
|
GOTO END
|
|
|
|
|
|
|
|
:ver_Win7_8_32
|
2014-02-02 17:40:58 -05:00
|
|
|
call:install_packed_software "mongo-db" "%%downloads_7_32[1]%%"
|
2014-02-01 21:46:45 -05:00
|
|
|
goto git_rep_checkout
|
2014-01-30 15:36:40 -05:00
|
|
|
|
|
|
|
:ver_Vista_32
|
2014-02-02 17:40:58 -05:00
|
|
|
call:install_packed_software "mongo-db" "%%downloads_vista_32[1]%%"
|
2014-02-01 21:46:45 -05:00
|
|
|
goto git_rep_checkout
|
2014-01-30 15:36:40 -05:00
|
|
|
|
|
|
|
:ver_XP_32
|
2014-02-01 21:46:45 -05:00
|
|
|
call:log_ds "Sadly we can't support Windows XP... Please upgrade your OS!"
|
2014-01-30 15:36:40 -05:00
|
|
|
goto END
|
|
|
|
|
|
|
|
:ver_Win7_8_64
|
2014-02-02 17:40:58 -05:00
|
|
|
call:install_packed_software "mongo-db" "%%downloads_7_64[1]%%"
|
2014-02-01 21:46:45 -05:00
|
|
|
goto git_rep_checkout
|
2014-01-30 15:36:40 -05:00
|
|
|
|
|
|
|
:ver_Vista_64
|
2014-02-02 17:40:58 -05:00
|
|
|
call:install_packed_software "mongo-db" "%%downloads_vista_64[1]%%"
|
2014-02-01 21:46:45 -05:00
|
|
|
goto git_rep_checkout
|
2014-01-30 15:36:40 -05:00
|
|
|
|
|
|
|
:ver_XP_64
|
2014-02-01 21:46:45 -05:00
|
|
|
call:log_ds "Sadly we can't support Windows XP... Please upgrade your OS!"
|
2014-01-30 15:36:40 -05:00
|
|
|
goto END
|
|
|
|
|
2014-01-30 16:09:32 -05:00
|
|
|
:git_rep_checkout
|
2014-02-01 21:46:45 -05:00
|
|
|
call:log_ss "Software has been installed..."
|
|
|
|
call:log_sse "Checking out the Git Repository..."
|
2014-01-30 15:36:40 -05:00
|
|
|
goto report_ok
|
|
|
|
|
|
|
|
:report_ok
|
2014-02-01 21:46:45 -05:00
|
|
|
call:log_ss "Installation of the Developers Environment is complete!"
|
|
|
|
call:log_sse "Bye Bye!"
|
2014-01-30 15:36:40 -05:00
|
|
|
goto clean_up
|
|
|
|
|
|
|
|
:warn_and_exit
|
2014-02-01 21:46:45 -05:00
|
|
|
call:log_ss "Machine OS cannot be determined..."
|
|
|
|
call:log_sse "Report your OS to the developers @ CodeCombat.com..."
|
2014-01-30 16:17:48 -05:00
|
|
|
goto error_report
|
|
|
|
|
|
|
|
:error_report
|
2014-02-01 21:46:45 -05:00
|
|
|
call:log_ds "Installation has been stopped..."
|
2014-01-30 15:36:40 -05:00
|
|
|
goto END
|
|
|
|
|
|
|
|
:clean_up
|
2014-02-01 21:46:45 -05:00
|
|
|
call:log_sse "... Cleaning up has been disabled... Terminating Script!"
|
|
|
|
rmdir %temp-dir% /s /q
|
2014-01-30 15:36:40 -05:00
|
|
|
goto END
|
|
|
|
|
2014-02-01 20:55:42 -05:00
|
|
|
:install_software
|
2014-02-02 16:51:03 -05:00
|
|
|
call:get_lw word 4
|
|
|
|
call:log "%word% %~1..."
|
2014-02-01 21:46:45 -05:00
|
|
|
%curl-app% %~2 -o %temp-dir%\%~1-setup.exe
|
2014-02-02 16:51:03 -05:00
|
|
|
call:get_lw word 5
|
|
|
|
call:log "%word% %~1..."
|
2014-02-01 21:46:45 -05:00
|
|
|
START /WAIT %temp-dir%\%~1-setup.exe
|
2014-02-01 20:55:42 -05:00
|
|
|
goto:eof
|
|
|
|
|
2014-02-02 16:51:03 -05:00
|
|
|
:: ============================== FUNCTIONS ====================================
|
|
|
|
|
2014-02-01 20:55:42 -05:00
|
|
|
:log
|
2014-02-01 21:46:45 -05:00
|
|
|
echo %~1
|
|
|
|
echo %~1 >> %install-log%
|
|
|
|
goto:eof
|
|
|
|
|
|
|
|
:draw_ss
|
|
|
|
call:log "----------------------------------------------------------------------------"
|
|
|
|
goto:eof
|
|
|
|
|
|
|
|
:draw_dss
|
|
|
|
call:log "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -"
|
|
|
|
goto:eof
|
|
|
|
|
|
|
|
:log_ss
|
|
|
|
call:draw_ss
|
|
|
|
call:log "%~1"
|
|
|
|
goto:eof
|
|
|
|
|
|
|
|
:log_sse
|
|
|
|
call:log "%~1"
|
|
|
|
call:draw_ss
|
|
|
|
goto:eof
|
|
|
|
|
|
|
|
:log_ds
|
|
|
|
call:log_ss "%~1"
|
|
|
|
call:draw_ss
|
2014-02-01 20:55:42 -05:00
|
|
|
goto:eof
|
|
|
|
|
2014-02-02 16:51:03 -05:00
|
|
|
:: ============================== IO FUNCTIONS ====================================
|
|
|
|
|
|
|
|
:parse_file
|
|
|
|
set "file=%~1"
|
|
|
|
for /F "usebackq delims=" %%a in ("%file%") do (
|
|
|
|
set /A %~3+=1
|
|
|
|
call set %~2[%%%~3%%]=%%a
|
|
|
|
)
|
|
|
|
goto:eof
|
|
|
|
|
|
|
|
:parse_file_new
|
|
|
|
set /A %~3=0
|
|
|
|
call:parse_file %~1 %~2 %~3
|
|
|
|
goto:eof
|
|
|
|
|
|
|
|
:: ============================== LOCALISATION FUNCTIONS ===========================
|
|
|
|
|
|
|
|
:get_lw
|
|
|
|
call:get_lw_id %~1 %lang_id% %~2
|
|
|
|
goto:eof
|
|
|
|
|
|
|
|
:get_lw_id
|
|
|
|
set /A count = %~2 * %wc% + %~3 + 1
|
|
|
|
set "%~1=!languages[%count%]!"
|
|
|
|
goto:eof
|
|
|
|
|
|
|
|
:log_lw
|
|
|
|
call:get_lw str %~1
|
|
|
|
call:log %str%
|
|
|
|
goto:eof
|
|
|
|
|
|
|
|
:log_lw_ss
|
|
|
|
call:get_lw str %~1
|
|
|
|
call:log_ss %str%
|
|
|
|
goto:eof
|
|
|
|
|
|
|
|
:log_lw_ds
|
|
|
|
call:get_lw str %~1
|
|
|
|
call:log_ds %str%
|
|
|
|
goto:eof
|
|
|
|
|
|
|
|
:log_lw_sse
|
|
|
|
call:get_lw str %~1
|
|
|
|
call:log_sse %str%
|
|
|
|
goto:eof
|
|
|
|
|
|
|
|
:: ============================== EOF ====================================
|
|
|
|
|
2014-01-30 15:36:40 -05:00
|
|
|
:END
|
|
|
|
endlocal
|