add: 打包脚本
This commit is contained in:
38
build/misc/cpnetools.sh
Normal file
38
build/misc/cpnetools.sh
Normal file
@@ -0,0 +1,38 @@
|
||||
#!/bin/bash
|
||||
|
||||
tooldir=/usr/local/bin
|
||||
toollist="zip unzip"
|
||||
|
||||
#分发到各个节点,这里分发到nehosts文件中的主机中.
|
||||
while read line
|
||||
do
|
||||
if [[ "$line" =~ ^[^[:space:]]*# || -z "$line" ]]; then
|
||||
continue
|
||||
fi
|
||||
user=`echo $line | cut -d " " -f 2`
|
||||
ip=`echo $line | cut -d " " -f 1`
|
||||
passwd=`echo $line | cut -d " " -f 3`
|
||||
|
||||
for toolname in $toollist;do
|
||||
expect <<EOF
|
||||
set timeout 10
|
||||
spawn scp $tooldir/$toolname $user@$ip:/tmp
|
||||
expect {
|
||||
"yes/no" { send "yes\n";exp_continue }
|
||||
"password" { send "$passwd\n" }
|
||||
}
|
||||
expect "password" { send "$passwd\n" }
|
||||
EOF
|
||||
done
|
||||
for toolname in $toollist;do
|
||||
expect <<EOF
|
||||
set timeout 10
|
||||
spawn ssh $user@$ip sudo mv /tmp/$toolname $tooldir
|
||||
expect {
|
||||
"yes/no" { send "yes\n";exp_continue }
|
||||
"password" { send "$passwd\n" }
|
||||
}
|
||||
expect "password" { send "$passwd\n" }
|
||||
EOF
|
||||
done
|
||||
done < nehosts
|
||||
Reference in New Issue
Block a user