summaryrefslogtreecommitdiff
path: root/firehose.configure
blob: 7d129dd0844f6e09e3927ff45775e95039f47148 (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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/sh
set -e

ROOT="$1"

# Add firehose user
chroot "$ROOT" adduser "$GERRIT_USER" -s /bin/false -D
chroot "$ROOT" sudo -u "$GERRIT_USER" --ssh-keygen -C "$GERRIT_USER@baserock.org" -N ""
chroot "$ROOT" sudo chown -R "$GERRIT_USER":"$GERRIT_USER" /var/lib/firehose
cd "$ROOT/home/firehose/"

# Clone the Firehose repo (temporary hack)
git clone git://git.baserock.org/baserock/baserock/firehose

# Move Firehose arguments to specific directory and timer/service
# files to /etc/systemd
mkdir -p "$ROOT/var/lib/firehose"
cp examples/*.yaml "$ROOT/var/lib/firehose/"
cp firehose.service "$ROOT/etc/systemd/system/firehose.service"
cp firehose.timer "$ROOT/etc/systemd/system/firehose.timer"

# Run the Firehose install script
chroot "$ROOT" /usr/bin/python ./setup.py install

cat >>"$ROOT/etc/morph.conf" <<EOF
[config]
repo-alias=baserock=git://git.baserock.org/baserock/#ssh://firehose@testgerrit.baserock.org:29418/baserock/,upstream=git://git.baserock.org/delta/#ssh://firehose@testgerrit.baserock.org:29418/delta/
EOF

# This will run Firehose on the argument specified in firehose.timer
# automatically every six hours
chroot "$ROOT" systemctl enable firehose.timer
chroot "$ROOT" systemctl start firehose.timer
chroot "$ROOT" systemctl enable firehose.service

# Check necessary parameters were filled in firehose.morph before
# the system was deployed, and exit if not
if
    [ -z "$GERRIT_USERNAME" -a \
      -z "$GERRIT_URL" -a \
      -z "$GIT_USERNAME" -a \
      -z "$GIT_EMAIL" -a]; then
    exit 0
fi

# Create firehose.conf to store parameters obtained from .morph file
cat >>"$ROOT/etc/firehose.conf" <<EOF
[config]
gerrit_username = $GERRIT_USERNAME
gerrit_url = $GERRIT_URL
git_username = $GIT_USERNAME
git_email = $GIT_EMAIL
EOF

# Become firehose user
chroot "$ROOT" sudo -u "$GERRIT_USER" -s

# Configure a git identity for Firehose
cat >>"$ROOT/home/firehose/.gitconfig" <<EOF
git config --global user.name "$GIT_USER"
git config --global user.email "$GIT_EMAIL"
EOF