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

retry() {
    if eval "$@"; then
        return 0
    fi

    for i in 2 1; do
        sleep 3s
        echo "Retrying $i..."
        if eval "$@"; then
            return 0
        fi
    done
    return 1
}

if [ -f /.dockerenv ] || [ -f ./dockerinit ]; then
    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 vendor --retry 3 --quiet"
else
    rnd=$(awk 'BEGIN { srand() ; printf("%d\n",rand()*5) }')
    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_$rnd/" -i config/database.yml
fi