-
Notifications
You must be signed in to change notification settings - Fork 0
/
senv.bat
131 lines (120 loc) · 3.41 KB
/
senv.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
@echo off
set script=%~dp0%
set parent=%script: =,%
set parent=%parent:\= %
set parentdir=
set unixpath=
call :getparentdir %parent%
set parent=%parentdir:,= %
set unixpath=%unixpath%/b2d
rem echo script='%script%'
rem echo parentdir='%parentdir%'
rem echo parent='%parent%'
rem echo.unixpath='%unixpath%'
if not exist ..\env.bat (
echo Add %parent%\env.bat: (..\env.bat^)
echo See env.bat.template in %script%
echo In ..\env.bat, complete your %%PATH%% with Git, VirtualBox and Boot2Docker
exit /B 1
)
call "%parent%\env.bat"
set PATH=%PATH%;%script%
rem http://stackoverflow.com/a/7218493/6309: test substring
echo.%PATH%| findstr /C:"Boot2Docker" 1>nul
if %errorlevel% == 1 (
echo "Boot2Docker is not found in PATH: check your ..\env.bat"
exit /B 1
)
echo.%PATH%| findstr /C:"Git" 1>nul
if %errorlevel% == 1 (
echo "Git is not found in PATH: check your ..\env.bat"
exit /B 1
)
echo.%PATH%| findstr /C:"VirtualBox" 1>nul
if %errorlevel% == 1 (
echo "VirtualBox is not found in PATH: check your ..\env.bat"
exit /B 1
)
doskey vbm="VBoxManage.exe" $*
doskey vbmmt="VBoxManage.exe modifyvm \"boot2docker-vm\" natpf1 \"tcp-port$1,tcp,,$1,,$1\";"
doskey vbmmu="VBoxManage.exe modifyvm \"boot2docker-vm\" natpf1 \"udp-port$1,udp,,$1,,$1\";"
doskey vbmct="VBoxManage.exe controlvm \"boot2docker-vm\" natpf1 \"tcp-port$1,tcp,,$1,,$1\";"
doskey vbmcu="VBoxManage.exe controlvm \"boot2docker-vm\" natpf1 \"udp-port$1,udp,,$1,,$1\";"
doskey bd="boot2docker.exe" $*
set scriptd=%script:\=\\%
git -C %script% config filter.dffilter.smudge %scriptd%dfsmudge.sh
git -C %script% config filter.dffilter.clean %scriptd%dfclean.sh
cp -f %script%dfsmudge.sh.template %script%dfsmudge.sh
echo.%HTTP_PROXY%| findstr /C:"http" 1>nul
if %errorlevel% == 0 (
sed -i -e "s/#hasproxy#/1/g" dfsmudge.sh
sed -i -e "s;#http_proxy#;%HTTP_PROXY%;g" dfsmudge.sh
sed -i -e "s;#https_proxy#;%HTTPS_PROXY%;g" dfsmudge.sh
sed -i -e "s;#no_proxy#;%NO_PROXY%;g" dfsmudge.sh
)
sed -i -e "s;_unixpath_;%unixpath%;g" dfsmudge.sh
goto :eof
rem http://www.dostips.com/DtTutoFunctions.php#FunctionTutorial.ReturningValuesClassic
:getparentdir
setlocal enabledelayedexpansion
set P=%~1
rem echo 1='%P%'
rem echo getparentdir parentdir='%parentdir%'
rem echo getparentdir unixpath='%unixpath%'
if "!P!" EQU "" goto :eof
if "!P!" EQU "b2d" (
endlocal
set "parentdir=%parentdir%"
set "unixpath=%unixpath%"
goto :EOF
)
if not "%parentdir%" == "" (
set "parentdir=!parentdir!\!P!"
set "unixpath=!unixpath!/!P!"
rem echo notempty: parentdir='%parentdir%'
rem echo notempty: unixpath='%unixpath%'
)
rem echo between: parentdir='%parentdir%'
rem echo between: unixpath='%unixpath%'
if "%parentdir%" == "" (
set "parentdir=!P!"
set "unixpath=/!P!"
set "unixpath=!unixpath::=!"
call :lowercase unixpath
rem echo empty: parentdir='!parentdir!'
rem echo empty: unixpath='!unixpath!'
)
shift
( endlocal & REM.-- RETURN VALUES
set "parentdir=%parentdir%"
set "unixpath=%unixpath%"
)
rem echo shiftt: parentdir='%parentdir%'
rem echo shiftt: unixpath='%unixpath%'
goto getparentdir
:lowercase
set %~1=!%1:C=c!
set %~1=!%1:D=d!
set %~1=!%1:E=e!
set %~1=!%1:F=f!
set %~1=!%1:G=g!
set %~1=!%1:H=h!
set %~1=!%1:I=i!
set %~1=!%1:J=j!
set %~1=!%1:K=k!
set %~1=!%1:L=l!
set %~1=!%1:M=m!
set %~1=!%1:N=n!
set %~1=!%1:O=o!
set %~1=!%1:P=p!
set %~1=!%1:Q=q!
set %~1=!%1:R=r!
set %~1=!%1:S=s!
set %~1=!%1:T=t!
set %~1=!%1:U=u!
set %~1=!%1:V=v!
set %~1=!%1:W=w!
set %~1=!%1:X=w!
set %~1=!%1:Y=y!
set %~1=!%1:Z=z!
goto :eof