[128] | 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 HADOOP_FILE=hadoop-0.20.1.tar.gz |
---|
| 22 | set HADOOP_MIRROR=http://ftp.twaren.net/Unix/Web/apache/hadoop/core/hadoop-0.20.1/ |
---|
| 23 | set JDK_FILE=jdk1.6.0_18.zip |
---|
| 24 | set JDK_MIRROR=http://tsmc.classcloud.org/ |
---|
| 25 | set CYGWIN_ROOT=C:\hadoop4win |
---|
| 26 | set LOCAL_REPOSITORY=%cd% |
---|
| 27 | set CYGWIN_SETUP=%LOCAL_REPOSITORY%\cygwin_mirror\cyg-setup.exe |
---|
| 28 | set PATH=%PATH%;%cd%\bin |
---|
| 29 | |
---|
| 30 | set MY_PACKAGE=%LOCAL_REPOSITORY%\my_packages |
---|
| 31 | set HADOOP_SRC=%MY_PACKAGE%\hadoop\hadoop-*.gz |
---|
| 32 | set HADOOP_DES=%CYGWIN_ROOT%\usr\src |
---|
| 33 | set JDK_SRC=%MY_PACKAGE%\jdk\jdk*.zip |
---|
| 34 | set JDK_DES=%CYGWIN_ROOT%\usr\src |
---|
| 35 | |
---|
| 36 | REM - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
---|
| 37 | REM Assert that there exists a valid %LOCAL_REPOSITORY% directory. |
---|
| 38 | REM - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
---|
| 39 | |
---|
| 40 | IF NOT EXIST "%LOCAL_REPOSITORY%" ( |
---|
| 41 | echo "ERROR: %LOCAL_REPOSITORY% DON'T EXIST" |
---|
| 42 | exit /B 1 |
---|
| 43 | ) |
---|
| 44 | |
---|
| 45 | IF NOT EXIST "%LOCAL_REPOSITORY%\cygwin_mirror" ( |
---|
| 46 | echo "ERROR: %LOCAL_REPOSITORY%\cygwin_mirror DON'T EXIST" |
---|
| 47 | exit /B 1 |
---|
| 48 | ) |
---|
| 49 | |
---|
| 50 | IF NOT EXIST "%LOCAL_REPOSITORY%\cygwin_mirror\release" ( |
---|
| 51 | echo "ERROR: %LOCAL_REPOSITORY%\cygwin_mirror\release DON'T EXIST" |
---|
| 52 | exit /B 1 |
---|
| 53 | ) |
---|
| 54 | |
---|
| 55 | IF NOT EXIST "%LOCAL_REPOSITORY%\cygwin_mirror\setup.ini" ( |
---|
| 56 | echo "ERROR: %LOCAL_REPOSITORY%\cygwin_mirror\setup.ini DON'T EXIST" |
---|
| 57 | exit /B 1 |
---|
| 58 | ) |
---|
| 59 | |
---|
| 60 | IF NOT EXIST "%CYGWIN_SETUP%" ( |
---|
| 61 | echo "ERROR: %CYGWIN_SETUP% DON'T EXIST" |
---|
| 62 | exit /B 1 |
---|
| 63 | ) |
---|
| 64 | |
---|
| 65 | REM - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
---|
| 66 | REM Create a fake installation skeleton for Cygwin setup |
---|
| 67 | REM - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
---|
| 68 | IF NOT EXIST "%CYGWIN_ROOT%" ( |
---|
| 69 | mkdir "%CYGWIN_ROOT%" |
---|
| 70 | ) |
---|
| 71 | |
---|
| 72 | IF NOT EXIST "%CYGWIN_ROOT%\etc\setup" ( |
---|
| 73 | mkdir "%CYGWIN_ROOT%\etc\setup" |
---|
| 74 | ) ELSE ( |
---|
| 75 | del /Q "%CYGWIN_ROOT%\etc\setup\last-*" |
---|
| 76 | ) |
---|
| 77 | |
---|
| 78 | REM -- Note that last-* must *not* containing whitespace, e.g. " " etc. |
---|
| 79 | REM -- This is why there below is no space in front of ">". |
---|
| 80 | |
---|
| 81 | echo Install> "%CYGWIN_ROOT%\etc\setup\last-action" |
---|
| 82 | echo %LOCAL_REPOSITORY%> "%CYGWIN_ROOT%\etc\setup\last-cache" |
---|
| 83 | echo cygwin_mirror> "%CYGWIN_ROOT%\etc\setup\last-mirror" |
---|
| 84 | |
---|
| 85 | REM - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
---|
| 86 | REM Finally, run Cygwin setup quietly |
---|
| 87 | REM - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
---|
| 88 | |
---|
| 89 | echo To run %CYGWIN_SETUP% -q -d -L -l "%LOCAL_REPOSITORY%\cygwin_mirror" -R "%CYGWIN_ROOT%" |
---|
| 90 | |
---|
| 91 | REM real do cygwin installation |
---|
| 92 | |
---|
| 93 | "%CYGWIN_SETUP%" -q -d -L -l "%LOCAL_REPOSITORY%\cygwin_mirror" -R "%CYGWIN_ROOT%" |
---|
| 94 | |
---|
| 95 | REM - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
---|
| 96 | REM Installation of Hadoop and JDK |
---|
| 97 | REM - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
---|
| 98 | |
---|
| 99 | IF NOT EXIST "%HADOOP_SRC%" ( |
---|
| 100 | wget "%HADOOP_MIRROR%/%HADOOP_FILE%" -O "%MY_PACKAGE%\hadoop\%HADOOP_FILE%" |
---|
| 101 | ) |
---|
| 102 | |
---|
| 103 | IF NOT EXIST "%JDK_SRC%" ( |
---|
| 104 | wget "%JDK_MIRROR%/%JDK_FILE%" -O "%MY_PACKAGE%\jdk\%JDK_FILE%" |
---|
| 105 | ) |
---|
| 106 | |
---|
| 107 | IF NOT EXIST "%JDK_DES%" ( |
---|
| 108 | mkdir "%JDK_DES%" |
---|
| 109 | ) |
---|
| 110 | |
---|
| 111 | IF NOT EXIST "%CYGWIN_ROOT%\opt\hadoop" ( |
---|
| 112 | copy "%HADOOP_SRC%" "%HADOOP_DES%" |
---|
| 113 | ) |
---|
| 114 | |
---|
| 115 | IF NOT EXIST "%CYGWIN_ROOT%\lib\jvm" ( |
---|
| 116 | copy "%JDK_SRC%" "%JDK_DES%" |
---|
| 117 | ) |
---|
| 118 | |
---|
| 119 | copy /Y "%MY_PACKAGE%\hadoop\bin\*" "%CYGWIN_ROOT%\bin" |
---|
| 120 | xcopy /Y /E /I "%MY_PACKAGE%\hadoop\conf-examples" "%HADOOP_DES%\conf-examples" |
---|
| 121 | |
---|
| 122 | cls |
---|
| 123 | echo "=====================================================" |
---|
| 124 | echo " Please run `hadoop4win-init' to extract Hadoop and" |
---|
| 125 | echo " JDK to proper PATH. It will format HDFS Namenode, too." |
---|
| 126 | echo " ." |
---|
| 127 | echo " Use `start-hadoop' and `stop-hadoop' to run single" |
---|
| 128 | echo " machine hadoop configuration." |
---|
| 129 | echo " ." |
---|
| 130 | echo " Use `jps' to check java process for troubleshooting." |
---|
| 131 | echo "=====================================================" |
---|
| 132 | |
---|
| 133 | CALL "%CYGWIN_ROOT%\Cygwin.bat" |
---|