1
+ #! /bin/sh
2
+
3
+ # ABOUT
4
+ # This script performs a complete installation of Gitlab (master branch).
5
+ # Is can be run with one command without needing _any_ user input after that.
6
+ # This script only works on Amazon Web Services (AWS).
7
+ # The operating system used is Ubuntu 12.04 64bit.
8
+
9
+ # TODO
10
+ # @dosire will send a pull request after this is merged in to change dosire/gitlabhq/non-interactive-aws-install links to gitlabhq/gitlabhq/master and reference this script from installation.md
11
+
12
+ # HOWTO
13
+ # Signup for AWS, free tier are available at http://aws.amazon.com/free/
14
+ # Go to EC2 tab in the AWS console EC2 https://console.aws.amazon.com/ec2/home
15
+ # Click the 'Launch Instance' button
16
+ # Select: 'Quick launch wizard' and continue
17
+ # Choose a key pair => Create New => Name it => Download it
18
+ # Choose a Launch Configuration => Select 'More Amazon Marketplace Images'
19
+ # Press 'Continue'
20
+ # Enter 'ubuntu/images/ubuntu-precise-12.04-amd64-server-20120424' and press 'Search'
21
+ # Select the only result (ami-3c994355) and press 'Continue'
22
+ # Press 'Edit details' if you want to modify something, for example make the type 'c1.medium' to make the install faster.
23
+ # Press the 'Launch' button
24
+ # Press 'Close'
25
+ # Click 'Security Groups' under the left hand menu 'NETWORK & SECURITY'
26
+ # Select the newly create seciruty group, probably named 'quicklaunch-1'
27
+ # Click on the Inbound tab
28
+ # In the 'Create a new rule' dropdown select 'HTTP'
29
+ # Press 'Add Rule'
30
+ # In the 'Create a new rule' dropdown select 'HTTPS'
31
+ # Press 'Add Rule'
32
+ # Press 'Apply Rule Changes'
33
+ # Give the following command in your local terminal while suptituting the UPPERCASE items
34
+ # 'ssh -i LOCATION_OF_AWS_KEY_PAIR_PRIVATE_KEY PUBLIC_DNS_OF_THE_NEW_SERVER'
35
+ # Execute the curl command below and when its ready follow the printed 'Log in instuctions'
36
+ # curl https://raw.github.com/dosire/gitlabhq/non-interactive-aws-install/lib/support/aws/debian_ubuntu_aws.sh | sh
37
+
38
+ # Prevent fingerprint prompt for localhost in step 1 to 3.
39
+ echo " Host localhost
40
+ StrictHostKeyChecking no
41
+ UserKnownHostsFile=/dev/null" | sudo tee -a /etc/ssh/ssh_config
42
+
43
+ # Existing script for Step 1 to 3
44
+ curl https://raw.github.com/dosire/gitlabhq/non-interactive-aws-install/doc/debian_ubuntu.sh | sh
45
+
46
+ # Install MySQL
47
+ sudo apt-get install -y makepasswd # Needed to create a unique password non-interactively.
48
+ userPassword=$( makepasswd --char=10) # Generate a random MySQL password
49
+ # Note that the lines below creates a cleartext copy of the random password in /var/cache/debconf/passwords.dat
50
+ # This file is normally only readable by root and the password will be deleted by the package management system after install.
51
+ echo mysql-server mysql-server/root_password password $userPassword | sudo debconf-set-selections
52
+ echo mysql-server mysql-server/root_password_again password $userPassword | sudo debconf-set-selections
53
+ sudo apt-get install -y mysql-server
54
+
55
+ # Gitlab install
56
+ sudo gem install charlock_holmes --version ' 0.6.8'
57
+ sudo pip install pygments
58
+ sudo gem install bundler
59
+ sudo su -l gitlab -c " git clone git://github.com/gitlabhq/gitlabhq.git gitlab" # Using master everywhere.
60
+ sudo su -l gitlab -c " cd gitlab && mkdir tmp"
61
+ sudo su -l gitlab -c " cd gitlab/config && cp gitlab.yml.example gitlab.yml"
62
+ sudo su -l gitlab -c " cd gitlab/config && cp database.yml.example database.yml"
63
+ sudo sed -i ' s/"secure password"/"' $userPassword ' "/' /home/gitlab/gitlab/config/database.yml # Insert the mysql root password.
64
+ sudo su -l gitlab -c " cd gitlab && bundle install --without development test --deployment"
65
+ sudo su -l gitlab -c " cd gitlab && bundle exec rake gitlab:app:setup RAILS_ENV=production"
66
+
67
+ # Setup gitlab hooks
68
+ sudo cp /home/gitlab/gitlab/lib/hooks/post-receive /home/git/share/gitolite/hooks/common/post-receive
69
+ sudo chown git:git /home/git/share/gitolite/hooks/common/post-receive
70
+
71
+ # Set the first occurrence of host in the Gitlab config to the publicly available domain name
72
+ sudo sed -i ' 0,/host/s/localhost/' ` wget -qO- http://instance-data/latest/meta-data/public-hostname` ' /' /home/gitlab/gitlab/config/gitlab.yml
73
+
74
+ # Gitlab installation test (optional)
75
+ # sudo -u gitlab bundle exec rake gitlab:app:status RAILS_ENV=production
76
+ # sudo -u gitlab bundle exec rails s -e production
77
+ # sudo -u gitlab bundle exec rake environment resque:work QUEUE=* RAILS_ENV=production BACKGROUND=no
78
+
79
+ # Install and configure Nginx
80
+ sudo apt-get install -y nginx
81
+ sudo cp /home/gitlab/gitlab/lib/support/nginx-gitlab /etc/nginx/sites-available/gitlab
82
+ sudo ln -s /etc/nginx/sites-available/gitlab /etc/nginx/sites-enabled/gitlab
83
+ sudo sed -i ' s/YOUR_SERVER_IP/' ` wget -qO- http://instance-data/latest/meta-data/local-ipv4` ' /' /etc/nginx/sites-available/gitlab # Set private ip address (public won't work).
84
+ sudo sed -i ' s/YOUR_SERVER_FQDN/' ` wget -qO- http://instance-data/latest/meta-data/public-hostname` ' /' /etc/nginx/sites-available/gitlab # Set public dns domain name.
85
+
86
+ # Configure Unicorn
87
+ sudo -u gitlab cp /home/gitlab/gitlab/config/unicorn.rb.orig /home/gitlab/gitlab/config/unicorn.rb
88
+
89
+ # Create a Gitlab service
90
+ sudo cp /home/gitlab/gitlab/lib/support/init-gitlab /etc/init.d/gitlab
91
+ sudo chmod +x /etc/init.d/gitlab && sudo update-rc.d gitlab defaults
92
+
93
+ # # Gitlab service commands (unicorn and resque)
94
+ # # restart doesn't restart resque, only start/stop effect it.
95
+ sudo -u gitlab service gitlab start
96
+ # sudo -u gitlab service gitlab restart
97
+ # sudo -u gitlab service gitlab stop
98
+
99
+ # nginx Service commands
100
+ # sudo service nginx start
101
+ sudo service nginx restart
102
+ # sudo service nginx stop
103
+
104
+ # Manual startup commands for troubleshooting when the service commands do not work
105
+ # sudo -u gitlab bundle exec unicorn_rails -c config/unicorn.rb -E production -D
106
+ # sudo su -l gitlab -c "cd gitlab && ./resque.sh"
107
+
108
+ # Monitoring commands
109
+ # sudo tail -f /var/log/nginx/access.log;
110
+ # sudo tail -f /var/log/nginx/error.log;
111
+
112
+ # Go to gitlab directory by default on next login.
113
+ echo ' cd /home/gitlab/gitlab' >> /home/ubuntu/.bashrc
114
+
115
+ echo ' '
116
+ echo ' ###########################################'
117
+ echo ' # Log in instuctions #'
118
+ echo ' ###########################################'
119
+ echo ' '
120
+ echo " Surf to this Gitlab installation in your browser:"
121
+ echo " http://` wget -qO- http://instance-data/latest/meta-data/public-hostname` /"
122
+ echo ' '
123
+ echo ' and login with the following Email and Password:'
124
+
125
+ echo ' 5iveL!fe'
0 commit comments