2015-09-11 14:41:01 +05:30
|
|
|
#!/bin/bash
|
2016-04-02 18:10:28 +05:30
|
|
|
|
2016-06-02 11:05:42 +05:30
|
|
|
retry() {
|
2016-06-16 23:09:34 +05:30
|
|
|
if eval "$@"; then
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
for i in 2 1; do
|
|
|
|
sleep 3s
|
|
|
|
echo "Retrying $i..."
|
2016-06-02 11:05:42 +05:30
|
|
|
if eval "$@"; then
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
|
|
|
if [ -f /.dockerenv ] || [ -f ./dockerinit ]; then
|
2016-06-16 23:09:34 +05:30
|
|
|
mkdir -p vendor/apt
|
2016-06-02 11:05:42 +05:30
|
|
|
|
|
|
|
# Install phantomjs package
|
2016-06-16 23:09:34 +05:30
|
|
|
pushd vendor/apt
|
2016-06-02 11:05:42 +05:30
|
|
|
if [ ! -e phantomjs_1.9.8-0jessie_amd64.deb ]; then
|
2016-04-02 18:10:28 +05:30
|
|
|
wget -q https://gitlab.com/axil/phantomjs-debian/raw/master/phantomjs_1.9.8-0jessie_amd64.deb
|
|
|
|
fi
|
2016-06-02 11:05:42 +05:30
|
|
|
dpkg -i phantomjs_1.9.8-0jessie_amd64.deb
|
|
|
|
popd
|
2015-09-11 14:41:01 +05:30
|
|
|
|
2016-06-02 11:05:42 +05:30
|
|
|
# Try to install packages
|
|
|
|
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'
|
2015-09-11 14:41:01 +05:30
|
|
|
|
|
|
|
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
|
2016-04-02 18:10:28 +05:30
|
|
|
|
2016-06-02 11:05:42 +05:30
|
|
|
export FLAGS=(--path vendor --retry 3)
|
2015-09-11 14:41:01 +05:30
|
|
|
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
|