Add sshd container to known hosts
[gitorious:ce-installer.git] / functions / setup_git.sh
1 git_user_exists() {
2   id git &>/dev/null
3 }
4
5 create_git_user() {
6   useradd -m -u 5000 -U -d /home/git git
7 }
8
9 generate_key_pair() {
10   su git -c "ssh-keygen -f /home/git/.ssh/id_rsa -P ''"
11   mkdir -p /var/lib/gitorious/.ssh
12   chown git:git /var/lib/gitorious/.ssh
13   su git -c "cp /home/git/.ssh/id_rsa.pub /var/lib/gitorious/.ssh/git_id_rsa.pub"
14 }
15
16 generate_bin_gitorious() {
17   cp resources/usr/bin/gitorious /usr/bin/gitorious
18 }
19
20 setup_authorized_keys() {
21   su git -c "ln -fs /var/lib/gitorious/.ssh/authorized_keys /home/git/.ssh/authorized_keys"
22 }
23
24 setup_git_known_hosts() {
25   su git -c "ssh-keyscan -p 5022 -H localhost > /home/git/.ssh/known_hosts 2> /dev/null"
26 }
27
28 setup_git_user() {
29   if git_user_exists; then
30     log "Git user already created"
31   else
32     log "Setting up a git user"
33     create_git_user
34     generate_key_pair
35     generate_bin_gitorious
36     setup_authorized_keys
37   fi
38 }