forked from datasets-at/mi-gitlab
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcustomize
executable file
·101 lines (77 loc) · 2.94 KB
/
customize
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/usr/bin/bash
PATH=/opt/local/gnu/bin:/opt/local/bin:/opt/local/sbin:/usr/bin:/usr/sbin
# Exit if any commands fail
set -o errexit
# Ensure we have updated standard packages
echo "* Updating standard packages.";
# Configuring image specific packages
echo "* Configuring image specific packages.";
[ ! -f /opt/local/bin/python2 ] && ln -sf python /opt/local/bin/python2
gem install bundler --no-ri --no-rdoc
useradd -m -d /home/git -c GitLab git
passwd -u git
# clone sources
cd /home/git
sudo -u git -H git clone https://github.com/gitlabhq/gitlab-shell.git gitlab-shell
sudo -u git -H git clone https://github.com/gitlabhq/gitlabhq.git gitlab
sudo -u git -H git clone https://gitlab.com/gitlab-org/gitlab-workhorse.git gitlab-workhorse
echo "* Configuring gitlab-workhorse.";
cd /home/git/gitlab-workhorse
sudo -u git -H git checkout 0.4.2
sudo -u git -H make
echo "* Configuring gitlab-shell.";
cd /home/git/gitlab-shell
sudo -u git -H git checkout v2.6.8
sudo -u git -H cp /root/gitlab-shell-config.yml config.yml
sudo -u git -H ./bin/install
echo "* Configuring gitlab.";
cd /home/git/gitlab
sudo -u git -H git checkout 8-3-stable
chown -R git {log,tmp}/
chmod -R u+rwX {log,tmp}/
sudo -u git -H cp /root/gitlab-gitlab.yml config/gitlab.yml
sudo -u git -H cp /root/gitlab-unicorn.rb config/unicorn.rb
sudo -u git -H cp /root/gitlab-database-rootparty.yml config/database.yml
sudo -u git -H chmod o-rwx config/database.yml
echo "* Installing gems.";
sudo -u git -H NOKOGIRI_USE_SYSTEM_LIBRARIES=yes bundle install --deployment --without development test postgres aws
echo "* starting the MySQL instance"
svcadm enable percona
echo "* waiting for the socket to show up"
COUNT="0";
while [[ ! -e /tmp/mysql.sock ]]; do
sleep 1
((COUNT=COUNT+1))
if [[ $COUNT -eq 60 ]]; then
echo "ERROR Could not talk to MySQL after 60 seconds"
ERROR=yes
break 1
fi
done
[[ -n "${ERROR}" ]] && exit 1
echo "(it took ${COUNT} seconds to start properly)"
sleep 1
[[ "$(svcs -Ho state percona)" == "online" ]] || \
( echo "ERROR MySQL SMF not reporting as 'online'" && exit 1 )
echo "* creating database"
mysql -u root -e "CREATE DATABASE IF NOT EXISTS gitlabhq_production DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;" >/dev/null || \
( echo "ERROR MySQL query failed to execute." && exit 1 )
echo "* Precompiling assets.";
sudo -u git -H bundle exec rake assets:precompile RAILS_ENV=production
echo "* shutting down the MySQL instance"
svcadm disable percona
echo "* Reconfiguring gitlab.";
sudo -u git -H cp /root/gitlab-database.yml config/database.yml
echo "* Importing services.";
svccfg import /root/gitlab.xml
svccfg import /root/gitlab-sidekiq.xml
svccfg import /root/gitlab-workhorse.xml
echo "* Configuring nginx.";
cp /root/nginx.conf /opt/local/etc/nginx/nginx.conf
# Clean up
echo "* Cleaning up."
/opt/local/sbin/pkg_delete cmake gmake gcc48 pkg-config
rm -rf /root/*
rm -rf /tmp/*
# Prepare image for provisioning
sm-prepare-image -y