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