summaryrefslogtreecommitdiff
path: root/scripts/utils.sh
blob: 2d2ba115563165ee58d2d180d951673b234e0c0f (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
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
}

setup_db_user_only() {
    if [ "$GITLAB_DATABASE" = "postgresql" ]; then
        . scripts/create_postgres_user.sh
    else
        . scripts/create_mysql_user.sh
    fi
}

setup_db() {
    setup_db_user_only

    bundle exec rake db:drop db:create db:schema:load db:migrate

    if [ "$GITLAB_DATABASE" = "mysql" ]; then
        bundle exec rake add_limits_mysql
    fi
}