Wiki Page Cookbook
Not logged in
Overview

Version:8e46971181ac2c7438e2614ae16ef6929dc777d8
Date: 2008-05-25 07:50:11
Original User: michael
Commands: history | raw-text

Content

Fossil Cookbook

The Fossil Cookbook is a collection of task-oriented instructions for intermediate users who wish to do more than basic operations with their Fossil repositories. The tutorial is a more suitable place for newcomers trying to learn the basic concepts to go first before tackling these recipes.

Index

Server recipes:

Using Fossil's Built-In CGI

Motivation

Problem

Unlike some other distributed SCMs, Fossil can only clone, push, pull and and otherwise interact through repositories over HTTP. This can be simply and easily managed through use of the fossil server and/or fossil ui commands, of course, but this is really only adequate for ad-hoc repository sharing. Consider, for example, sharing ten repositories. Using the built-in server would require you to open ten ports in your firewall to permit access. Any serious sharing will require something more robust and permanent.

Solution

Fossil supports three different ways to share repositories. For ad-hoc sharing fossil server/ui is more than adequate. For more robust solutions, however, the use of (x)inetd or CGI support is indicated.

Setting up fossil for CGI support is simple. (Setting up your web server for CGI support may or may not be simple, but it is out of scope of this recipe. Consult your web server/service provider's documentation for this.)

UNIX

  1. Find your CGI scripts directory (if applicable). This is commonly something like <base>/cgi-bin/, but does not have to be.
  2. Inside that directory build a script file which looks like this:
      #! /usr/bin/env fossil
    repository: /full/path/to/repository/file.fsl
  3. Ensure that the script file so generated is set executable for the CGI user account.
  4. Ensure that every directory in the path leading to the repository is browseable (chmod +x) to the CGI user account.
  5. Ensure that the repository file is readable and writable to the CGI user account.

The following bash script can be run from within the directory containing the Fossil repositories to be shared (and, of course, altered for your setup) to set some of the constraints above up automatically:

 1 #! /usr/bin/env bash
 2 CGI_ROOT=/usr/lib/fossil
 3 REPOSITORY_OWNER=michael
 4 CGI_GROUP=www-data
 5 if [ `whoami` = 'root' ]
 6 then
 7   for repository in *.fsl
 8   do
 9     SOURCE=`pwd`/$repository
10     DESTINATION=$CGI_ROOT/${repository%.fsl}
11     echo "#! /usr/bin/env fossil" > $DESTINATION
12     echo "repository: $SOURCE" >> $DESTINATION
13     chown $REPOSITORY_OWNER:$CGI_GROUP $SOURCE
14     chmod 664 $SOURCE
15     chown root:root $DESTINATION
16     chmod 755 $DESTINATION
17   done
18 else
19   sudo $0 $*
20 fi

Windows

Someone with access to a Windows machine complete with web server, etc. needs to write this portion. The CGI script is the same, but none of the other instructions make sense.

Discussion

Using the CGI server is the best solution combining an existing web infrastructure and the sharing of many Fossil repositories. Unlike the ad-hoc solution which requires, in effect, a separate port for each simultaneously-shared repository, and which requires several instances of fossil running -- one for each shared repository -- the CGI approach uses URLs to distinguish between repositories and only (briefly) runs a copy of fossil when the repository is actually accessed.

Sharing repositories with CGI is really only worth the effort if more than one repository is being shared, however. With only one being shared, fossil server is likely more than adequate or the use of (x)inetd may be indicated. If, however, there is already an existing web infrastructure in place, CGI still may be preferred if only for consistency and maintainability of the system as a whole.