-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreplication-setup.sh
More file actions
executable file
·65 lines (56 loc) · 1.5 KB
/
replication-setup.sh
File metadata and controls
executable file
·65 lines (56 loc) · 1.5 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#! /bin/bash
# Argument check
if [ $# != 2 ]
then
echo "Usage: $0 </path/to/gerrit> <GitHub Username>"
exit
else
echo "Gerrit directory: $1"
echo "GitHub User Name: $2"
fi
# SSH directory check.
if [ ! -d ~/.ssh ]
then
echo "~/.ssh does not exist."
echo "Generating RSA Keys. Do not include a password."
ssh-keygen
else
echo "~/.ssh exists."
echo "Please be sure ~/.ssh/id_rsa.pub is uploaded to GitHub."
fi
# Gerrit Directory check.
if [[ ! -d $1 || ! -f $1/etc/gerrit.config ]]
then
echo "$1 is invalid for the Gerrit Directory."
echo "Please be sure Gerrit is installed and"
echo "that you are using the proper directory."
exit
fi
echo ""
echo "Creating ~/.ssh/config and setting it up for Gerrit ..."
if [ ! -f ~/.ssh/config ]
then
touch ~/.ssh/config
fi
sshconfig=~/.ssh/config
echo "Host github.com:" >> $sshconfig
echo " IdentityFile ~/.ssh/id_rsa" >> $sshconfig
echo " PreferredAuthentications publickey" >> $sshconfig
if [ ! -f $1/etc/secure.config ]
then
touch $1/etc/secure.config
fi
secureconfig=$1/etc/secure.config
echo "[ssh]" >> $secureconfig
echo " file = $HOME/.ssh/config" >> $secureconfig
if [ ! -f $1/etc/replication.config ]
then
touch $1/etc/replication.config
fi
repconfig=$1/etc/replication.config
echo '[remote "github"]' >> $repconfig
echo " url = git@github.com:$2/\${name}.git" >> $repconfig
echo " push = +refs/heads/*:refs/heads/*" >> $repconfig
echo " push = +refs/tags/*:refs/tags/*" >> $repconfig
echo " timeout = 5" >> $repconfig
echo " replicationDelay = 0" >> $repconfig