Merge pull request #494 from pichuang/master
Modify directory path in clustersetup.sh
This commit is contained in:
+12
-12
@@ -25,20 +25,20 @@ clean=false
|
|||||||
declare -a hosts=()
|
declare -a hosts=()
|
||||||
user=$(whoami)
|
user=$(whoami)
|
||||||
SSHDIR=/tmp/mn/ssh
|
SSHDIR=/tmp/mn/ssh
|
||||||
USERDIR=/home/$user/.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
|
Authenticate yourself and other cluster nodes to each other
|
||||||
via ssh for mininet cluster edition. By default, we use a
|
via ssh for mininet cluster edition. By default, we use a
|
||||||
temporary ssh setup. An ssh directory is mounted over
|
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
|
-h: display this help
|
||||||
-p: create a persistent ssh setup. This will add
|
-p: create a persistent ssh setup. This will add
|
||||||
new ssh keys and known_hosts to each nodes
|
new ssh keys and known_hosts to each nodes
|
||||||
/home/user/.ssh directory
|
$USERDIR directory
|
||||||
-c: method to clean up a temporary ssh setup.
|
-c: method to clean up a temporary ssh setup.
|
||||||
Any hosts taken as arguments will be cleaned
|
Any hosts taken as arguments will be cleaned
|
||||||
'
|
"
|
||||||
|
|
||||||
persistentSetup() {
|
persistentSetup() {
|
||||||
echo "***creating key pair"
|
echo "***creating key pair"
|
||||||
@@ -74,10 +74,10 @@ tempSetup() {
|
|||||||
echo "***creating temporary ssh directory"
|
echo "***creating temporary ssh directory"
|
||||||
mkdir -p $SSHDIR
|
mkdir -p $SSHDIR
|
||||||
echo "***creating key pair"
|
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"
|
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
|
cp $SSHDIR/id_rsa.pub $SSHDIR/authorized_keys
|
||||||
|
|
||||||
for host in $hosts; do
|
for host in $hosts; do
|
||||||
@@ -85,9 +85,9 @@ for host in $hosts; do
|
|||||||
ssh-copy-id $user@$host &> /dev/null
|
ssh-copy-id $user@$host &> /dev/null
|
||||||
echo "***mounting remote temporary ssh directory for $host"
|
echo "***mounting remote temporary ssh directory for $host"
|
||||||
ssh -o ForwardAgent=yes $user@$host "
|
ssh -o ForwardAgent=yes $user@$host "
|
||||||
mkdir -p /tmp/mn/ssh
|
mkdir -p $SSHDIR
|
||||||
cp /home/$user/.ssh/authorized_keys $SSHDIR/authorized_keys
|
cp $USERDIR/authorized_keys $SSHDIR/authorized_keys
|
||||||
sudo mount --bind $SSHDIR /home/$user/.ssh"
|
sudo mount --bind $SSHDIR $USERDIR"
|
||||||
echo "***copying key pair to $host"
|
echo "***copying key pair to $host"
|
||||||
scp $SSHDIR/{id_rsa,id_rsa.pub} $user@$host:$SSHDIR
|
scp $SSHDIR/{id_rsa,id_rsa.pub} $user@$host:$SSHDIR
|
||||||
done
|
done
|
||||||
@@ -102,12 +102,12 @@ cleanup() {
|
|||||||
|
|
||||||
for host in $hosts; do
|
for host in $hosts; do
|
||||||
echo "***cleaning up $host"
|
echo "***cleaning up $host"
|
||||||
ssh $user@$host "sudo umount /home/$user/.ssh
|
ssh $user@$host "sudo umount $USERDIR
|
||||||
sudo rm -rf $SSHDIR"
|
sudo rm -rf $SSHDIR"
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "**unmounting local directories"
|
echo "**unmounting local directories"
|
||||||
sudo umount /home/$user/.ssh
|
sudo umount $USERDIR
|
||||||
echo "***removing temporary ssh directory"
|
echo "***removing temporary ssh directory"
|
||||||
sudo rm -rf $SSHDIR
|
sudo rm -rf $SSHDIR
|
||||||
echo "done!"
|
echo "done!"
|
||||||
|
|||||||
Reference in New Issue
Block a user