1 | @echo off |
---|
2 | |
---|
3 | REM #################################################################### |
---|
4 | REM # Unattended hadoop for windows installation |
---|
5 | REM # |
---|
6 | REM # License : GPL |
---|
7 | REM # Author : Jazz Yao-Tsung Wang <jazz@nchc.org.tw> |
---|
8 | REM # Last update : $Date$ |
---|
9 | REM # Version : $Rev$ |
---|
10 | REM # |
---|
11 | REM # Usage: hadoop4win-setup.bat |
---|
12 | REM # |
---|
13 | REM # References: |
---|
14 | REM # [1] Henrik Bengtsson, Unattended Cygwin Installation, June 2, 2004. |
---|
15 | REM # http://www.maths.lth.se/help/windows/cygwin/ |
---|
16 | REM # [2] DRBL-WinRoll |
---|
17 | REM # http://drbl.nchc.org.tw/drbl-winroll |
---|
18 | REM # This script is modified from winroll-setup.bat |
---|
19 | REM #################################################################### |
---|
20 | |
---|
21 | set JDK_FILE=jdk1.6.0_18.zip |
---|
22 | set ANT_FILE=ant-current-bin.zip |
---|
23 | set HBASE_FILE=hbase-0.20.6.tar.gz |
---|
24 | set HADOOP_FILE=hadoop-0.20.2.tar.gz |
---|
25 | set JDK_MIRROR=http://www.classcloud.org/hadoop4win |
---|
26 | set ANT_MIRROR=http://ftp.twaren.net/Unix/Web/apache/ant/ |
---|
27 | set HBASE_MIRROR=http://ftp.twaren.net/Unix/Web/apache/hbase/hbase-0.20.6/ |
---|
28 | set HADOOP_MIRROR=http://ftp.twaren.net/Unix/Web/apache/hadoop/core/hadoop-0.20.2 |
---|
29 | set CYGWIN_ROOT=C:\hadoop4win |
---|
30 | set LOCAL_REPOSITORY=%cd% |
---|
31 | set CYGWIN_SETUP=%LOCAL_REPOSITORY%\cygwin_mirror\cyg-setup.exe |
---|
32 | set OLDPATH=%PATH% |
---|
33 | set PATH=%PATH%;%cd%\bin |
---|
34 | set CYGWIN=nodosfilewarning |
---|
35 | |
---|
36 | set MY_PACKAGE=%LOCAL_REPOSITORY%\my_packages |
---|
37 | set ANT_SRC=%MY_PACKAGE%\ant\%ANT_FILE% |
---|
38 | set ANT_DES=%CYGWIN_ROOT%\usr\src |
---|
39 | set JDK_SRC=%MY_PACKAGE%\jdk\%JDK_FILE% |
---|
40 | set JDK_DES=%CYGWIN_ROOT%\usr\src |
---|
41 | set HBASE_SRC=%MY_PACKAGE%\hbase\%HBASE_FILE% |
---|
42 | set HBASE_DES=%CYGWIN_ROOT%\usr\src |
---|
43 | set HADOOP_SRC=%MY_PACKAGE%\hadoop\%HADOOP_FILE% |
---|
44 | set HADOOP_DES=%CYGWIN_ROOT%\usr\src |
---|
45 | |
---|
46 | REM - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
---|
47 | REM Assert that there exists a valid %LOCAL_REPOSITORY% directory. |
---|
48 | REM - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
---|
49 | |
---|
50 | IF NOT EXIST "%LOCAL_REPOSITORY%" ( |
---|
51 | echo "ERROR: %LOCAL_REPOSITORY% DON'T EXIST" |
---|
52 | exit /B 1 |
---|
53 | ) |
---|
54 | |
---|
55 | IF NOT EXIST "%LOCAL_REPOSITORY%\cygwin_mirror" ( |
---|
56 | echo "ERROR: %LOCAL_REPOSITORY%\cygwin_mirror DON'T EXIST" |
---|
57 | exit /B 1 |
---|
58 | ) |
---|
59 | |
---|
60 | IF NOT EXIST "%LOCAL_REPOSITORY%\cygwin_mirror\release" ( |
---|
61 | echo "ERROR: %LOCAL_REPOSITORY%\cygwin_mirror\release DON'T EXIST" |
---|
62 | exit /B 1 |
---|
63 | ) |
---|
64 | |
---|
65 | IF NOT EXIST "%LOCAL_REPOSITORY%\cygwin_mirror\setup.ini" ( |
---|
66 | echo "ERROR: %LOCAL_REPOSITORY%\cygwin_mirror\setup.ini DON'T EXIST" |
---|
67 | exit /B 1 |
---|
68 | ) |
---|
69 | |
---|
70 | IF NOT EXIST "%CYGWIN_SETUP%" ( |
---|
71 | echo "ERROR: %CYGWIN_SETUP% DON'T EXIST" |
---|
72 | exit /B 1 |
---|
73 | ) |
---|
74 | |
---|
75 | REM - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
---|
76 | REM Create a fake installation skeleton for Cygwin setup |
---|
77 | REM - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
---|
78 | IF NOT EXIST "%CYGWIN_ROOT%" ( |
---|
79 | mkdir "%CYGWIN_ROOT%" |
---|
80 | ) |
---|
81 | |
---|
82 | IF NOT EXIST "%CYGWIN_ROOT%\etc\setup" ( |
---|
83 | mkdir "%CYGWIN_ROOT%\etc\setup" |
---|
84 | ) ELSE ( |
---|
85 | del /Q "%CYGWIN_ROOT%\etc\setup\last-*" |
---|
86 | ) |
---|
87 | |
---|
88 | REM -- Note that last-* must *not* containing whitespace, e.g. " " etc. |
---|
89 | REM -- This is why there below is no space in front of ">". |
---|
90 | |
---|
91 | echo Install > "%CYGWIN_ROOT%\etc\setup\last-action" |
---|
92 | echo %LOCAL_REPOSITORY% > "%CYGWIN_ROOT%\etc\setup\last-cache" |
---|
93 | echo cygwin_mirror > "%CYGWIN_ROOT%\etc\setup\last-mirror" |
---|
94 | echo "" > "%CYGWIN_ROOT%\etc\setup\setup.rc" |
---|
95 | echo "" > "%CYGWIN_ROOT%\etc\setup\net-method" |
---|
96 | echo "" > "%CYGWIN_ROOT%\etc\setup\net-proxy-host" |
---|
97 | echo "" > "%CYGWIN_ROOT%\etc\setup\net-proxy-port" |
---|
98 | echo "" > "%CYGWIN_ROOT%\etc\setup\extrakeys" |
---|
99 | echo "" > "%CYGWIN_ROOT%\etc\setup\chooser_window_settings" |
---|
100 | echo "" > "%CYGWIN_ROOT%\etc\setup\installed.db" |
---|
101 | echo "" > "%CYGWIN_ROOT%\etc\setup\timestamp" |
---|
102 | |
---|
103 | REM - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
---|
104 | REM Finally, run Cygwin setup quietly |
---|
105 | REM - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
---|
106 | |
---|
107 | echo To run %CYGWIN_SETUP% -q -d -L -l "%LOCAL_REPOSITORY%\cygwin_mirror" -R "%CYGWIN_ROOT%" |
---|
108 | |
---|
109 | REM real do cygwin installation |
---|
110 | |
---|
111 | "%CYGWIN_SETUP%" -q -d -L -l "%LOCAL_REPOSITORY%\cygwin_mirror" -R "%CYGWIN_ROOT%" |
---|
112 | REM "%CYGWIN_SETUP%" -q -d -L -l "%LOCAL_REPOSITORY%\cygwin_mirror" -R "%CYGWIN_ROOT%" -P cygrunsrv,file,openssh,perl,procps,ncurses,rsync,sharutils,shutdown,subversion,tcp_wrappers,termcap,unzip,wget,zip,zlib |
---|
113 | |
---|
114 | REM - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
---|
115 | REM Installation of Hadoop and JDK |
---|
116 | REM - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
---|
117 | |
---|
118 | IF NOT EXIST "%JDK_SRC%" ( |
---|
119 | wget "%JDK_MIRROR%/%JDK_FILE%" -O "%MY_PACKAGE%\jdk\%JDK_FILE%" |
---|
120 | ) |
---|
121 | |
---|
122 | IF NOT EXIST "%ANT_SRC%" ( |
---|
123 | wget "%ANT_MIRROR%/%ANT_FILE%" -O "%MY_PACKAGE%\ant\%ANT_FILE%" |
---|
124 | ) |
---|
125 | |
---|
126 | IF NOT EXIST "%HBASE_SRC%" ( |
---|
127 | wget "%HBASE_MIRROR%/%HBASE_FILE%" -O "%MY_PACKAGE%\hbase\%HBASE_FILE%" |
---|
128 | ) |
---|
129 | |
---|
130 | IF NOT EXIST "%HADOOP_SRC%" ( |
---|
131 | wget "%HADOOP_MIRROR%/%HADOOP_FILE%" -O "%MY_PACKAGE%\hadoop\%HADOOP_FILE%" |
---|
132 | ) |
---|
133 | |
---|
134 | IF NOT EXIST "%JDK_DES%" ( |
---|
135 | mkdir "%JDK_DES%" |
---|
136 | ) |
---|
137 | |
---|
138 | IF NOT EXIST "%ANT_DES%" ( |
---|
139 | mkdir "%ANT_DES%" |
---|
140 | ) |
---|
141 | |
---|
142 | IF NOT EXIST "%HBASE_DES%" ( |
---|
143 | mkdir "%HBASE_DES%" |
---|
144 | ) |
---|
145 | |
---|
146 | IF NOT EXIST "%HADOOP_DES%" ( |
---|
147 | mkdir "%HADOOP_DES%" |
---|
148 | ) |
---|
149 | |
---|
150 | IF NOT EXIST "%CYGWIN_ROOT%\lib\jvm" ( |
---|
151 | copy "%JDK_SRC%" "%JDK_DES%" |
---|
152 | ) |
---|
153 | |
---|
154 | IF NOT EXIST "%CYGWIN_ROOT%\opt\ant" ( |
---|
155 | copy "%ANT_SRC%" "%ANT_DES%" |
---|
156 | ) |
---|
157 | |
---|
158 | IF NOT EXIST "%CYGWIN_ROOT%\opt\hbase" ( |
---|
159 | copy "%HBASE_SRC%" "%HBASE_DES%" |
---|
160 | ) |
---|
161 | |
---|
162 | IF NOT EXIST "%CYGWIN_ROOT%\opt\hadoop" ( |
---|
163 | copy "%HADOOP_SRC%" "%HADOOP_DES%" |
---|
164 | ) |
---|
165 | |
---|
166 | copy /Y "%MY_PACKAGE%\ant\bin\*" "%CYGWIN_ROOT%\bin" |
---|
167 | copy /Y "%MY_PACKAGE%\hbase\bin\*" "%CYGWIN_ROOT%\bin" |
---|
168 | copy /Y "%MY_PACKAGE%\hadoop\bin\*" "%CYGWIN_ROOT%\bin" |
---|
169 | xcopy /Y /E /I "%MY_PACKAGE%\hadoop\conf-examples" "%HADOOP_DES%\conf-examples" |
---|
170 | |
---|
171 | cls |
---|
172 | echo "=====================================================" |
---|
173 | echo " run `hadoop4win-init' to extract Hadoop and JDK to " |
---|
174 | echo " proper PATH. It will format HDFS Namenode, too." |
---|
175 | echo "=====================================================" |
---|
176 | %CYGWIN_ROOT%\bin\bash --login -c "/bin/hadoop4win-init" |
---|
177 | %CYGWIN_ROOT%\bin\bash --login -c "/bin/hbase-init" |
---|
178 | %CYGWIN_ROOT%\bin\bash --login -c "/bin/ant-init" |
---|
179 | cls |
---|
180 | set PATH=%OLDPATH% |
---|
181 | CALL "%CYGWIN_ROOT%\Cygwin.bat" |
---|