Skip to content

Commit 0ae90d8

Browse files
committed
copy configs & install scripts from main repo
1 parent 7b12660 commit 0ae90d8

File tree

4 files changed

+255
-0
lines changed

4 files changed

+255
-0
lines changed

config/init-gitlab

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#! /bin/bash
2+
### BEGIN INIT INFO
3+
# Provides: gitlab
4+
# Required-Start: $local_fs $remote_fs $network $syslog redis-server
5+
# Required-Stop: $local_fs $remote_fs $network $syslog
6+
# Default-Start: 2 3 4 5
7+
# Default-Stop: 0 1 6
8+
# Short-Description: GitLab git repository management
9+
# Description: GitLab git repository management
10+
### END INIT INFO
11+
12+
APP_ROOT="/home/gitlab/gitlab"
13+
DAEMON_OPTS="-c $APP_ROOT/config/unicorn.rb -E production -D"
14+
NAME="unicorn"
15+
DESC="Gitlab service"
16+
PID="$APP_ROOT/tmp/pids/unicorn.pid"
17+
RESQUE_PID="$APP_ROOT/tmp/pids/resque_worker.pid"
18+
19+
case "$1" in
20+
start)
21+
CD_TO_APP_DIR="cd $APP_ROOT"
22+
START_DAEMON_PROCESS="bundle exec unicorn_rails $DAEMON_OPTS"
23+
START_RESQUE_PROCESS="./resque.sh"
24+
25+
echo -n "Starting $DESC: "
26+
if [ `whoami` = root ]; then
27+
sudo -u gitlab sh -l -c "$CD_TO_APP_DIR && $START_DAEMON_PROCESS && $START_RESQUE_PROCESS"
28+
else
29+
$CD_TO_APP_DIR && $START_DAEMON_PROCESS && $START_RESQUE_PROCESS
30+
fi
31+
echo "$NAME."
32+
;;
33+
stop)
34+
echo -n "Stopping $DESC: "
35+
kill -QUIT `cat $PID`
36+
kill -QUIT `cat $RESQUE_PID`
37+
echo "$NAME."
38+
;;
39+
restart)
40+
echo -n "Restarting $DESC: "
41+
kill -USR2 `cat $PID`
42+
echo "$NAME."
43+
;;
44+
reload)
45+
echo -n "Reloading $DESC configuration: "
46+
kill -HUP `cat $PID`
47+
echo "$NAME."
48+
;;
49+
*)
50+
echo "Usage: $NAME {start|stop|restart|reload}" >&2
51+
exit 1
52+
;;
53+
esac
54+
55+
exit 0

config/nginx-gitlab

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
upstream gitlab {
2+
server unix:/home/gitlab/gitlab/tmp/sockets/gitlab.socket;
3+
}
4+
5+
server {
6+
listen YOUR_SERVER_IP:80; # e.g., listen 192.168.1.1:80;
7+
server_name YOUR_SERVER_FQDN; # e.g., server_name source.example.com;
8+
root /home/gitlab/gitlab/public;
9+
10+
# individual nginx logs for this gitlab vhost
11+
access_log /var/log/nginx/gitlab_access.log;
12+
error_log /var/log/nginx/gitlab_error.log;
13+
14+
location / {
15+
# serve static files from defined root folder;.
16+
# @gitlab is a named location for the upstream fallback, see below
17+
try_files $uri $uri/index.html $uri.html @gitlab;
18+
}
19+
20+
# if a file, which is not found in the root folder is requested,
21+
# then the proxy pass the request to the upsteam (gitlab unicorn)
22+
location @gitlab {
23+
proxy_redirect off;
24+
25+
# you need to change this to "https", if you set "ssl" directive to "on"
26+
proxy_set_header X-FORWARDED_PROTO http;
27+
proxy_set_header Host $http_host;
28+
proxy_set_header X-Real-IP $remote_addr;
29+
30+
proxy_pass http://gitlab;
31+
}
32+
}
33+

install/debian_ubuntu.sh

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/bin/sh
2+
3+
sudo apt-get update
4+
sudo apt-get upgrade
5+
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
8+
9+
wget http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p194.tar.gz
10+
tar xfvz ruby-1.9.3-p194.tar.gz
11+
cd ruby-1.9.3-p194
12+
./configure
13+
make
14+
sudo make install
15+
16+
sudo adduser \
17+
--system \
18+
--shell /bin/sh \
19+
--gecos 'git version control' \
20+
--group \
21+
--disabled-password \
22+
--home /home/git \
23+
git
24+
25+
sudo adduser --disabled-login --gecos 'gitlab system' gitlab
26+
27+
sudo usermod -a -G git gitlab
28+
29+
sudo -H -u gitlab ssh-keygen -q -N '' -t rsa -f /home/gitlab/.ssh/id_rsa
30+
31+
cd /home/git
32+
sudo -H -u git git clone git://github.com/gitlabhq/gitolite /home/git/gitolite
33+
34+
sudo -u git -H sh -c "PATH=/home/git/bin:$PATH; /home/git/gitolite/src/gl-system-install"
35+
sudo cp /home/gitlab/.ssh/id_rsa.pub /home/git/gitlab.pub
36+
sudo chmod 777 /home/git/gitlab.pub
37+
38+
sudo -u git -H sed -i 's/0077/0007/g' /home/git/share/gitolite/conf/example.gitolite.rc
39+
sudo -u git -H sh -c "PATH=/home/git/bin:$PATH; gl-setup -q /home/git/gitlab.pub"
40+
41+
sudo chmod -R g+rwX /home/git/repositories/
42+
sudo chown -R git:git /home/git/repositories/
43+
44+
sudo -u gitlab -H git clone git@localhost:gitolite-admin.git /tmp/gitolite-admin
45+
sudo rm -rf /tmp/gitolite-admin

install/debian_ubuntu_aws.sh

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

0 commit comments

Comments
 (0)