forked from crashsystems/gitlab-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfirstrun.sh
More file actions
70 lines (52 loc) · 2.87 KB
/
firstrun.sh
File metadata and controls
70 lines (52 loc) · 2.87 KB
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
#!/bin/bash
# Set these parameters
mysqlRoot=RootPassword
# === Do not modify anything in this section ===
# Regenerate the SSH host key
/bin/rm /etc/ssh/ssh_host_*
dpkg-reconfigure openssh-server
# Copy over config files
cp /srv/gitlab_ci/config/puma.rb /home/gitlab_ci/gitlab-ci/config/puma.rb
cp /srv/gitlab_ci/config/application.yml /home/gitlab_ci/gitlab-ci/config/application.yml
password=$(cat /srv/gitlab_ci/config/database.yml | grep -m 1 password | sed -e 's/ password: "//g' | sed -e 's/"//g')
echo "Password from database config extracted as $password"
cp /srv/gitlab_ci/config/database.yml /home/gitlab_ci/gitlab-ci/config/database.yml
chown gitlab_ci:gitlab_ci -R /home/gitlab_ci/gitlab-ci/config/ && chmod o-rwx -R /home/gitlab_ci/gitlab-ci/config/
# Link data directories to /srv/gitlab_ci/data
#rm -R /home/gitlab_ci/tmp && ln -s /srv/gitlab_ci/data/tmp /home/gitlab_ci/tmp && chown -R git /srv/gitlab_ci/data/tmp/ && chmod -R u+rwX /srv/gitlab_ci/data/tmp/
#rm -R /home/git/.ssh && ln -s /srv/gitlab_ci/data/ssh /home/git/.ssh && chown -R git:git /srv/gitlab_ci/data/ssh && chmod -R 0700 /srv/gitlab_ci/data/ssh && chmod 0700 /home/git/.ssh
#chown -R git:git /srv/gitlab_ci/data/gitlab-satellites
#chown -R git:git /srv/gitlab_ci/data/repositories && chmod -R ug+rwX,o-rwx /srv/gitlab_ci/data/repositories && chmod -R ug-s /srv/gitlab_ci/data/repositories/
#find /srv/gitlab_ci/data/repositories/ -type d -print0 | xargs -0 chmod g+s
# Change repo path in gitlab-shell config
#sed -i -e 's#/home/git/repositories#/srv/gitlab_ci/data/repositories#g' /home/gitlab_ci-shell/config.yml
# Link MySQL dir to /srv/gitlab_ci/data
#mv /var/lib/mysql /var/lib/mysql-tmp
#ln -s /srv/gitlab_ci/data/mysql /var/lib/mysql
# ==============================================
# === Delete this section if resoring data from previous build ===
rm -R /srv/gitlab_ci/data/mysql
mv /var/lib/mysql-tmp /srv/gitlab_ci/data/mysql
# Start MySQL
mysqld_safe &
sleep 5
# Initialize MySQL
mysqladmin -u root --password=temprootpass password $mysqlRoot
echo "CREATE USER 'gitlab_ci'@'localhost' IDENTIFIED BY '$password';" | \
mysql --user=root --password=$mysqlRoot
echo "CREATE DATABASE IF NOT EXISTS gitlab_ci_production DEFAULT CHARACTER SET \
'utf8' COLLATE 'utf8_unicode_ci';" | mysql --user=root --password=$mysqlRoot
echo "GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON \
gitlab_ci_production.* TO 'gitlab_ci'@'localhost';" | mysql \
--user=root --password=$mysqlRoot
cd /home/gitlab_ci/gitlab-ci
su gitlab_ci -c "bundle exec rake db:setup force=yes RAILS_ENV=production"
sleep 5
su gitlab_ci -c "bundle exec whenever -w force=yes RAILS_ENV=production"
# ================================================================
# Manually create /var/run/sshd
mkdir /var/run/sshd
# change the root password
echo "root:password" | chpasswd
# Delete firstrun script
rm /srv/gitlab_ci/firstrun.sh