]> git.donarmstrong.com Git - bin.git/blob - add_kgb_project
escape directories
[bin.git] / add_kgb_project
1 #!/bin/bash
2
3 set -e
4 set -x
5
6 PASSWORD=$(pwgen -s)
7
8 PROJECT=${1%%.git}
9 PROJECT=${PROJECT//\//_}
10
11 GITPATH="$(pwd)/$1"
12
13 cat << EOF > "$GITPATH/hooks/post-receive"
14 #!/bin/sh
15 kgb-client --git-reflog - --conf $GITPATH/hooks/kgb.conf
16 EOF
17
18 chmod +x "$GITPATH/hooks/post-receive"
19
20 cat << EOF > "$GITPATH/hooks/kgb.conf"
21 repo-id: $PROJECT
22 password: $PASSWORD
23 servers:
24  - uri: http://localhost:5391
25 EOF
26
27 cat << EOF |sudo tee "/etc/kgb-bot/kgb.conf.d/${PROJECT}.conf" >/dev/null
28 repositories:
29  $PROJECT:
30   password: $PASSWORD 
31 EOF
32
33 sudo chmod 640 "/etc/kgb-bot/kgb.conf.d/${PROJECT}.conf";
34 sudo chgrp Debian-kgb "/etc/kgb-bot/kgb.conf.d/${PROJECT}.conf";
35 sudo service kgb-bot reload;