Ignore:
Timestamp:
Jun 1, 2010, 5:34:00 PM (14 years ago)
Author:
rock
Message:

修改部份功能

File:
1 edited

Legend:

Unmodified
Added
Removed
  • nutchez-0.2/src/test/client_install_func.sh

    r140 r142  
    3939echo -e "\nCheck dependent packages"
    4040if [ "$Linux_Distribution" == "Ubuntu" ] || [ "$Linux_Distribution" == "Debian" ] ;then
     41    echo -e "\nIt will install sime packages (expect, ssh, and dialog).\n"
    4142    aptitude install -y expect ssh dialog
    4243# rpm 系列系統
    4344elif [ "$Linux_Distribution" == "Fedora" ] || [ "$Linux_Distribution" == "CentOS" ] ;then
    4445    echo -e "Plz install expect, ssh, and dialog."
     46    exit
     47else
     48    echo -e "Plz install expect, ssh, and dialog."
     49    exit
    4550fi
    4651}
     
    6671echo -e "\n= check_sunJava (debug) ="
    6772echo -e "\nNutchEz need Sun Java JDK 1.6.x or above version"
    68 javaPath="/usr/"
    69 
    70 test -e $javaPath/bin/java || read -p "Plz input specific Java path\
    71 (ex./opt/jvm/java-6-sun-1.6.0.20/): " javaPath
     73
     74yesno="no"
     75while [ "$yesno" != "yes" ]
     76do
     77    read -p "Plz input Sun Java home path (ex. '/usr/lib/jvm/java-6-sun-1.6.0.12' or using default '/usr' ): " javaPath
     78    read -p "Your java is ${javaPath}/bin/java. Is it correct (yes/no): " yesno
     79done
     80
     81test -z JavaPath && $javaPath="/usr"
    7282
    7383if [ -e $javaPath/bin/java ]; then
     
    128138}
    129139
     140
    130141# scp nutchuser@master_ip:~ 把.ssh/目錄複製下來
    131142# 當使用者輸入nutchuser 密碼時,將此密碼紀錄到Nutchuser_Passwd
     
    134145echo -e "\n= scp_master_nutchuser_sshkey (debug) ="
    135146echo -e "mkdir -p /home/nutchuser/"
    136 mkdir -p /home/nutchuser/
    137 rm -fr /home/nutchuser/.ssh
    138 
    139 while [ ! -d "/home/nutchuser/.ssh" ]
    140 do
    141     while [ "$Nutchuser_Passwd" != "$Nutchuser_Passwd2" ]
    142     do
    143         echo -e "\n"
    144         read -p "Plz input nutchuser password of master node: " Nutchuser_Passwd
    145         read -p "plz input nutchuser password, again: " Nutchuser_Passwd2
    146             if [ "$1" == "$Nutchuser_Passwd2" ]; then
    147                 echo "Two Passwords match."
    148             else
    149                 echo "two passwords do not match, plz re-input nutchuser's password."
    150             fi
    151     done
    152    
    153     unset Nutchuser_Passwd2
    154 
    155     echo -e "scp nutchuser@$1:~/.ssh /home/nutchuser/"
    156     expect -c "spawn scp -r -o StrictHostKeyChecking=no nutchuser@$1:~/.ssh /home/nutchuser/
    157     expect \"*: \" { send \"$Nutchuser_Passwd\r\" }
    158     expect \"*: \" { send_user \"Password is error\" }
    159     expect eof"
    160         if [ ! -d "/home/nutchuser/.ssh" ]; then
    161             echo -e "\nPassword  is error, plz re-input nutchuser passwd of master node."
    162         else
    163             echo -e "\nscp correct."
    164         fi
    165         echo "chown -R nutchuser:nutchuser /home/nutchuser/.ssh"
    166         chown -R nutchuser:nutchuser /home/nutchuser/.ssh
    167 done
     147mkdir -p /home/nutchuser/.ssh/
     148rm -fr /home/nutchuser/.ssh/*
     149
     150unset Nutchuser_Passwd2
     151
     152echo -e "scp nutchuser@$1:~/.ssh /home/nutchuser/"
     153expect -c "spawn scp -r -o StrictHostKeyChecking=no nutchuser@$1:~/.ssh /home/nutchuser/
     154expect \"*: \" { send \"$Nutchuser_Passwd\r\" }
     155expect \"*: \" { send_user \"Password is error\" }
     156expect eof"
     157
     158if [ -e "/home/nutchuser/.ssh/authorized_keys" ]; then
     159        echo -e "\nscp correct."   
     160    else
     161        echo -e "\nscp is error,\n(1)plz check nutchuser password in server\n(2)nutchuser's authorized_keys in server\n(3)server's network status"
     162        exit
     163    fi
     164
     165    echo "chown -R nutchuser:nutchuser /home/nutchuser/.ssh"
     166    chown -R nutchuser:nutchuser /home/nutchuser/.ssh
     167
    168168}
    169169
     
    172172function creat_nutchuser_account(){
    173173echo -e "\n= creat_nutchuser_account (debug) ="
     174
     175while [ "$Nutchuser_Passwd" != "$Nutchuser_Passwd2" ]
     176do
     177    echo -e "\n"
     178    read -p "Plz input nutchuser password of master node: " Nutchuser_Passwd
     179    read -p "plz input nutchuser password, again: " Nutchuser_Passwd2
     180        if [ "$Nutchuser_Passwd" == "$Nutchuser_Passwd2" ]; then
     181            echo "Two Passwords match."
     182        else
     183            echo "two passwords do not match, plz re-input nutchuser's password."
     184        fi
     185done                                                                                                                                   
     186   
     187unset Nutchuser_Passwd2
    174188
    175189if [ $(cat /etc/passwd | grep nutchuser) ]; then
     
    178192    set timeout 1
    179193    expect \"*: \"
    180     send \"$1\r\"
    181     expect \"*: \"
    182     send \"$1\r\"
     194    send \"$Nutchuser_Passwd\r\"
     195    expect \"*: \"
     196    send \"$Nutchuser_Passwd\r\"
    183197    expect eof"
    184198else
     
    188202    set timeout 1
    189203    expect \"*: \"
    190     send \"$1\r\"
    191     expect \"*: \"
    192     send \"$1\r\"
     204    send \"$Nutchuser_Passwd\r\"
     205    expect \"*: \"
     206    send \"$Nutchuser_Passwd\r\"
    193207    expect eof"
    194208fi
     
    200214echo -e "\n= scp_packages (debug) ="
    201215chmod 777 /opt
    202 echo "scp -r -o StrictHostKeyChecking=no nutchuser@$1:/opt/nutchez/ /opt/"
    203 su nutchuser -c "scp -r -o StrictHostKeyChecking=no nutchuser@$1:/opt/nutchez/ /opt/"
    204 
    205 echo -e "\nchown -R nutchuser:nutchuser /opt/nutchez/"
    206 chown -R nutchuser:nutchuser /opt/nutchez/
     216echo "scp -r -o StrictHostKeyChecking=no nutchuser@$1:/opt/nutchez /opt/"
     217su nutchuser -c "scp -r -o StrictHostKeyChecking=no nutchuser@$1:/opt/nutchez /opt/"
     218
     219echo -e "\nchown -R nutchuser:nutchuser /opt/nutchez"
     220chown -R nutchuser:nutchuser /opt/nutchez
    207221chmod 755 /opt
    208222}
Note: See TracChangeset for help on using the changeset viewer.