antony@notes:~/misc$ cat "CNT.2022.v4.md"
CNT.2022.v4
CNT.2022.v4
dt.bat 內容
@echo off
set RSDTA1='displayName = \"DT Admin\"', 'displayName = \"ALP.DTA1.3\"'
set RSDTM1='displayName = \"ALP\"', 'displayName = \"ALP.DTM1.4\"'
set RSDTM2='displayName = \"ALP\"', 'displayName = \"ALP.DTM2.5\"'
set RSDTW1='displayName = \"ALP\"', 'displayName = \"ALP.DTW1.6\"'
set RSDTW2='displayName = \"ALP\"', 'displayName = \"ALP.DTW2.7\"'
set RSDTW3='displayName = \"ALP\"', 'displayName = \"ALP.DTW3.8\"'
powershell -Command "(Get-CimInstance Win32_PhysicalMemory | Measure-Object -Property capacity -Sum).sum /8Mb" > max.txt
powershell -Command "(Get-CimInstance Win32_PhysicalMemory | Measure-Object -Property capacity -Sum).sum /16Mb" > min.txt
set /P MAX=<max.txt
set /P MIN=<min.txt
set /A MAXS="%MAX%" > nul
set /A MINS="%MIN%+1024" > nul
set RSMMAX='memsize = \"2048\"', 'memsize = \"%MAXS%\"'
set RSMMIN='memsize = \"2048\"', 'memsize = \"%MINS%\"'
set RSADR1='ethernet0.generatedAddressOffset = \"0\"'
set RSADR2='ethernet0.addressType = \"generated\"' , 'ethernet0.addressType = \"static\"'
set RSMAC3='ethernet0.generatedAddress = \"00:0c:29:.*\"' , 'ethernet0.address = \"00:50:56:cd:00:03\"'
set RSMAC4='ethernet0.generatedAddress = \"00:0c:29:.*\"' , 'ethernet0.address = \"00:50:56:cd:00:04\"'
set RSMAC5='ethernet0.generatedAddress = \"00:0c:29:.*\"' , 'ethernet0.address = \"00:50:56:cd:00:05\"'
set RSMAC6='ethernet0.generatedAddress = \"00:0c:29:.*\"' , 'ethernet0.address = \"00:50:56:cd:00:06\"'
set RSMAC7='ethernet0.generatedAddress = \"00:0c:29:.*\"' , 'ethernet0.address = \"00:50:56:cd:00:07\"'
set RSMAC8='ethernet0.generatedAddress = \"00:0C:29:.*\"' , 'ethernet0.address = \"00:50:56:cd:00:08\"'
2>NUL CALL :CASE_%1 # jump to :CASE_create, :CASE_start, etc.
goto:eof
:CASE_create
if not exist DT\ (
mkdir DT > nul
if %ERRORLEVEL% == 0 (
mkdir DT\alp.dta1 > nul
xcopy /E /Y ALP.DT.ADM DT\alp.dta1\ > nul
powershell -Command "(gc DT\alp.dta1\alpine64.vmwarevm\alpine64.vmx) -replace "%RSDTA1%" -replace "%RSMAC3%" -replace "%RSMMIN%" -replace "%RSADR1%" -replace "%RSADR2%" | Out-File -Encoding "UTF8" vm.temp"
del /Q DT\alp.dta1\alpine64.vmwarevm\alpine64.vmx
copy /Y vm.temp DT\alp.dta1\alpine64.vmwarevm\alpine64.vmx > nul
if %ERRORLEVEL% == 0 echo "DT\alp.dta1\ (%MINS%MB) ok"
mkdir DT\alp.dtm1 > nul
xcopy /E /Y ALP3 DT\alp.dtm1\ > nul
powershell -Command "(gc DT\alp.dtm1\alpine64.vmwarevm\alpine64.vmx) -replace "%RSDTM1%" -replace "%RSMAC4%" -replace "%RSMMIN%" -replace "%RSADR1%" -replace "%RSADR2%" | Out-File -Encoding "UTF8" vm.temp"
del /Q DT\alp.dtm1\alpine64.vmwarevm\alpine64.vmx
copy /Y vm.temp DT\alp.dtm1\alpine64.vmwarevm\alpine64.vmx > nul
if %ERRORLEVEL% == 0 echo "DT\alp.dtm1\ (%MINS%MB) ok"
mkdir DT\alp.dtm2 > nul
xcopy /E /Y ALP3 DT\alp.dtm2\ > nul
powershell -Command "(gc DT\alp.dtm2\alpine64.vmwarevm\alpine64.vmx) -replace "%RSDTM2%" -replace "%RSMAC5%" -replace "%RSMMIN%" -replace "%RSADR1%" -replace "%RSADR2%" | Out-File -Encoding "UTF8" vm.temp"
del /Q DT\alp.dtm2\alpine64.vmwarevm\alpine64.vmx
copy /Y vm.temp DT\alp.dtm2\alpine64.vmwarevm\alpine64.vmx > nul
if %ERRORLEVEL% == 0 echo "DT\alp.dtm2\ (%MINS%MB) ok"
mkdir DT\alp.dtw1 > nul
xcopy /E /Y ALP3 DT\alp.dtw1\ > nul
powershell -Command "(gc DT\alp.dtw1\alpine64.vmwarevm\alpine64.vmx) -replace "%RSDTW1%" -replace "%RSMAC6%" -replace "%RSMMAX%" -replace "%RSADR1%" -replace "%RSADR2%" | Out-File -Encoding "UTF8" vm.temp"
del /Q DT\alp.dtw1\alpine64.vmwarevm\alpine64.vmx
copy /Y vm.temp DT\alp.dtw1\alpine64.vmwarevm\alpine64.vmx > nul
if %ERRORLEVEL% == 0 echo "DT\alp.dtw1\ (%MAXS%MB) ok"
mkdir DT\alp.dtw2 > nul
xcopy /E /Y ALP3 DT\alp.dtw2\ > nul
powershell -Command "(gc DT\alp.dtw2\alpine64.vmwarevm\alpine64.vmx) -replace "%RSDTW2%" -replace "%RSMAC7%" -replace "%RSMMAX%" -replace "%RSADR1%" -replace "%RSADR2%" | Out-File -Encoding "UTF8" vm.temp"
del /Q DT\alp.dtw2\alpine64.vmwarevm\alpine64.vmx
copy /Y vm.temp DT\alp.dtw2\alpine64.vmwarevm\alpine64.vmx > nul
if %ERRORLEVEL% == 0 echo "DT\alp.dtw2\ (%MAXS%MB) ok"
mkdir DT\alp.dtw3 > nul
xcopy /E /Y ALP3 DT\alp.dtw3\ > nul
powershell -Command "(gc DT\alp.dtw3\alpine64.vmwarevm\alpine64.vmx) -replace "%RSDTW3%" -replace "%RSMAC8%" -replace "%RSMMAX%" -replace "%RSADR1%" -replace "%RSADR2%" | Out-File -Encoding "UTF8" vm.temp"
del /Q DT\alp.dtw3\alpine64.vmwarevm\alpine64.vmx
copy /Y vm.temp DT\alp.dtw3\alpine64.vmwarevm\alpine64.vmx > nul
if %ERRORLEVEL% == 0 echo "DT\alp.dtw3\ (%MAXS%MB) ok"
del *.txt > nul
del vm.temp > nul
)
) else (
echo "DT\ exist"
)
GOTO:eof
:CASE_start
if not exist DT\ GOTO:eof
"C:\Program Files (x86)\VMware\VMware Player\vmrun" list | findstr DT\\alp.dtw3 > nul
if %ERRORLEVEL% == 1 (
"C:\Program Files (x86)\VMware\VMware Player\vmrun" start "DT\ALP.DTA1\alpine64.vmwarevm\alpine64.vmx" >nul
timeout /t 15 > nul
"C:\Program Files (x86)\VMware\VMware Player\vmrun" start "DT\ALP.DTM1\alpine64.vmwarevm\alpine64.vmx" > nul
timeout /t 15 > nul
"C:\Program Files (x86)\VMware\VMware Player\vmrun" start "DT\ALP.DTM2\alpine64.vmwarevm\alpine64.vmx" > nul
timeout /t 15 > nul
"C:\Program Files (x86)\VMware\VMware Player\vmrun" start "DT\ALP.DTW1\alpine64.vmwarevm\alpine64.vmx" > nul
timeout /t 15 > nul
"C:\Program Files (x86)\VMware\VMware Player\vmrun" start "DT\ALP.DTW2\alpine64.vmwarevm\alpine64.vmx" > nul
timeout /t 15 > nul
"C:\Program Files (x86)\VMware\VMware Player\vmrun" start "DT\ALP.DTW3\alpine64.vmwarevm\alpine64.vmx" > nul
timeout /t 15 > nul
)
GOTO:eof
:CASE_stop
if not exist DT\ GOTO:eof
"C:\Program Files (x86)\VMware\VMware Player\vmrun" list | findstr DT\\alp.dtw3 > nul
if %ERRORLEVEL% == 0 (
"C:\Program Files (x86)\VMware\VMware Player\vmrun" stop "DT\ALP.DTA1\alpine64.vmwarevm\alpine64.vmx" > nul
timeout /t 15 > nul
"C:\Program Files (x86)\VMware\VMware Player\vmrun" stop "DT\ALP.DTM1\alpine64.vmwarevm\alpine64.vmx" > nul
timeout /t 15 > nul
"C:\Program Files (x86)\VMware\VMware Player\vmrun" stop "DT\ALP.DTM2\alpine64.vmwarevm\alpine64.vmx" > nul
timeout /t 15 > nul
"C:\Program Files (x86)\VMware\VMware Player\vmrun" stop "DT\ALP.DTW1\alpine64.vmwarevm\alpine64.vmx" > nul
timeout /t 15 > nul
"C:\Program Files (x86)\VMware\VMware Player\vmrun" stop "DT\ALP.DTW2\alpine64.vmwarevm\alpine64.vmx" > nul
timeout /t 15 > nul
"C:\Program Files (x86)\VMware\VMware Player\vmrun" stop "DT\ALP.DTW3\alpine64.vmwarevm\alpine64.vmx" > nul
timeout /t 15 > nul
)
GOTO:eof
:CASE_delete
if not exist DT\ GOTO:eof
"C:\Program Files (x86)\VMware\VMware Player\vmrun" list | findstr DT\\alp.dtw3 > nul
if %ERRORLEVEL% == 0 (
echo "pls stop dt first"
goto:eof
)
if exist DT\ (
rd /S /Q DT
)
GOTO:eof
:CASE_list
if exist DT\ (
echo [DT\]
dir /B dt
echo [VM runnig]
"C:\Program Files (x86)\VMware\VMware Player\vmrun" list | findstr DT\\
)
goto:eof
:CASE_
echo "dt [create|start|stop|delete|list]"
goto:eof