summaryrefslogtreecommitdiff
path: root/firehose.configure
blob: 5cd5c5ba5bc95d314850623a498ce411917c6608 (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
#!/bin/sh
set -e

ROOT="$1"

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

# 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 ""

# Clone the Firehose repo (temporary hack)
git clone git://git.baserock.org/baserock/baserock/firehose "$ROOT/home/firehose/firehose"
cd "$ROOT/home/firehose/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/"
chroot "$ROOT" sudo chown -R "$GERRIT_USER":"$GERRIT_USER" /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" sh -c 'cd /home/firehose/firehose/ && /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

# 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

# Configure a git identity for Firehose
chroot "$ROOT" sudo -u "$GERRIT_USER" git config -f "/home/firehose/.gitconfig" user.name "$GIT_USER"
chroot "$ROOT" sudo -u "$GERRIT_USER" git config -f "/home/firehose/.gitconfig" user.email "$GIT_EMAIL"