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