Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / qa / qa_scripts / openstack / ceph_install_w_ansible / talknice.sh
1 #!/bin/bash
2 declare -A rsapub
3 for fulln in $*; do
4     sname=`echo $fulln | sed 's/\..*//'`
5     nhead=`echo $sname | sed 's/[0-9]*//g'`
6     x=`ssh $fulln "ls .ssh/id_rsa"`
7     if [ -z $x ]; then
8         ssh $fulln "ssh-keygen -N '' -f .ssh/id_rsa";
9     fi
10     xx=`ssh $fulln "ls .ssh/config"`
11     if [ -z $xx ]; then
12         scp config $fulln:/home/ubuntu/.ssh/config
13     fi
14     ssh $fulln "chown ubuntu:ubuntu .ssh/config"
15     ssh $fulln "chmod 0600 .ssh/config"
16     rsapub[$fulln]=`ssh $fulln "cat .ssh/id_rsa.pub"`
17 done
18 for ii in $*; do
19     ssh $ii sudo iptables -F
20     for jj in $*; do
21         pval=${rsapub[$jj]}
22         if [ "$ii" != "$jj" ]; then
23             xxxx=`ssh $ii "grep $jj .ssh/authorized_keys"`
24             if [ -z "$xxxx" ]; then
25                 ssh $ii "echo '$pval' | sudo tee -a /home/ubuntu/.ssh/authorized_keys"
26             fi
27         fi
28     done;
29 done