Setting Loggerhead up on Ubuntu
Posted 2009-04-07 15:45:41 by oisin.

Loggerhead allows you to browser your bazaar projects on your file system. It gives you the abilities to view file changes and revision to name a few. The interface is web based and it very straight forward to set up and put behind apache.

Pre-requisites

  • A running apache 2 web server.
  • A running daemontools install for service management.
  • The loggerhead dependancies installed (sudo aptitude install python-simpletal python-paste python-pastedeploy)
  • Python install with vitualenv in it (easy_install virtualenv)

Loggerhead set up

I get the latest source code install it into /opt and create a python virtual environment. I want to isolate loggerhead from the system python so I can easily change it.

 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
# Create a loggerhead user:
sudo mkdir /opt/loggerhead
sudo useradd -d /opt/loggerhead -s /bin/bash loggerhead
sudo chown -R loggerhead:loggerhead /opt/loggerhead

# to access bzr on my system I need logger head to be part of bzr group:
sudo usermod -a -Gbzr loggerhead

# Login as loggerhead to do the following steps:
sudo su - loggerhead
cd /opt/loggerhead

# Get the code
wget http://launchpad.net/loggerhead/1.10/1.10/+download/loggerhead-1.10.tar.gz

# Create a location for and decompress to it:
mkdir 1.10
cd /opt/loggerhead/1.10
tar zxf ../loggerhead-1.10.tar.gz
make

# Create a virtual environment and activate to install loggerhead into:
cd /opt/loggerhead
virtualenv py25
source py25/bin/activate

# Install the files into this python
cd /opt/loggerhead/1.10
python setup.py install

Daemontools loggerhead service set up

You don't have to use daemontools to run loggerhead. You can use init.d if you want to. I just like using daemontools.

 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
# Create the daemontools run script inside the loggerhead dir.
cd /opt/loggerhead

touch run
chmod a+x run

# Create a daemontools run script which will run this service as the loggerhead user:
vi run

#!/bin/bash
# activate the python with loggerhead installed:
source /opt/loggerhead/py25/bin/activate

# Run this as loggerhead user:
sudo setuidgid loggerhead serve-branches --host=127.0.0.1 --port=13311 --log=/var/log/loggerhead --prefix=/repo /bzr > /dev/null 2>&1

# Logout as loggerhead back to my account with sudo privileges:
exit

sudo mkdir /var/log/loggerhead
sudo chown -R loggerhead /var/log/loggerhead

# Test run loggerhead
sudo /opt/loggerhead/run

# success. Now install the script under daemontools management:

sudo mkdir /service/loggerhead-bzr

sudo ln -s /opt/loggerhead/loggerhead_run /service/loggerhead-bzr/run

Apache2 basic auth and Loggerhead set up

The choice of web server is up to you. I use Apache a lot so I hooking this in was fairly straight forward.

 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
# Now edit apache configuration for my site to access the branches/ under my domain and protect it
# with basic auth + htpasswd

vi /etc/apache2/sites-enabled/<my site config> :

  <Location "/repo/">
      AuthUserFile /<path to basic auth file>/pass
      AuthName "My Company"
      AuthType Basic
      require valid-user
      order deny,allow
      allow from all

      ProxyPass http://127.0.0.1:13311/
      ProxyPassReverse http://127.0.0.1:13311/
  </Location>

# check the site file configuration:
sudo apache2ctl configtest

Syntax OK

# Restart to take affect
sudo apache2ctl restart


# Set up the users and passwords with htpasswd
#
# htpasswd /<path to basic auth file>/pass <username>