Commit 65402f1a1a719d7b491b94cec36fb14e78a60f86
Exists in
master
and in
4 other branches
Merge pull request #1318 from dosire/non-interactive-aws-install
Non interactive aws install
Showing
3 changed files
with
153 additions
and
27 deletions
Show diff stats
doc/debian_ubuntu.sh
@@ -3,7 +3,8 @@ | @@ -3,7 +3,8 @@ | ||
3 | sudo apt-get update | 3 | sudo apt-get update |
4 | sudo apt-get upgrade | 4 | sudo apt-get upgrade |
5 | 5 | ||
6 | -sudo apt-get install -y git git-core wget curl gcc checkinstall libxml2-dev libxslt-dev sqlite3 libsqlite3-dev libcurl4-openssl-dev libreadline-gplv2-dev libc6-dev libssl-dev libmysql++-dev make build-essential zlib1g-dev libicu-dev redis-server openssh-server python-dev python-pip libyaml-dev postfix | 6 | +sudo DEBIAN_FRONTEND='noninteractive' apt-get install -y postfix-policyd-spf-python # Install postfix without prompting. |
7 | +sudo apt-get install -y git git-core wget curl gcc checkinstall libxml2-dev libxslt-dev sqlite3 libsqlite3-dev libcurl4-openssl-dev libreadline-gplv2-dev libc6-dev libssl-dev libmysql++-dev make build-essential zlib1g-dev libicu-dev redis-server openssh-server python-dev python-pip libyaml-dev | ||
7 | 8 | ||
8 | wget http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p194.tar.gz | 9 | wget http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p194.tar.gz |
9 | tar xfvz ruby-1.9.3-p194.tar.gz | 10 | tar xfvz ruby-1.9.3-p194.tar.gz |
doc/installation.md
1 | -## Platform requirements: | 1 | +## Platform requirements: |
2 | 2 | ||
3 | **The project is designed for the Linux operating system.** | 3 | **The project is designed for the Linux operating system.** |
4 | 4 | ||
@@ -22,7 +22,7 @@ You might have some luck using these, but no guarantees: | @@ -22,7 +22,7 @@ You might have some luck using these, but no guarantees: | ||
22 | 22 | ||
23 | Gitlab does **not** run on Windows and we have no plans of making Gitlab compatible. | 23 | Gitlab does **not** run on Windows and we have no plans of making Gitlab compatible. |
24 | 24 | ||
25 | -## This installation guide created for Debian/Ubuntu and properly tested. | 25 | +## This installation guide created for Debian/Ubuntu and properly tested. |
26 | 26 | ||
27 | The installation consists of 6 steps: | 27 | The installation consists of 6 steps: |
28 | 28 | ||
@@ -43,13 +43,13 @@ Also read the [Read this before you submit an issue](https://github.com/gitlabhq | @@ -43,13 +43,13 @@ Also read the [Read this before you submit an issue](https://github.com/gitlabhq | ||
43 | 43 | ||
44 | > - - - | 44 | > - - - |
45 | > First 3 steps can be easily skipped with simply install script: | 45 | > First 3 steps can be easily skipped with simply install script: |
46 | -> | ||
47 | -> # Install curl and sudo | 46 | +> |
47 | +> # Install curl and sudo | ||
48 | > apt-get install curl sudo | 48 | > apt-get install curl sudo |
49 | -> | 49 | +> |
50 | > # 3 steps in 1 command :) | 50 | > # 3 steps in 1 command :) |
51 | > curl https://raw.github.com/gitlabhq/gitlabhq/master/doc/debian_ubuntu.sh | sh | 51 | > curl https://raw.github.com/gitlabhq/gitlabhq/master/doc/debian_ubuntu.sh | sh |
52 | -> | 52 | +> |
53 | > Now you can go to step 4" | 53 | > Now you can go to step 4" |
54 | > - - - | 54 | > - - - |
55 | 55 | ||
@@ -61,7 +61,7 @@ Also read the [Read this before you submit an issue](https://github.com/gitlabhq | @@ -61,7 +61,7 @@ Also read the [Read this before you submit an issue](https://github.com/gitlabhq | ||
61 | sudo apt-get upgrade | 61 | sudo apt-get upgrade |
62 | 62 | ||
63 | sudo apt-get install -y wget curl gcc checkinstall libxml2-dev libxslt-dev sqlite3 libsqlite3-dev libcurl4-openssl-dev libreadline6-dev libc6-dev libssl-dev libmysql++-dev make build-essential zlib1g-dev libicu-dev redis-server openssh-server git-core python-dev python-pip libyaml-dev postfix | 63 | sudo apt-get install -y wget curl gcc checkinstall libxml2-dev libxslt-dev sqlite3 libsqlite3-dev libcurl4-openssl-dev libreadline6-dev libc6-dev libssl-dev libmysql++-dev make build-essential zlib1g-dev libicu-dev redis-server openssh-server git-core python-dev python-pip libyaml-dev postfix |
64 | - | 64 | + |
65 | # If you want to use MySQL: | 65 | # If you want to use MySQL: |
66 | sudo apt-get install -y mysql-server mysql-client libmysqlclient-dev | 66 | sudo apt-get install -y mysql-server mysql-client libmysqlclient-dev |
67 | 67 | ||
@@ -77,7 +77,7 @@ Also read the [Read this before you submit an issue](https://github.com/gitlabhq | @@ -77,7 +77,7 @@ Also read the [Read this before you submit an issue](https://github.com/gitlabhq | ||
77 | # 3. Install gitolite | 77 | # 3. Install gitolite |
78 | 78 | ||
79 | Create user for git: | 79 | Create user for git: |
80 | - | 80 | + |
81 | sudo adduser \ | 81 | sudo adduser \ |
82 | --system \ | 82 | --system \ |
83 | --shell /bin/sh \ | 83 | --shell /bin/sh \ |
@@ -90,7 +90,7 @@ Create user for git: | @@ -90,7 +90,7 @@ Create user for git: | ||
90 | Create user for gitlab: | 90 | Create user for gitlab: |
91 | 91 | ||
92 | # ubuntu/debian | 92 | # ubuntu/debian |
93 | - sudo adduser --disabled-login --gecos 'gitlab system' gitlab | 93 | + sudo adduser --disabled-login --gecos 'gitlab system' gitlab |
94 | 94 | ||
95 | Add your user to git group: | 95 | Add your user to git group: |
96 | 96 | ||
@@ -103,7 +103,7 @@ Generate key: | @@ -103,7 +103,7 @@ Generate key: | ||
103 | Get gitolite source code: | 103 | Get gitolite source code: |
104 | 104 | ||
105 | cd /home/git | 105 | cd /home/git |
106 | - sudo -H -u git git clone git://github.com/gitlabhq/gitolite /home/git/gitolite | 106 | + sudo -H -u git git clone git://github.com/gitlabhq/gitolite /home/git/gitolite |
107 | 107 | ||
108 | Setup: | 108 | Setup: |
109 | 109 | ||
@@ -114,20 +114,20 @@ Setup: | @@ -114,20 +114,20 @@ Setup: | ||
114 | 114 | ||
115 | sudo -u git -H sed -i 's/0077/0007/g' /home/git/share/gitolite/conf/example.gitolite.rc | 115 | sudo -u git -H sed -i 's/0077/0007/g' /home/git/share/gitolite/conf/example.gitolite.rc |
116 | sudo -u git -H sh -c "PATH=/home/git/bin:$PATH; gl-setup -q /home/git/gitlab.pub" | 116 | sudo -u git -H sh -c "PATH=/home/git/bin:$PATH; gl-setup -q /home/git/gitlab.pub" |
117 | - | 117 | + |
118 | Permissions: | 118 | Permissions: |
119 | 119 | ||
120 | sudo chmod -R g+rwX /home/git/repositories/ | 120 | sudo chmod -R g+rwX /home/git/repositories/ |
121 | sudo chown -R git:git /home/git/repositories/ | 121 | sudo chown -R git:git /home/git/repositories/ |
122 | 122 | ||
123 | #### CHECK: Logout & login again to apply git group to your user | 123 | #### CHECK: Logout & login again to apply git group to your user |
124 | - | 124 | + |
125 | # clone admin repo to add localhost to known_hosts | 125 | # clone admin repo to add localhost to known_hosts |
126 | # & be sure your user has access to gitolite | 126 | # & be sure your user has access to gitolite |
127 | - sudo -u gitlab -H git clone git@localhost:gitolite-admin.git /tmp/gitolite-admin | 127 | + sudo -u gitlab -H git clone git@localhost:gitolite-admin.git /tmp/gitolite-admin |
128 | 128 | ||
129 | # if succeed you can remove it | 129 | # if succeed you can remove it |
130 | - sudo rm -rf /tmp/gitolite-admin | 130 | + sudo rm -rf /tmp/gitolite-admin |
131 | 131 | ||
132 | **IMPORTANT! If you cant clone `gitolite-admin` repository - DONT PROCEED INSTALLATION** | 132 | **IMPORTANT! If you cant clone `gitolite-admin` repository - DONT PROCEED INSTALLATION** |
133 | 133 | ||
@@ -139,7 +139,7 @@ Permissions: | @@ -139,7 +139,7 @@ Permissions: | ||
139 | cd /home/gitlab | 139 | cd /home/gitlab |
140 | sudo -H -u gitlab git clone -b stable git://github.com/gitlabhq/gitlabhq.git gitlab | 140 | sudo -H -u gitlab git clone -b stable git://github.com/gitlabhq/gitlabhq.git gitlab |
141 | cd gitlab | 141 | cd gitlab |
142 | - | 142 | + |
143 | sudo -u gitlab mkdir tmp | 143 | sudo -u gitlab mkdir tmp |
144 | 144 | ||
145 | # Rename config files | 145 | # Rename config files |
@@ -150,22 +150,22 @@ Permissions: | @@ -150,22 +150,22 @@ Permissions: | ||
150 | # SQLite | 150 | # SQLite |
151 | sudo -u gitlab cp config/database.yml.sqlite config/database.yml | 151 | sudo -u gitlab cp config/database.yml.sqlite config/database.yml |
152 | 152 | ||
153 | - # Or | 153 | + # Or |
154 | # Mysql | 154 | # Mysql |
155 | # Install MySQL as directed in Step #1 | 155 | # Install MySQL as directed in Step #1 |
156 | - | 156 | + |
157 | # Login to MySQL | 157 | # Login to MySQL |
158 | - $ mysql -u root -p | ||
159 | - | 158 | + $ mysql -u root -p |
159 | + | ||
160 | # Create the gitlabhq production database | 160 | # Create the gitlabhq production database |
161 | mysql> CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`; | 161 | mysql> CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`; |
162 | - | 162 | + |
163 | # Create the MySQL User change $password to a real password | 163 | # Create the MySQL User change $password to a real password |
164 | - mysql> CREATE USER 'gitlab'@'localhost' IDENTIFIED BY '$password'; | ||
165 | - | 164 | + mysql> CREATE USER 'gitlab'@'localhost' IDENTIFIED BY '$password'; |
165 | + | ||
166 | # Grant proper permissions to the MySQL User | 166 | # Grant proper permissions to the MySQL User |
167 | mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `gitlabhq_production`.* TO 'gitlab'@'localhost'; | 167 | mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `gitlabhq_production`.* TO 'gitlab'@'localhost'; |
168 | - | 168 | + |
169 | # Exit MySQL Server and copy the example config, make sure to update username/password in config/database.yml | 169 | # Exit MySQL Server and copy the example config, make sure to update username/password in config/database.yml |
170 | sudo -u gitlab cp config/database.yml.example config/database.yml | 170 | sudo -u gitlab cp config/database.yml.example config/database.yml |
171 | 171 | ||
@@ -181,7 +181,7 @@ Permissions: | @@ -181,7 +181,7 @@ Permissions: | ||
181 | 181 | ||
182 | sudo cp ./lib/hooks/post-receive /home/git/share/gitolite/hooks/common/post-receive | 182 | sudo cp ./lib/hooks/post-receive /home/git/share/gitolite/hooks/common/post-receive |
183 | sudo chown git:git /home/git/share/gitolite/hooks/common/post-receive | 183 | sudo chown git:git /home/git/share/gitolite/hooks/common/post-receive |
184 | - | 184 | + |
185 | Checking status: | 185 | Checking status: |
186 | 186 | ||
187 | sudo -u gitlab bundle exec rake gitlab:app:status RAILS_ENV=production | 187 | sudo -u gitlab bundle exec rake gitlab:app:status RAILS_ENV=production |
@@ -202,13 +202,13 @@ Checking status: | @@ -202,13 +202,13 @@ Checking status: | ||
202 | UMASK for .gitolite.rc is 0007? ............YES | 202 | UMASK for .gitolite.rc is 0007? ............YES |
203 | /home/git/share/gitolite/hooks/common/post-receive exists? ............YES | 203 | /home/git/share/gitolite/hooks/common/post-receive exists? ............YES |
204 | 204 | ||
205 | -If you got all YES - congrats! You can go to next step. | 205 | +If you got all YES - congrats! You can go to next step. |
206 | 206 | ||
207 | # 5. Server up | 207 | # 5. Server up |
208 | 208 | ||
209 | Application can be started with next command: | 209 | Application can be started with next command: |
210 | 210 | ||
211 | - # For test purposes | 211 | + # For test purposes |
212 | sudo -u gitlab bundle exec rails s -e production | 212 | sudo -u gitlab bundle exec rails s -e production |
213 | 213 | ||
214 | # As daemon | 214 | # As daemon |
@@ -0,0 +1,125 @@ | @@ -0,0 +1,125 @@ | ||
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 | +echo 'admin@local.host' | ||
125 | +echo '5iveL!fe' | ||
0 | \ No newline at end of file | 126 | \ No newline at end of file |