BigW Consortium Gitlab

prepare_build.sh 1.4 KB
Newer Older
1
#!/bin/bash
2

3 4 5 6 7 8 9 10 11 12 13
retry() {
    for i in $(seq 1 3); do
        if eval "$@"; then
            return 0
        fi
        sleep 3s
        echo "Retrying..."
    done
    return 1
}

14
if [ -f /.dockerinit ]; then
15
    mkdir -p vendor
16 17 18 19

    # Install phantomjs package
    pushd vendor
    if [ ! -e phantomjs_1.9.8-0jessie_amd64.deb ]; then
20 21
        wget -q https://gitlab.com/axil/phantomjs-debian/raw/master/phantomjs_1.9.8-0jessie_amd64.deb
    fi
22 23 24 25
    dpkg -i phantomjs_1.9.8-0jessie_amd64.deb
    popd

    # Try to install packages
26 27
    retry 'apt-get update -yqqq; apt-get -o dir::cache::archives="vendor/apt" install -y -qq --force-yes \
      libicu-dev libkrb5-dev cmake nodejs postgresql-client mysql-client unzip'
28 29 30 31 32 33 34 35

    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
36

37
    export FLAGS=(--path vendor --retry 3)
38 39 40 41 42 43 44
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