Changeset 189 for nutchez-0.2/src
- Timestamp:
- Jun 15, 2010, 9:59:12 AM (14 years ago)
- Location:
- nutchez-0.2/src/test
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
nutchez-0.2/src/test/client_install_func.sh
r188 r189 24 24 function choose_lang(){ 25 25 26 lang=$(locale | grep 'LANG=' | cut -d "=" -f2) 27 28 # Default: source english 29 . lang_en_US_client_install 30 # if locale is zh then source chinese 31 echo $lang | grep 'zh' && source lang_zh_TW_nutchez 32 33 # Ask language 26 34 echo -e "\n$choose_lang_1" 27 35 read -p "$choose_lang_2 " langChoice … … 77 85 # 目前先檢查是否有/opt/nutchez 這個資料夾即可 78 86 function check_nez_installed(){ 79 debug_info " chcheck_nez_installed"87 debug_info "$check_nez_1" 80 88 if [ -d /opt/nutchez ]; then 81 show_info " System already had NutchEz."82 exit 83 else 84 show_info " System does not has NutchEz."89 show_info "$check_nez_2" 90 exit 91 else 92 show_info "$check_nez_3" 85 93 fi 86 94 } … … 91 99 # (3)系統有安裝但Sun Java 在非預設路徑下 (4)以正確安裝 Sun JAVA 預設路徑下 92 100 function check_sunJava(){ 93 debug_info " check_sunJava"94 debug_info " NutchEz need Sun Java JDK 1.6.x or above version"101 debug_info "$check_sunJava_1" 102 debug_info "$check_sunJava_2" 95 103 96 104 javaPath="/usr" … … 104 112 105 113 if [ "$JAVA_org" == "" ]; then 106 show_info " Java is not Sun version, plz install sun Java 1.6.X"107 show_info " Please input your choice:"108 show_info " (1)System don't have Sun Java (2)Sun Java is in other path (3)Exit"109 read -p " plz input (1/2/3):" choice114 show_info "$check_sunJava_if_1" 115 show_info "$check_sunJava_if_2" 116 show_info "$check_sunJava_if_3" 117 read -p "$check_sunJava_if_4" choice 110 118 case $choice in 111 119 "1") 112 show_info " Please install Sun Java manually!"120 show_info "$check_sunJava_if_5" 113 121 exit 114 122 ;; 115 123 "2") 116 read -p " Input Sun Java home path(ex. '/usr/lib/jvm/java-6-sun-1.6.0.12' or using default '/usr' ):" javaPath124 read -p "$check_sunJava_if_6" javaPath 117 125 ;; 118 126 "*") … … 127 135 128 136 if [ "$JAVA_org" == "" ]; then 129 show_info " It is not Sun Java! Plz install Sun Java manually!"137 show_info "$check_sunJava_if_7" 130 138 exit 131 139 fi … … 135 143 large16=$(echo "$JAVA_version >= 1.6" | bc) 136 144 if [ "${large16}" == 0 ]; then 137 show_info " Java version is too old (it need 1.6.X above)"145 show_info "$check_sunJava_if_8" 138 146 exit 139 147 fi 140 148 141 show_info " System has Sun Java 1.6 above version."142 else 143 show_info " Please install Sun JAVA 1.6.X or above version"149 show_info "$check_sunJava_if_9" 150 else 151 show_info "$check_sunJava_if_10" 144 152 exit 145 153 fi … … 152 160 # 檢查是否有安裝openssh, openssh-server 153 161 function check_ssh(){ 154 debug_info " check_ssh"162 debug_info "$check_ssh_1" 155 163 if [ -e /usr/bin/ssh ]; then 156 show_info " System has ssh."157 else 158 show_info " Please install ssh."164 show_info "$check_ssh_2" 165 else 166 show_info "$check_ssh_3" 159 167 exit 160 168 fi 161 169 162 170 if [ -e /usr/sbin/sshd ]; then 163 show_info " System has ssh Server (sshd)."164 else 165 show_info " Please install ssh Server (sshd)."171 show_info "$check_ssh_4" 172 else 173 show_info "$check_ssh_5" 166 174 exit 167 175 fi … … 171 179 # 檢查是否有安裝dialog 172 180 function check_dialog(){ 173 debug_info " check_dialog"181 debug_info "$check_dialog_1" 174 182 if [ -e /usr/bin/dialog ]; then 175 show_info " System has dialog."176 else 177 show_info " Please install dialog."183 show_info "$check_dialog_2" 184 else 185 show_info "$check_dialog_3" 178 186 exit 179 187 fi … … 185 193 # 此步驟若無法連到 master 則跳出 186 194 function scp_master_nutchuser_sshkey(){ 187 debug_info " scp_master_nutchuser_sshkey"188 debug_info " mkdir -p /home/nutchuser/"195 debug_info "$scp_sshkey_d1" 196 debug_info "$scp_sshkey_d2" 189 197 mkdir -p /home/nutchuser/.ssh/ 190 198 rm -fr /home/nutchuser/.ssh/* 191 199 unset Nutchuser_Passwd2 192 200 193 debug_info " scp nutchuser@$1:~/.ssh /home/nutchuser/"201 debug_info "$scp_sshkey_d3" 194 202 expect -c "spawn scp -r -o StrictHostKeyChecking=no nutchuser@$1:~/.ssh /home/nutchuser/ 195 203 expect \"*: \" { send \"$Nutchuser_Passwd\r\" } 196 expect \"*: \" { send_user \" Password is error\" }204 expect \"*: \" { send_user \"$scp_sshkey_expect_1\" } 197 205 expect eof" 198 206 199 207 if [ -e "/home/nutchuser/.ssh/authorized_keys" ]; then 200 show_info " scp correct."208 show_info "$scp_sshkey_s1" 201 209 else 202 show_info " scp error,\n(1)plese check nutchuser password in server\n(2)nutchuser's authorized_keys in server\n(3)server's network status"210 show_info "$scp_sshkey_s2" 203 211 exit 204 212 fi 205 213 ssh-add /home/nutchuser/.ssh/id_rsa 206 debug_info " chown -R nutchuser:nutchuser /home/nutchuser/.ssh"214 debug_info "$scp_sshkey_d4" 207 215 chown -R nutchuser:nutchuser /home/nutchuser/.ssh 208 216 } … … 210 218 # 新增nutchuser 帳號時用 Nutchuser_Passwd 當密碼 211 219 function creat_nutchuser_account(){ 212 debug_info " creat_nutchuser_account"220 debug_info "$create_nutchuser_d1" 213 221 while [ "$Nutchuser_Passwd" != "$Nutchuser_Passwd2" ] 214 222 do 215 223 echo -e "\n" 216 read -sp " Plz input nutchuser password of master node:" Nutchuser_Passwd224 read -sp "$create_nutchuser_1" Nutchuser_Passwd 217 225 echo 218 read -sp " plz input nutchuser password, again:" Nutchuser_Passwd2226 read -sp "$create_nutchuser_2" Nutchuser_Passwd2 219 227 echo 220 228 if [ "$Nutchuser_Passwd" == "$Nutchuser_Passwd2" ]; then 221 show_info " Two Passwords match."229 show_info "$create_nutchuser_3" 222 230 else 223 show_info " Two passwords don't match, please re-input nutchuser's password."231 show_info "$create_nutchuser_4" 224 232 fi 225 233 done … … 227 235 228 236 if [ $(cat /etc/passwd | grep nutchuser) ]; then 229 show_info " System already has nutchuser, change nutchuser password."237 show_info "$create_nutchuser_s1" 230 238 expect -c "spawn passwd nutchuser 231 239 set timeout 1 … … 236 244 expect eof" 237 245 else 238 show_info " Create nutchuser and change password."246 show_info "$create_nutchuser_s2" 239 247 useradd -m nutchuser -s /bin/bash 240 248 expect -c "spawn passwd nutchuser … … 251 259 # 目前僅需做到能無礙的複製遠端的/opt/nutchez/到local的/opt/ 252 260 function scp_packages(){ 253 debug_info " scp_packages"261 debug_info "$scp_packages_d1" 254 262 mkdir /opt/nutchez 255 263 mkdir /var/nutchez … … 258 266 mkdir /home/nutchuser/nutchez/system 259 267 chmod 777 /opt/nutchez 260 debug_info " chown -R nutchuser:nutchuser /opt/nutchez"268 debug_info "$scp_packages_d2" 261 269 chown -R nutchuser:nutchuser /opt/nutchez 262 270 chown -R nutchuser:nutchuser /var/nutchez 263 271 chown -R nutchuser:nutchuser /home/nutchuser/nutchez 264 272 chmod 755 /opt/nutchez 265 debug_info " scp -r nutchuser@$1:/opt/nutchez/NutchezForClientOf_$Master_IP_Address.tar.gz /home/nutchuser/nutchez/source"273 debug_info "$scp_packages_d3" 266 274 su nutchuser -c "scp -r -o StrictHostKeyChecking=no nutchuser@$1:/home/nutchuser/nutchez/source/NutchezForClientOf_$Master_IP_Address.tar.gz /home/nutchuser/nutchez/source" 267 275 … … 270 278 271 279 function install_nutch_package(){ 272 debug_info " install_nutch_package"280 debug_info "$install_nutch_package_d1" 273 281 tar -zxvf /home/nutchuser/nutchez/source/NutchezForClientOf_$Master_IP_Address.tar.gz -C /opt/nutchez 274 282 sed -i '1a '$Master_IP_Address' '$Master_Hostname'' /etc/hosts … … 278 286 279 287 function recall_hostname_ip(){ 280 debug_info " recall_hostname_ip"288 debug_info "$recall_hostname_ip_d1" 281 289 net_interfaces=$(ifconfig | grep ^eth | cut -d " " -f1) 282 290 net_nu=$(echo $net_interfaces | wc -w) … … 286 294 net_address=$(ifconfig $net_interfaces | grep "inet addr:" | sed 's/^.*inet addr://g' | cut -d " " -f1) 287 295 net_MacAddr=$(ifconfig $net_interfaces | grep 'HW' | sed 's/^.*HWaddr //g') 288 show_info " net_address is$net_address"289 show_info " net_MacAddr is$net_MacAddr"296 show_info "$recall_hostname_ip_1 $net_address" 297 show_info "$recall_hostname_ip_2 $net_MacAddr" 290 298 291 299 # 若有多個 eth 時 292 300 else 293 301 declare -i i=1 294 show_info " System have multiple network device, which network use for this machine:"302 show_info "$recall_hostname_ip_3" 295 303 296 304 for net in $net_interfaces … … 300 308 done 301 309 302 read -p " Please choice(1/2/3...):" net_choice310 read -p "$recall_hostname_ip_4" net_choice 303 311 if [ -z $net_choice ]; then 304 312 net_choice=1 … … 310 318 net_address=$(ifconfig $net_interface | grep "inet addr:" | sed 's/^.*inet addr://g' | cut -d " " -f1) 311 319 net_MacAddr=$(ifconfig $net_interface | grep 'HW' | sed 's/^.*HWaddr //g') 312 show_info " net_address is$net_address"313 show_info " net_MacAddr is$net_MacAddr"314 fi 315 316 debug_info " ssh nutchuser@$1 echo $net_address $(hostname) $net_MacAddr \>\> ~/nutchez/system/nutch_nodes"320 show_info "$recall_hostname_ip_1 $net_address" 321 show_info "$recall_hostname_ip_2 $net_MacAddr" 322 fi 323 324 debug_info "$recall_hostname_ip_d2" 317 325 su nutchuser -c "ssh nutchuser@$1 echo $net_address $(hostname) $net_MacAddr \>\> ~/nutchez/system/nutch_nodes" 318 326 -
nutchez-0.2/src/test/lang_en_US_client_install
r188 r189 36 36 37 37 ### [for check_nez_installed()] ### 38 check_nez_1="chcheck_nez_installed" 39 check_nez_2="System already had NutchEz." 40 check_nez_3="System does not has NutchEz." 38 41 39 42 ### [for check_sunJava()] ### 43 check_sunJava_1="check_sunJava" 44 check_sunJava_2="NutchEz need Sun Java JDK 1.6.x or above version" 45 check_sunJava_if_1="Java is not Sun version, plz install sun Java 1.6.X" 46 check_sunJava_if_2="Please input your choice: " 47 check_sunJava_if_3="(1)System don't have Sun Java (2)Sun Java is in other path (3)Exit" 48 check_sunJava_if_4="plz input (1/2/3): " 49 check_sunJava_if_5="Please install Sun Java manually!" 50 check_sunJava_if_6="Input Sun Java home path(ex. '/usr/lib/jvm/java-6-sun-1.6.0.12' or using default '/usr' ): " 51 check_sunJava_if_7="It is not Sun Java! Plz install Sun Java manually !" 52 check_sunJava_if_8="Java version is too old (it need 1.6.X above)" 53 check_sunJava_if_9="System has Sun Java 1.6 above version." 54 check_sunJava_if_10="Please install Sun JAVA 1.6.X or above version" 40 55 41 56 ### [for check_ssh()] ### 57 check_ssh_1="check_ssh" 58 check_ssh_2="System has ssh." 59 check_ssh_3="Please install ssh." 60 check_ssh_4="System has ssh Server (sshd)." 61 check_ssh_5="Please install ssh Server (sshd)." 42 62 43 63 ### [for check_dialog()] ### 64 check_dialog_1="check_dialog" 65 check_dialog_2="System has dialog." 66 check_dialog_3="Please install dialog." 67 68 ### scp_master_nutchuser_sshkey() ### 69 scp_sshkey_d1="scp_master_nutchuser_sshkey" 70 scp_sshkey_d2="mkdir -p /home/nutchuser/" 71 scp_sshkey_d3="scp nutchuser@master:~/.ssh /home/nutchuser/" 72 scp_sshkey_expect_1="Password is error" 73 scp_sshkey_s1="scp correct." 74 scp_sshkey_s2="scp error,\n(1)plese check nutchuser password in server\n(2)nutchuser's authorized_keys in server\n(3)server's network status" 75 scp_sshkey_d4="chown -R nutchuser:nutchuser /home/nutchuser/.ssh" 44 76 45 77 ### [for creat_nutchuser_account()] ### 78 create_nutchuser_d1="creat_nutchuser_account" 79 create_nutchuser_1="Plz input nutchuser password of master node: " 80 create_nutchuser_2="plz input nutchuser password, again: " 81 create_nutchuser_3="Two Passwords match." 82 create_nutchuser_4="Two passwords don't match, please re-input nutchuser's password." 83 create_nutchuser_s1="System already has nutchuser, change nutchuser password." 84 create_nutchuser_s2="Create nutchuser and change password." 85 46 86 ### [for scp_packages()] ### 87 scp_packages_d1="scp_packages" 88 scp_packages_d2="chown -R nutchuser:nutchuser /opt/nutchez" 89 scp_packages_d3="scp -r nutchuser@\$1:/opt/nutchez/NutchezForClientOf_\$Master_IP_Address.tar.gz /home/nutchuser/nutchez/source" 90 47 91 ### [for install_nutch_package()] ### 92 install_nutch_package_d1="install_nutch_package" 93 48 94 ### [for recall_hostname_ip()] ### 95 recall_hostname_ip_d1="recall_hostname_ip" 96 recall_hostname_ip_1="net_address is" 97 recall_hostname_ip_2="net_MacAddr is" 98 recall_hostname_ip_3="System have multiple network device, which network use for this machine: " 99 recall_hostname_ip_4="Please choice(1/2/3...): " 100 recall_hostname_ip_d2="ssh nutchuser@\$1 echo \$net_address \$(hostname) \$net_MacAddr \>\> ~/nutchez/system/nutch_nodes" 49 101
Note: See TracChangeset
for help on using the changeset viewer.