Commit eae41ad1 authored by Sytse Sijbrandij's avatar Sytse Sijbrandij

Non-interactive AWS install by running a single script.

Non-interactive AWS install by running a single script.

Complete non-interactive AWS install with one line.

Squash of 28 commits:

Initial commit of complete install script.

Must be sudo.

Non interactive prostgres.

Install mysql with unique password.

Service file.

Add init file.

Nginx config.

Script contains aws specific settings.

Update references after rename.

Prevent localhost ssh prompt.

Postfix with policyd.

Typo in localhost. Postfix package has other name. sudo -l session needs oneliners.

More sudo commands to prevent permission problems.

Change in existing file.

Change in existing file must be referenced.

Switch order.

Postfix comment.

Old way to generate password, less sudo.

todo login

Must use private ip and login instructions.

Starting up.

Fixed and checked various todos.

Use service. Set host name. Go to default dir.

Only works on next login.

Only replace first host.

Cleaned up the comments.

Link to nginx config.

Move to aws dir.

Update links to aws for interactive install.

Existing script stays at the same location.

Change directory. Use the new init scripts for gitlab service and nginx. Use the branch for file downloads. Update with newest changes to installation.md.

Correct reference.

Use master branch since we need the nginx condfig and use absolute paths.

Need to copy with sudo.
parent b2b88b2f
......@@ -3,7 +3,8 @@
sudo apt-get update
sudo apt-get upgrade
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
sudo DEBIAN_FRONTEND='noninteractive' apt-get install -y postfix-policyd-spf-python # Install postfix without prompting.
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
wget http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p194.tar.gz
tar xfvz ruby-1.9.3-p194.tar.gz
......
## Platform requirements:
## Platform requirements:
**The project is designed for the Linux operating system.**
......@@ -22,7 +22,7 @@ You might have some luck using these, but no guarantees:
Gitlab does **not** run on Windows and we have no plans of making Gitlab compatible.
## This installation guide created for Debian/Ubuntu and properly tested.
## This installation guide created for Debian/Ubuntu and properly tested.
The installation consists of 6 steps:
......@@ -43,13 +43,13 @@ Also read the [Read this before you submit an issue](https://github.com/gitlabhq
> - - -
> First 3 steps can be easily skipped with simply install script:
>
> # Install curl and sudo
>
> # Install curl and sudo
> apt-get install curl sudo
>
>
> # 3 steps in 1 command :)
> curl https://raw.github.com/gitlabhq/gitlabhq/master/doc/debian_ubuntu.sh | sh
>
>
> Now you can go to step 4"
> - - -
......@@ -61,7 +61,7 @@ Also read the [Read this before you submit an issue](https://github.com/gitlabhq
sudo apt-get upgrade
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
# If you want to use MySQL:
sudo apt-get install -y mysql-server mysql-client libmysqlclient-dev
......@@ -77,7 +77,7 @@ Also read the [Read this before you submit an issue](https://github.com/gitlabhq
# 3. Install gitolite
Create user for git:
sudo adduser \
--system \
--shell /bin/sh \
......@@ -90,7 +90,7 @@ Create user for git:
Create user for gitlab:
# ubuntu/debian
sudo adduser --disabled-login --gecos 'gitlab system' gitlab
sudo adduser --disabled-login --gecos 'gitlab system' gitlab
Add your user to git group:
......@@ -103,7 +103,7 @@ Generate key:
Get gitolite source code:
cd /home/git
sudo -H -u git git clone git://github.com/gitlabhq/gitolite /home/git/gitolite
sudo -H -u git git clone git://github.com/gitlabhq/gitolite /home/git/gitolite
Setup:
......@@ -114,21 +114,21 @@ Setup:
sudo -u git -H sed -i 's/0077/0007/g' /home/git/share/gitolite/conf/example.gitolite.rc
sudo -u git -H sh -c "PATH=/home/git/bin:$PATH; gl-setup -q /home/git/gitlab.pub"
Permissions:
sudo chmod -R g+rwX /home/git/repositories/
sudo chown -R git:git /home/git/repositories/
sudo chown gitlab:gitlab /home/git/repositories/**/hooks/post-receive
sudo chown gitlab:gitlab /home/git/repositories/**/hooks/post-receive
#### CHECK: Logout & login again to apply git group to your user
# clone admin repo to add localhost to known_hosts
# & be sure your user has access to gitolite
sudo -u gitlab -H git clone git@localhost:gitolite-admin.git /tmp/gitolite-admin
sudo -u gitlab -H git clone git@localhost:gitolite-admin.git /tmp/gitolite-admin
# if succeed you can remove it
sudo rm -rf /tmp/gitolite-admin
sudo rm -rf /tmp/gitolite-admin
**IMPORTANT! If you cant clone `gitolite-admin` repository - DONT PROCEED INSTALLATION**
......@@ -140,7 +140,7 @@ Permissions:
cd /home/gitlab
sudo -H -u gitlab git clone -b stable git://github.com/gitlabhq/gitlabhq.git gitlab
cd gitlab
sudo -u gitlab mkdir tmp
# Rename config files
......@@ -151,22 +151,22 @@ Permissions:
# SQLite
sudo -u gitlab cp config/database.yml.sqlite config/database.yml
# Or
# Or
# Mysql
# Install MySQL as directed in Step #1
# Login to MySQL
$ mysql -u root -p
$ mysql -u root -p
# Create the gitlabhq production database
mysql> CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;
# Create the MySQL User change $password to a real password
mysql> CREATE USER 'gitlab'@'localhost' IDENTIFIED BY '$password';
mysql> CREATE USER 'gitlab'@'localhost' IDENTIFIED BY '$password';
# Grant proper permissions to the MySQL User
mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `gitlabhq_production`.* TO 'gitlab'@'localhost';
# Exit MySQL Server and copy the example config, make sure to update username/password in config/database.yml
sudo -u gitlab cp config/database.yml.example config/database.yml
......@@ -177,7 +177,7 @@ Permissions:
#### Setup DB
sudo -u gitlab bundle exec rake gitlab:app:setup RAILS_ENV=production
Checking status:
sudo -u gitlab bundle exec rake gitlab:app:status RAILS_ENV=production
......@@ -197,13 +197,13 @@ Checking status:
Can clone gitolite-admin?............YES
UMASK for .gitolite.rc is 0007? ............YES
If you got all YES - congrats! You can go to next step.
If you got all YES - congrats! You can go to next step.
# 5. Server up
Application can be started with next command:
# For test purposes
# For test purposes
sudo -u gitlab bundle exec rails s -e production
# As daemon
......@@ -239,7 +239,7 @@ You can login via web using admin generated with setup:
sudo -u gitlab cp config/unicorn.rb.orig config/unicorn.rb
sudo -u gitlab bundle exec unicorn_rails -c config/unicorn.rb -E production -D
Edit /etc/nginx/nginx.conf. In the *http* section add:
Edit /etc/nginx/nginx.conf. In the *http* section add the following section of code or replace it completely with https://raw.github.com/dosire/gitlabhq/master/aws/nginx.conf
upstream gitlab {
server unix:/home/gitlab/gitlab/tmp/sockets/gitlab.socket;
......@@ -249,27 +249,27 @@ Edit /etc/nginx/nginx.conf. In the *http* section add:
listen YOUR_SERVER_IP:80; # e.g., listen 192.168.1.1:80;
server_name YOUR_SERVER_FQDN; # e.g., server_name source.example.com;
root /home/gitlab/gitlab/public;
# individual nginx logs for this gitlab vhost
access_log /var/log/nginx/gitlab_access.log;
error_log /var/log/nginx/gitlab_error.log;
location / {
# serve static files from defined root folder;.
# @gitlab is a named location for the upstream fallback, see below
try_files $uri $uri/index.html $uri.html @gitlab;
}
# if a file, which is not found in the root folder is requested,
# if a file, which is not found in the root folder is requested,
# then the proxy pass the request to the upsteam (gitlab unicorn)
location @gitlab {
proxy_redirect off;
# you need to change this to "https", if you set "ssl" directive to "on"
proxy_set_header X-FORWARDED_PROTO http;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://gitlab;
}
}
......@@ -292,7 +292,7 @@ Create init script in /etc/init.d/gitlab:
# Short-Description: GitLab git repository management
# Description: GitLab git repository management
### END INIT INFO
DAEMON_OPTS="-c /home/gitlab/gitlab/config/unicorn.rb -E production -D"
NAME=unicorn
DESC="Gitlab service"
......
#!/bin/sh
# ABOUT
# This script performs a complete installation of Gitlab (master branch).
# Is can be run with one command without needing _any_ user input after that.
# This script only works on Amazon Web Services (AWS).
# The operating system used is Ubuntu 12.04 64bit.
# TODO
# @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
# HOWTO
# Signup for AWS, free tier are available at http://aws.amazon.com/free/
# Go to EC2 tab in the AWS console EC2 https://console.aws.amazon.com/ec2/home
# Click the 'Launch Instance' button
# Select: 'Quick launch wizard' and continue
# Choose a key pair => Create New => Name it => Download it
# Choose a Launch Configuration => Select 'More Amazon Marketplace Images'
# Press 'Continue'
# Enter 'ubuntu/images/ubuntu-precise-12.04-amd64-server-20120424' and press 'Search'
# Select the only result (ami-3c994355) and press 'Continue'
# Press 'Edit details' if you want to modify something, for example make the type 'c1.medium' to make the install faster.
# Press the 'Launch' button
# Press 'Close'
# Click 'Security Groups' under the left hand menu 'NETWORK & SECURITY'
# Select the newly create seciruty group, probably named 'quicklaunch-1'
# Click on the Inbound tab
# In the 'Create a new rule' dropdown select 'HTTP'
# Press 'Add Rule'
# In the 'Create a new rule' dropdown select 'HTTPS'
# Press 'Add Rule'
# Press 'Apply Rule Changes'
# Give the following command in your local terminal while suptituting the UPPERCASE items
# 'ssh -i LOCATION_OF_AWS_KEY_PAIR_PRIVATE_KEY PUBLIC_DNS_OF_THE_NEW_SERVER'
# Execute the curl command below and when its ready follow the printed 'Log in instuctions'
# curl https://raw.github.com/dosire/gitlabhq/non-interactive-aws-install/lib/support/aws/debian_ubuntu_aws.sh | sh
# Prevent fingerprint prompt for localhost in step 1 to 3.
echo "Host localhost
StrictHostKeyChecking no
UserKnownHostsFile=/dev/null" | sudo tee -a /etc/ssh/ssh_config
# Existing script for Step 1 to 3
curl https://raw.github.com/dosire/gitlabhq/non-interactive-aws-install/doc/debian_ubuntu.sh | sh
# Install MySQL
sudo apt-get install -y makepasswd # Needed to create a unique password non-interactively.
userPassword=$(makepasswd --char=10) # Generate a random MySQL password
# Note that the lines below creates a cleartext copy of the random password in /var/cache/debconf/passwords.dat
# This file is normally only readable by root and the password will be deleted by the package management system after install.
echo mysql-server mysql-server/root_password password $userPassword | sudo debconf-set-selections
echo mysql-server mysql-server/root_password_again password $userPassword | sudo debconf-set-selections
sudo apt-get install -y mysql-server
# Gitlab install
sudo gem install charlock_holmes --version '0.6.8'
sudo pip install pygments
sudo gem install bundler
sudo su -l gitlab -c "git clone git://github.com/gitlabhq/gitlabhq.git gitlab" # Using master everywhere.
sudo su -l gitlab -c "cd gitlab && mkdir tmp"
sudo su -l gitlab -c "cd gitlab/config && cp gitlab.yml.example gitlab.yml"
sudo su -l gitlab -c "cd gitlab/config && cp database.yml.example database.yml"
sudo sed -i 's/"secure password"/"'$userPassword'"/' /home/gitlab/gitlab/config/database.yml # Insert the mysql root password.
sudo su -l gitlab -c "cd gitlab && bundle install --without development test --deployment"
sudo su -l gitlab -c "cd gitlab && bundle exec rake gitlab:app:setup RAILS_ENV=production"
# Setup gitlab hooks
sudo cp /home/gitlab/gitlab/lib/hooks/post-receive /home/git/share/gitolite/hooks/common/post-receive
sudo chown git:git /home/git/share/gitolite/hooks/common/post-receive
# Set the first occurrence of host in the Gitlab config to the publicly available domain name
sudo sed -i '0,/host/s/localhost/'`wget -qO- http://instance-data/latest/meta-data/public-hostname`'/' /home/gitlab/gitlab/config/gitlab.yml
# Gitlab installation test (optional)
# sudo -u gitlab bundle exec rake gitlab:app:status RAILS_ENV=production
# sudo -u gitlab bundle exec rails s -e production
# sudo -u gitlab bundle exec rake environment resque:work QUEUE=* RAILS_ENV=production BACKGROUND=no
# Install and configure Nginx
sudo apt-get install -y nginx
sudo cp /home/gitlab/gitlab/lib/support/nginx-gitlab /etc/nginx/sites-available/gitlab
sudo ln -s /etc/nginx/sites-available/gitlab /etc/nginx/sites-enabled/gitlab
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).
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.
# Configure Unicorn
sudo -u gitlab cp /home/gitlab/gitlab/config/unicorn.rb.orig /home/gitlab/gitlab/config/unicorn.rb
# Create a Gitlab service
sudo cp /home/gitlab/gitlab/lib/support/init-gitlab /etc/init.d/gitlab
sudo chmod +x /etc/init.d/gitlab && sudo update-rc.d gitlab defaults
## Gitlab service commands (unicorn and resque)
## restart doesn't restart resque, only start/stop effect it.
sudo -u gitlab service gitlab start
# sudo -u gitlab service gitlab restart
# sudo -u gitlab service gitlab stop
# nginx Service commands
# sudo service nginx start
sudo service nginx restart
# sudo service nginx stop
# Manual startup commands for troubleshooting when the service commands do not work
# sudo -u gitlab bundle exec unicorn_rails -c config/unicorn.rb -E production -D
# sudo su -l gitlab -c "cd gitlab && ./resque.sh"
# Monitoring commands
# sudo tail -f /var/log/nginx/access.log;
# sudo tail -f /var/log/nginx/error.log;
# Go to gitlab directory by default on next login.
echo 'cd /home/gitlab/gitlab' >> /home/ubuntu/.bashrc
echo ''
echo '###########################################'
echo '# Log in instuctions #'
echo '###########################################'
echo ''
echo "Surf to this Gitlab installation in your browser:"
echo "http://`wget -qO- http://instance-data/latest/meta-data/public-hostname`/"
echo ''
echo 'and login with the following Email and Password:'
echo 'admin@local.host'
echo '5iveL!fe'
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment