summaryrefslogtreecommitdiffstats
path: root/geo-replication/src/peer_add_secret_pub.in
blob: 97011f204d28e695063f94a9757042b8a766f25b (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
#!/bin/bash

if [ "$1" == "" ]; then
    user="root"
    home_dir=`getent passwd root | cut -d ':' -f 6`;
else
    user=$1
    home_dir=`getent passwd $1 | cut -d ':' -f 6`;
fi

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

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/common_secret.pem.pub >> $home_dir/.ssh/authorized_keys;