From 57c8f5934f403ebe9b9fdffd448f00293869f118 Mon Sep 17 00:00:00 2001 From: Roan Huang Date: Mon, 6 Apr 2015 11:12:27 +0000 Subject: [PATCH 1/3] Fixed code indentation --- util/clustersetup.sh | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/util/clustersetup.sh b/util/clustersetup.sh index 89d5cff..c968034 100755 --- a/util/clustersetup.sh +++ b/util/clustersetup.sh @@ -80,22 +80,22 @@ tempSetup() { sudo mount --bind $SSHDIR /home/$user/.ssh cp $SSHDIR/id_rsa.pub $SSHDIR/authorized_keys -for host in $hosts; do - echo "***copying public key to $host" - ssh-copy-id $user@$host &> /dev/null - echo "***mounting remote temporary ssh directory for $host" - ssh -o ForwardAgent=yes $user@$host " - mkdir -p /tmp/mn/ssh - cp /home/$user/.ssh/authorized_keys $SSHDIR/authorized_keys - sudo mount --bind $SSHDIR /home/$user/.ssh" - echo "***copying key pair to $host" - scp $SSHDIR/{id_rsa,id_rsa.pub} $user@$host:$SSHDIR -done + for host in $hosts; do + echo "***copying public key to $host" + ssh-copy-id $user@$host &> /dev/null + echo "***mounting remote temporary ssh directory for $host" + ssh -o ForwardAgent=yes $user@$host " + mkdir -p /tmp/mn/ssh + cp /home/$user/.ssh/authorized_keys $SSHDIR/authorized_keys + sudo mount --bind $SSHDIR /home/$user/.ssh" + echo "***copying key pair to $host" + scp $SSHDIR/{id_rsa,id_rsa.pub} $user@$host:$SSHDIR + done -for host in $hosts; do - echo "***copying known_hosts to $host" - scp $SSHDIR/known_hosts $user@$host:$SSHDIR -done + for host in $hosts; do + echo "***copying known_hosts to $host" + scp $SSHDIR/known_hosts $user@$host:$SSHDIR + done } cleanup() { From 0a810b226c7333c89f5a751a443e5c097c0bbd45 Mon Sep 17 00:00:00 2001 From: Roan Huang Date: Mon, 6 Apr 2015 11:19:26 +0000 Subject: [PATCH 2/3] Modify SSHDIR and USERDIR path --- util/clustersetup.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/util/clustersetup.sh b/util/clustersetup.sh index c968034..a80c899 100755 --- a/util/clustersetup.sh +++ b/util/clustersetup.sh @@ -25,7 +25,7 @@ clean=false declare -a hosts=() user=$(whoami) SSHDIR=/tmp/mn/ssh -USERDIR=/home/$user/.ssh +USERDIR=$HOME/.ssh usage=$'./clustersetup.sh [ -p|h|c ] [ host1 ] [ host2 ] ...\n Authenticate yourself and other cluster nodes to each other via ssh for mininet cluster edition. By default, we use a @@ -74,10 +74,10 @@ tempSetup() { echo "***creating temporary ssh directory" mkdir -p $SSHDIR echo "***creating key pair" - ssh-keygen -t rsa -C "Cluster_Edition_Key" -f /tmp/mn/ssh/id_rsa -N '' &> /dev/null + ssh-keygen -t rsa -C "Cluster_Edition_Key" -f $SSHDIR/id_rsa -N '' &> /dev/null echo "***mounting temporary ssh directory" - sudo mount --bind $SSHDIR /home/$user/.ssh + sudo mount --bind $SSHDIR $USERDIR cp $SSHDIR/id_rsa.pub $SSHDIR/authorized_keys for host in $hosts; do @@ -85,9 +85,9 @@ tempSetup() { ssh-copy-id $user@$host &> /dev/null echo "***mounting remote temporary ssh directory for $host" ssh -o ForwardAgent=yes $user@$host " - mkdir -p /tmp/mn/ssh - cp /home/$user/.ssh/authorized_keys $SSHDIR/authorized_keys - sudo mount --bind $SSHDIR /home/$user/.ssh" + mkdir -p $SSHDIR + cp $USERDIR/authorized_keys $SSHDIR/authorized_keys + sudo mount --bind $SSHDIR $USERDIR" echo "***copying key pair to $host" scp $SSHDIR/{id_rsa,id_rsa.pub} $user@$host:$SSHDIR done @@ -102,12 +102,12 @@ cleanup() { for host in $hosts; do echo "***cleaning up $host" - ssh $user@$host "sudo umount /home/$user/.ssh + ssh $user@$host "sudo umount $USERDIR sudo rm -rf $SSHDIR" done echo "**unmounting local directories" - sudo umount /home/$user/.ssh + sudo umount $USERDIR echo "***removing temporary ssh directory" sudo rm -rf $SSHDIR echo "done!" From 2c916acc06686d8d6d755bcfb1f0b8c4f6dae2db Mon Sep 17 00:00:00 2001 From: Roan Huang Date: Tue, 7 Apr 2015 03:37:53 +0000 Subject: [PATCH 3/3] Modify cluster help information --- util/clustersetup.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/util/clustersetup.sh b/util/clustersetup.sh index a80c899..d28cbc4 100755 --- a/util/clustersetup.sh +++ b/util/clustersetup.sh @@ -26,19 +26,19 @@ declare -a hosts=() user=$(whoami) SSHDIR=/tmp/mn/ssh USERDIR=$HOME/.ssh -usage=$'./clustersetup.sh [ -p|h|c ] [ host1 ] [ host2 ] ...\n +usage="./clustersetup.sh [ -p|h|c ] [ host1 ] [ host2 ] ...\n Authenticate yourself and other cluster nodes to each other via ssh for mininet cluster edition. By default, we use a temporary ssh setup. An ssh directory is mounted over - /home/user/.ssh on each machine in the cluster. + $USERDIR on each machine in the cluster. -h: display this help -p: create a persistent ssh setup. This will add new ssh keys and known_hosts to each nodes - /home/user/.ssh directory + $USERDIR directory -c: method to clean up a temporary ssh setup. Any hosts taken as arguments will be cleaned - ' + " persistentSetup() { echo "***creating key pair"