parse_config_ini.bat #4

  • //
  • guest/
  • perforce_software/
  • sdp/
  • dev/
  • Server/
  • Windows/
  • p4/
  • common/
  • bin/
  • parse_config_ini.bat
  • View
  • Commits
  • Open Download .zip Download (2 KB)
:: ============================================================================
:: Copyright and license info is available in the LICENSE file included with
:: the Server Deployment Package (SDP), and also available online:
:: https://swarm.workshop.perforce.com/projects/perforce-software-sdp/view/main/LICENSE
:: ----------------------------------------------------------------------------

:: Parses the ini file
:: The name is hardcoded and expected to be ..\..\config\sdp_config.ini from the location of this .bat file!

@setlocal enableextensions enabledelayedexpansion
@echo off

if not x%~1==x (
    set SDP_INSTANCE=%~1
    goto CheckINI
)
if not x%SDP_INSTANCE%==x (
    goto CheckINI
)

@echo off
echo ERROR: Required SDP_INSTANCE value not defined (either as parameter or in environment).
echo .
exit /b 1

:CheckINI

set current_script_dir=%~p0
set ini_file=%current_script_dir%..\..\config\sdp_config.ini

if exist %ini_file% (
    goto :ParseINI
)

@echo off
echo ERROR: sdp_config.ini file doesn't exist (%ini_file%)
echo .
exit /b 1

:ParseINI

FOR /F "usebackq" %%i IN (`hostname`) DO SET HOSTNAME=%%i

:: Write a batch file to set the env variables - this filename can't be a variable because of endlocal later.
echo @echo off> _temp_set.bat

set area_found=0
set area=[%SDP_INSTANCE%:%hostname%]
set currarea=
for /f "usebackq delims=" %%a in ("!ini_file!") do (
    set ln=%%a
    if "x!ln:~0,1!"=="x[" (
        set currarea=!ln!
    ) else (
        if not "x!ln:~0,1!"=="x#" (
            for /f "tokens=1,2 delims==" %%b in ("!ln!") do (
                set currkey=%%b
                set currval=%%c
                if /i "x!area!"=="x!currarea!" (
                    set area_found=1
                    echo set !currkey!=!currval!>> _temp_set.bat
                )
            )
        )
    )
)
if %area_found% equ 0 (
    Echo Could not find configuration for instance/hostname %area%.
    Echo .
    Exit /b 1
)

endlocal
    
:: This must be done after the endlocal call above.
call _temp_set.bat

:exit
# Change User Description Committed
#5 27915 Robert Cowham Implement p4login.bat properly with powershell.
Fix to @27817
#review ttyler
#4 27817 C. Thomas Tyler Re-added Windows SDP files deleted in @26659.

#review @robert_cowham
#3 26659 Robert Cowham Removing out-of-date files and ancient utilities.
Updating SDP Guide for Windows with includes to various .ps1 scripts
Add new sync-replica.ps1 and call it from sync_replica.bat
#2 16029 C. Thomas Tyler Routine merge to dev from main using:
p4 merge -b perforce_software-sdp-dev
#1 10961 C. Thomas Tyler Merge down from main.
//guest/perforce_software/sdp/main/Server/Windows/p4/common/bin/parse_config_ini.bat
#1 10872 C. Thomas Tyler Added Windows SDP into The Workshop:
* Combined (back) into Unix SDP structure.
* Avoided adding duplicate files p4verify.pl, p4review.(py,cfg).
* Upgraded 'dist.sh' utility to produce both Unix and Windows
packages (*.tgz and *.zip), adjusting line endings on text
files to be appropriate for Windows prior to packaging.

To Do:
* Resolve duplication of [template_]configure_new_server.bat.
* Merge test suites for Windows and Unix into a cohesive set.