| 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 | # 設定 functions  | 
|---|
| 12 | . ./client_install_func.sh | 
|---|
| 13 |  | 
|---|
| 14 | # 需要 master_install 設定的參數區 | 
|---|
| 15 | Master_IP_Address="a.a.a.a"; | 
|---|
| 16 |  | 
|---|
| 17 | # 此檔自己用的參數區 | 
|---|
| 18 | Linux_Distribution=""; | 
|---|
| 19 | Linux_Version=""; | 
|---|
| 20 | Nutchuser_Passwd="xxxxxxxxxx"; | 
|---|
| 21 |  | 
|---|
| 22 | # 參數詢問 | 
|---|
| 23 | yesno="no" | 
|---|
| 24 | echo -e "\nYour master IP: $Master_IP_Address" | 
|---|
| 25 | echo -e "Your Nutchuser Password: $Nutchuser_Passwd" | 
|---|
| 26 | read -p "These data are cooect? (yes/no): " yesno | 
|---|
| 27 |                | 
|---|
| 28 | if [ "$yesno" == "yes" ] || [ "$yesno" == "y" ] ; then | 
|---|
| 29 |     echo "These parameters are correct." | 
|---|
| 30 | else | 
|---|
| 31 |     echo "Plz edit these parameters in this file." | 
|---|
| 32 |     exit | 
|---|
| 33 | fi | 
|---|
| 34 |  | 
|---|
| 35 | # 功能邏輯區 | 
|---|
| 36 |  | 
|---|
| 37 |  | 
|---|
| 38 | # 程式邏輯區 | 
|---|
| 39 |  | 
|---|
| 40 | # 檢查執行這個程式的是否為root權限 | 
|---|
| 41 | check_root | 
|---|
| 42 | read | 
|---|
| 43 |  | 
|---|
| 44 | # 查出此主機的作業系統,以及版本 | 
|---|
| 45 | check_systemInfo | 
|---|
| 46 | read | 
|---|
| 47 |  | 
|---|
| 48 | # 安裝需要的套件 (目前只支援 deb 套件的系統自動安裝,yum或其他套件系統的則必須手動安裝) | 
|---|
| 49 | # 需要套件名稱 ssh, expect, dialog  | 
|---|
| 50 | install_packages | 
|---|
| 51 | read | 
|---|
| 52 |  | 
|---|
| 53 | # 檢查之前是否有安裝NutchEz | 
|---|
| 54 | # 目前先檢查是否有/opt/nutchez 這個資料夾即可 | 
|---|
| 55 | check_nez_installed | 
|---|
| 56 | read | 
|---|
| 57 |  | 
|---|
| 58 | # 檢查是否有安裝sun java ,並檢查是否為jdk 1.6 以上版本 | 
|---|
| 59 | check_sunJava | 
|---|
| 60 | read | 
|---|
| 61 |  | 
|---|
| 62 | # 檢查是否有安裝openssh, openssh-server | 
|---|
| 63 | check_ssh | 
|---|
| 64 | read | 
|---|
| 65 |  | 
|---|
| 66 | # 檢查是否有安裝dialog | 
|---|
| 67 | check_dialog | 
|---|
| 68 | read | 
|---|
| 69 |  | 
|---|
| 70 | # 檢查是否安裝 php 5.5 | 
|---|
| 71 | check_php | 
|---|
| 72 | read | 
|---|
| 73 |  | 
|---|
| 74 | # scp nutchuser@master_ip:~ 把.ssh/目錄複製下來 | 
|---|
| 75 | # 當使用者輸入nutchuser 密碼時,將此密碼紀錄到Nutchuser_Passwd | 
|---|
| 76 | # 此步驟若無法連到 master 則跳出 | 
|---|
| 77 | scp_master_nutchuser_sshkey $Master_IP_Address | 
|---|
| 78 | read | 
|---|
| 79 |  | 
|---|
| 80 | # 新增nutchuser 帳號時用 Nutchuser_Passwd 當密碼 | 
|---|
| 81 | creat_nutchuser_account $Nutchuser_Passwd | 
|---|
| 82 | read | 
|---|
| 83 |  | 
|---|
| 84 | # 用scp 複製 master 的設定與安裝資料 | 
|---|
| 85 | # 目前僅需做到能無礙的複製遠端的/opt/nutchez/到local的/opt/ | 
|---|
| 86 | scp_packages $Master_IP_Address | 
|---|
| 87 | read | 
|---|
| 88 |  | 
|---|
| 89 | # 安裝 | 
|---|
| 90 | #install_packages | 
|---|
| 91 |  | 
|---|