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