debian-mirror-gitlab/scripts/utils.sh
2020-04-08 18:37:08 +05:30

59 lines
1.1 KiB
Bash

function 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
}
function setup_db_user_only() {
source scripts/create_postgres_user.sh
}
function setup_db() {
setup_db_user_only
bundle exec rake db:drop db:create db:schema:load db:migrate
bundle exec rake gitlab:db:setup_ee
}
function install_api_client_dependencies_with_apk() {
apk add --update openssl curl jq
}
function install_api_client_dependencies_with_apt() {
apt update && apt install jq -y
}
function install_gitlab_gem() {
gem install httparty --no-document --version 0.17.3
gem install gitlab --no-document --version 4.13.0
}
function echoerr() {
local header="${2}"
if [ -n "${header}" ]; then
printf "\n\033[0;31m** %s **\n\033[0m" "${1}" >&2;
else
printf "\033[0;31m%s\n\033[0m" "${1}" >&2;
fi
}
function echoinfo() {
local header="${2}"
if [ -n "${header}" ]; then
printf "\n\033[0;33m** %s **\n\033[0m" "${1}" >&2;
else
printf "\033[0;33m%s\n\033[0m" "${1}" >&2;
fi
}