-
Notifications
You must be signed in to change notification settings - Fork 56
/
firstrun.sh
executable file
·47 lines (34 loc) · 1.44 KB
/
firstrun.sh
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
#!/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
password=$(cat /srv/gitlab/config/database.yml | grep -m 1 password | sed -e 's/ password: "//g' | sed -e 's/"//g')
# ==============================================
# === Delete this section if restoring data from previous build ===
# Precompile assets
cd /home/git/gitlab
su git -c "bundle exec rake assets:precompile RAILS_ENV=production"
rm -R /srv/gitlab/data/mysql
mv /var/lib/mysql-tmp /srv/gitlab/data/mysql
# Start MySQL
mysqld_safe &
sleep 5
# Initialize MySQL
mysqladmin -u root --password=temprootpass password $mysqlRoot
echo "CREATE USER 'git'@'localhost' IDENTIFIED BY '$password';" | \
mysql --user=root --password=$mysqlRoot
echo "CREATE DATABASE IF NOT EXISTS gitlabhq_production DEFAULT CHARACTER SET \
'utf8' COLLATE 'utf8_unicode_ci';" | mysql --user=root --password=$mysqlRoot
echo "GRANT SELECT, LOCK TABLES, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, \
ALTER ON gitlabhq_production.* TO 'git'@'localhost';" | mysql \
--user=root --password=$mysqlRoot
cd /home/git/gitlab
su git -c "bundle exec rake gitlab:setup force=yes RAILS_ENV=production"
sleep 5
su git -c "bundle exec rake db:seed_fu RAILS_ENV=production"
# ================================================================
# Delete firstrun script
rm /srv/gitlab/firstrun.sh