summaryrefslogtreecommitdiff
path: root/scripts/prepare_build.sh
blob: 5987988dc8e5f1d9d1240b430b90c36c3ff4d5ae (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
#!/bin/bash

if [ -f /.dockerinit ]; then
    # Docker runners use `/cache` folder which is persisted every build
    if [ ! -e /cache/phantomjs_1.9.8-0jessie_amd64.deb ]; then
        wget -q https://gitlab.com/axil/phantomjs-debian/raw/master/phantomjs_1.9.8-0jessie_amd64.deb
        mv phantomjs_1.9.8-0jessie_amd64.deb /cache
    fi
    dpkg -i /cache/phantomjs_1.9.8-0jessie_amd64.deb

    apt-get update -qq
    apt-get -o dir::cache::archives="/cache/apt" install -y -qq --force-yes \
        libicu-dev libkrb5-dev cmake nodejs postgresql-client mysql-client unzip

    cp config/database.yml.mysql config/database.yml
    sed -i 's/username:.*/username: root/g' config/database.yml
    sed -i 's/password:.*/password:/g' config/database.yml
    sed -i 's/# socket:.*/host: mysql/g' config/database.yml

    cp config/resque.yml.example config/resque.yml
    sed -i 's/localhost/redis/g' config/resque.yml

    export FLAGS=(--path /cache)
else
    export PATH=$HOME/bin:/usr/local/bin:/usr/bin:/bin
    cp config/database.yml.mysql config/database.yml
    sed "s/username\:.*$/username\: runner/" -i config/database.yml
    sed "s/password\:.*$/password\: 'password'/" -i config/database.yml
    sed "s/gitlabhq_test/gitlabhq_test_$((RANDOM/5000))/" -i config/database.yml
fi