| [117] | 1 | #!/bin/bash |
|---|
| [122] | 2 | # Program: |
|---|
| 3 | # Check root identity and change root to exectue client_install.sh |
|---|
| 4 | # Author: |
|---|
| 5 | # Waue, Shunfa, Rock {waue, shunfa, rock}@nchc.org.tw |
|---|
| 6 | # History: |
|---|
| 7 | # 2010/05/20 Rock First release |
|---|
| [117] | 8 | |
|---|
| [123] | 9 | # 正式版之後,記的將不必要 read 拿掉 (trace 用的 read) |
|---|
| [122] | 10 | |
|---|
| 11 | # 設定 functions |
|---|
| 12 | . ./client_install_func.sh |
|---|
| 13 | |
|---|
| [132] | 14 | # 需要 master_install 設定的參數區 |
|---|
| [140] | 15 | # Master IP here |
|---|
| [169] | 16 | Master_IP_Address=input.your.master.ip_address |
|---|
| [152] | 17 | # Master Hostname here |
|---|
| [169] | 18 | Master_Hostname=input_your_master_hostname |
|---|
| [119] | 19 | # 此檔自己用的參數區 |
|---|
| 20 | Linux_Distribution=""; |
|---|
| 21 | Linux_Version=""; |
|---|
| [135] | 22 | Nutchuser_Passwd="xxxxxxxxxx"; |
|---|
| [119] | 23 | |
|---|
| [188] | 24 | # Language Choice |
|---|
| 25 | choose_lang |
|---|
| 26 | |
|---|
| [129] | 27 | # 參數詢問 |
|---|
| [132] | 28 | yesno="no" |
|---|
| [188] | 29 | show_info "$par_echo_1 $Master_IP_Address" |
|---|
| 30 | read -p "$par_echo_2" yesno |
|---|
| [129] | 31 | |
|---|
| [132] | 32 | if [ "$yesno" == "yes" ] || [ "$yesno" == "y" ] ; then |
|---|
| [188] | 33 | show_info "$par_echo_3" |
|---|
| [132] | 34 | else |
|---|
| [188] | 35 | show_info "$par_echo_4" |
|---|
| [132] | 36 | exit |
|---|
| [129] | 37 | fi |
|---|
| 38 | |
|---|
| [119] | 39 | |
|---|
| 40 | # 檢查執行這個程式的是否為root權限 |
|---|
| [117] | 41 | check_root |
|---|
| [191] | 42 | read -p "continue.." |
|---|
| [117] | 43 | |
|---|
| [123] | 44 | # 查出此主機的作業系統,以及版本 |
|---|
| [117] | 45 | check_systemInfo |
|---|
| [191] | 46 | read -p "continue.." |
|---|
| [117] | 47 | |
|---|
| [132] | 48 | # 安裝需要的套件 (目前只支援 deb 套件的系統自動安裝,yum或其他套件系統的則必須手動安裝) |
|---|
| 49 | # 需要套件名稱 ssh, expect, dialog |
|---|
| 50 | install_packages |
|---|
| [191] | 51 | read -p "continue.." |
|---|
| [132] | 52 | |
|---|
| [119] | 53 | # 檢查之前是否有安裝NutchEz |
|---|
| 54 | # 目前先檢查是否有/opt/nutchez 這個資料夾即可 |
|---|
| [117] | 55 | check_nez_installed |
|---|
| [191] | 56 | read -p "continue.." |
|---|
| [117] | 57 | |
|---|
| [119] | 58 | # 檢查是否有安裝sun java ,並檢查是否為jdk 1.6 以上版本 |
|---|
| [135] | 59 | check_sunJava |
|---|
| [191] | 60 | read -p "continue.." |
|---|
| [117] | 61 | |
|---|
| [119] | 62 | # 檢查是否有安裝openssh, openssh-server |
|---|
| [123] | 63 | check_ssh |
|---|
| [191] | 64 | read -p "continue.." |
|---|
| [117] | 65 | |
|---|
| [123] | 66 | # 檢查是否有安裝dialog |
|---|
| 67 | check_dialog |
|---|
| [191] | 68 | read -p "continue.." |
|---|
| [117] | 69 | |
|---|
| [142] | 70 | # 新增nutchuser 帳號時用 Nutchuser_Passwd 當密碼 |
|---|
| 71 | creat_nutchuser_account |
|---|
| [191] | 72 | read -p "continue.." |
|---|
| [142] | 73 | |
|---|
| [117] | 74 | # scp nutchuser@master_ip:~ 把.ssh/目錄複製下來 |
|---|
| 75 | # 當使用者輸入nutchuser 密碼時,將此密碼紀錄到Nutchuser_Passwd |
|---|
| 76 | # 此步驟若無法連到 master 則跳出 |
|---|
| [128] | 77 | scp_master_nutchuser_sshkey $Master_IP_Address |
|---|
| [191] | 78 | read -p "continue.." |
|---|
| [117] | 79 | |
|---|
| 80 | # 用scp 複製 master 的設定與安裝資料 |
|---|
| [119] | 81 | # 目前僅需做到能無礙的複製遠端的/opt/nutchez/到local的/opt/ |
|---|
| [128] | 82 | scp_packages $Master_IP_Address |
|---|
| [191] | 83 | read -p "continue.." |
|---|
| [117] | 84 | |
|---|
| [146] | 85 | # 安裝及啟動 |
|---|
| [144] | 86 | install_nutch_package |
|---|
| [191] | 87 | read -p "continue.." |
|---|
| [117] | 88 | |
|---|
| [147] | 89 | # 回覆 Hostname 和 IP 給 Master Server |
|---|
| 90 | recall_hostname_ip $Master_IP_Address |
|---|
| [191] | 91 | read -p "continue.." |
|---|