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