Script now has the functionality to download packed software and unpack it to a customizble position. This is applied to the mongo-db install as an example.

This commit is contained in:
Glen De Cauwsemaecker 2014-02-03 19:19:24 +01:00
parent ed93e56b38
commit 54b8f8655d
5 changed files with 47 additions and 180 deletions

View file

@ -12,8 +12,10 @@ IF EXIST "%PROGRAMFILES(X86)%" (
set "curl-app=utilities\curl\32bit\curl.exe"
)
set "ZU-app=utilities\7za.exe"
:: TODO:
:: + Write unpack and move code for software like mongo-db
:: + Write code to set environment variables...
:: + Write code to install vs if it's not yet installed on users pc
:: + Write Git Checkout repository code:
:: 1) Let user specify destination
@ -100,6 +102,7 @@ call:log_lw 8
call:install_software_o "git" "%%downloads[1]%%" exe 9
call:draw_dss
call:get_lw word 11
:: [TODO] Check if that application exists, if not ask again with warning that the path is invalid!!! (SAFETYYYY)
set /p git_exe_path="%word%: "
:: [TODO] Add downloads for windows visual studio ?!
@ -147,11 +150,13 @@ GOTO END
GOTO END
:ver_Win7_8_32
call:install_packed_software_o "mongo-db" "%%downloads_7_32[1]%%" 14
call:install_packed_software_o "mongo-db" "%%downloads_7_32[1]%%" 25 14
set "mong-db-path = %packed_software_path%"
goto git_rep_checkout
:ver_Vista_32
call:install_packed_software_o "mongo-db" "%%downloads_vista_32[1]%%" 14
call:install_packed_software_o "mongo-db" "%%downloads_vista_32[1]%%" 25 14
set "mong-db-path = %packed_software_path%"
goto git_rep_checkout
:ver_XP_32
@ -159,11 +164,13 @@ goto git_rep_checkout
goto END
:ver_Win7_8_64
call:install_packed_software_o "mongo-db" "%%downloads_7_64[1]%%" 14
call:install_packed_software_o "mongo-db" "%%downloads_7_64[1]%%" 25 14
set "mong-db-path = %packed_software_path%"
goto git_rep_checkout
:ver_Vista_64
call:install_packed_software_o "mongo-db" "%%downloads_vista_64[1]%%" 14
call:install_packed_software_o "mongo-db" "%%downloads_vista_64[1]%%" 25 14
set "mong-db-path = %packed_software_path%"
goto git_rep_checkout
:ver_XP_64
@ -196,10 +203,14 @@ goto END
:: ============================ INSTALL SOFTWARE FUNCTIONS ======================
:install_software
:download_software
call:get_lw word 4
call:log "%word% %~1..."
%curl-app% -sS -k %~2 -o %temp-dir%\%~1-setup.%~3
goto:eof
:install_software
call:download_software %~1 %~2 %~3
call:get_lw word 5
call:log "%word% %~1..."
START /WAIT %temp-dir%\%~1-setup.%~3
@ -220,20 +231,39 @@ goto:eof
goto:eof
:install_packed_software
:: 1) unpack software
:: 2) move unpacked directory
:: 3) ...
call:download_software %~1 %~2 zip
call:draw_dss
call:get_lw word %~3
set /p packed_software_path="%word% "
:: remove chosen directory of user if it already exists (to prevent a window from popping up)
IF EXIST %packed_software_path% rmdir %packed_software_path% /s /q
%ZU-app% x %temp-dir%\%~1-setup.zip -o%packed_software_path%
call:draw_dss
for /f "delims=" %%a in ('dir "%packed_software_path%\" /on /ad /b') do @set temp_dir=%%a
for /f "delims=" %%a in ('dir "%packed_software_path%\%temp_dir%\" /on /ad /b') do (
xcopy %packed_software_path%\%temp_dir% %packed_software_path%\ /S /E
)
call:draw_dss
rmdir %packed_software_path%\%temp_dir%\ /s /q
goto:eof
:install_packed_software_o
call:get_lw word %~3
call:get_lw word %~4
set /p result="%word% [Y/N]: "
call:draw_dss
set res=false
if "%result%"=="N" set res=true
if "%result%"=="n" set res=true
if "%res%"=="true" (
call:install_packed_software %~1 %~2
call:install_packed_software %~1 %~2 %~3
) else (
call:log_lw 10
)

View file

@ -22,4 +22,5 @@ Machine OS cannot be determined...
Report your OS to the developers @ CodeCombat.com...
Installation has been stopped...
... Cleaning up has been disabled... Terminating Script!
unpacking and moving:
unpacking and moving:
Enter the path where you would like to install MongoDB:

View file

@ -22,4 +22,5 @@ Machine OS cannot be determined...
Report your OS to the developers @ CodeCombat.com...
Installation has been stopped...
... Cleaning up has been disabled... Terminating Script!
unpacking and moving:
unpacking and moving:
Enter the path where you would like to install MongoDB:

View file

@ -22,4 +22,5 @@ Machine OS cannot be determined...
Report your OS to the developers @ CodeCombat.com...
Installation has been stopped...
... Cleaning up has been disabled... Terminating Script!
unpacking and moving:
unpacking and moving:
Enter the path where you would like to install MongoDB:

View file

@ -1,166 +0,0 @@
@echo off
setlocal EnableDelayedExpansion
:: Global Variables
set "temp-dir=C:\Coco-Temp"
set install-log=%temp-dir%\coco-dev-install-log.txt
:: set correct curl app
IF EXIST "%PROGRAMFILES(X86)%" (
(set "curl-app=utilities\curl\64bit\curl.exe")
) ELSE (
(set "curl-app=utilities\curl\32bit\curl.exe")
)
set "ZU-app=utilities\7za.exe"
:: TODO:
:: + Write unpack and move code for software like mongo-db
:: + Write code to install vs if it's not yet installed on users pc
:: + Write Git Checkout repository code:
:: 1) Let user specify destination
:: 2) do a git clone with the git application
:: + Configuraton and installation checklist:
:: 1) ... ?!
:: + Copy the automated dev batch file to root folder
:: => Let user define mongo-db directory
:: + Start the dev environment
:: + Exit message and warn user that he can quit the window now
set /p mongo_db_path="Enter db path: "
%ZU-app% x %temp-dir%\mongo-db-setup.zip -o%mongo_db_path%
::move directory one up
::destroy that original root directory (remove)
PAUSE
:: ============================ INSTALL SOFTWARE FUNCTIONS ======================
:download_software
call:get_lw word 4
call:log "%word% %~1..."
%curl-app% -sS -k %~2 -o %temp-dir%\%~1-setup.%~3
goto:eof
:install_software
call:download_software %~1 %~2 %~3
call:get_lw word 5
call:log "%word% %~1..."
START /WAIT %temp-dir%\%~1-setup.%~3
goto:eof
:install_software_o
call:get_lw word %~4
set /p result="%word% [Y/N]: "
call:draw_dss
set res=false
if "%result%"=="N" set res=true
if "%result%"=="n" set res=true
if "%res%"=="true" (
call:install_software %~1 %~2 %~3
) else (
call:log_lw 10
)
goto:eof
:install_packed_software
call:download_software %~1 %~2 zip
call:get_lw word 24
call:log "%word% %~1..."
ZU-app %temp-dir%\%~1-setup.zip
::what directory do you want to move it too?
goto:eof
:install_packed_software_o
call:get_lw word %~3
set /p result="%word% [Y/N]: "
call:draw_dss
set res=false
if "%result%"=="N" set res=true
if "%result%"=="n" set res=true
if "%res%"=="true" (
call:install_packed_software %~1 %~2
) else (
call:log_lw 10
)
goto:eof
:: ============================== FUNCTIONS ====================================
:log
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
goto:eof
:: ============================== 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 ====================================
:END
endlocal