Changeset 129 for nutchez-0.2


Ignore:
Timestamp:
May 25, 2010, 3:32:41 PM (14 years ago)
Author:
rock
Message:

先增參數(Master_IP_Address, Nutchuser_Passwd)確認
修改2函式(creat_nutchuser_account, scp_master_nutchuser_sshkey)的錯誤偵測

Location:
nutchez-0.2/src/test
Files:
2 edited

Legend:

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

    r128 r129  
    1919Linux_Version="";
    2020Nutchuser_Passwd="xxxxxxxx";
     21
     22# 參數詢問
     23yesno="no"   
     24echo -e "\nYour master IP: $Master_IP_Address"
     25echo -e "Your Nutchuser Password: $Nutchuser_Passwd"
     26read -p "These data are cooect? (yes/no): " yesno
     27             
     28if [ "$yesno" == "no" ];then
     29    echo "Plz edit these parameters of this file."
     30    exit     
     31    else     
     32#    echo "yes"                                                                                   
     33fi
    2134
    2235# 功能邏輯區
  • nutchez-0.2/src/test/client_install_func.sh

    r128 r129  
    128128echo -e "mkdir -p /home/nutchuser/"
    129129mkdir -p /home/nutchuser/
    130 read -p "Plz input nutchuser passwd of mater node: " Nutchuser_Passwd
    131 
    132 echo -e "scp nutchuser@$1:~/.ssh /home/nutchuser/"
    133 expect -c "spawn scp -r -o StrictHostKeyChecking=no nutchuser@$1:~/.ssh /home/nutchuser/
    134 expect \"*: \"
    135 send \"$Nutchuser_Passwd\r\"
    136 expect eof"
    137 
    138 chown -R nutchuser:nutchuser /home/nutchuser/.ssh
     130
     131while [ ! -d "/home/nutchuser/.ssh" ]
     132    do
     133    echo -e "\n"
     134    read -p "Plz input nutchuser passwd of master node: " Nutchuser_Passwd
     135    echo -e "scp nutchuser@$1:~/.ssh /home/nutchuser/"
     136    expect -c "spawn scp -r -o StrictHostKeyChecking=no nutchuser@$1:~/.ssh /home/nutchuser/
     137    expect \"*: \" { send \"$Nutchuser_Passwd\r\" }
     138    expect \"*: \" { send_user \"Passwd is error\" }
     139    expect eof"
     140        if [ ! -d "/home/nutchuser/.ssh" ]; then
     141            echo -e "\nPasswd is error, plz re-input nutchuser passwd of master node."
     142        else
     143            echo -e "\nscp correct."
     144        fi
     145        echo "chown -R nutchuser:nutchuser /home/nutchuser/.ssh"
     146        chown -R nutchuser:nutchuser /home/nutchuser/.ssh
     147done
    139148}
    140149
     
    143152function creat_nutchuser_account(){
    144153echo -e "\n= creat_nutchuser_account (debug) ="                             
    145 read -p "Create nutchuser, plz input nutchuser's password: " Nutchuser_Passwd
    146 useradd -m nutchuser -s /bin/bash
    147 
    148 expect -c "spawn passwd nutchuser                 
    149 expect \"*: \"
    150 send \"$1\r\"
    151 expect \"*: \"
    152 send \"$1\r\"
    153 expect eof"
     154
     155# 若沒 nutchuser_Passwd 的參數傳遞才將註解打開讓使用者字型輸入
     156#while [ "1" != "$Nutchuser_Passwd2" ]
     157#do
     158#    read -p "Create nutchuser, plz input nutchuser's password: " Nutchuser_Passwd
     159#    read -p "plz input nutchuser's password, again: " Nutchuser_Passwd2
     160
     161#    if [ "$1" == "$Nutchuser_Passwd2" ]; then
     162#        echo "Two Passwords match."
     163#    else
     164#        echo "two passwords do not match, plz re-input nutchuser's password."
     165#    fi
     166#done
     167
     168#unset Nutchuser_Passwd2
     169
     170if [ $(cat /etc/passwd | grep nutchuser) ]; then
     171    echo "System already has nutchuser, change nutchuser password."
     172    expect -c "spawn passwd nutchuser                 
     173    expect \"*: \"                         
     174    send \"$1\r\"                         
     175    expect \"*: \"                         
     176    send \"$1\r\"                         
     177    expect eof"
     178else
     179    echo "System already has nutchuser, create nutchuser and change password."
     180    useradd -m nutchuser -s /bin/bash
     181    expect -c "spawn passwd nutchuser                 
     182    expect \"*: \"
     183    send \"$1\r\"
     184    expect \"*: \"
     185    send \"$1\r\"
     186    expect eof"
     187fi
    154188}
    155189
Note: See TracChangeset for help on using the changeset viewer.