summaryrefslogtreecommitdiffstats
path: root/geo-replication/src/peer_add_secret_pub.in
blob: 5a9fd9ac3470bd57d11d792cf18bab53cd0905d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/bash

user=$1
mastervol=$2
slavevol=$3

if [ "$user" == "" ]; then
    echo "Invalid User";
    exit 1;
fi

if [ "$mastervol" == "" ]; then
    echo "Invalid master volume";
    exit 1;
fi

if [ "$slavevol" == "" ]; then
    echo "Invalid slave volume";
    exit 1;
fi

home_dir=`getent passwd $user | cut -d ':' -f 6`;

if [ "$home_dir" == "" ]; then
    echo "Invalid home dir";
    exit 1;
fi

if [ ! -d $home_dir/.ssh ]; then
    mkdir $home_dir/.ssh;
    chmod 700 $home_dir/.ssh;
    chown $user: $home_dir/.ssh;
fi

if [ ! -d $home_dir/.ssh/authorized_keys ]; then
    touch $home_dir/.ssh/authorized_keys;
    chmod 600 $home_dir/.ssh/authorized_keys;
    chown $user: $home_dir/.ssh/authorized_keys;
fi

cat "$GLUSTERD_WORKDIR"/geo-replication/${mastervol}_${slavevol}_common_secret.pem.pub >> $home_dir/.ssh/authorized_keys;