Version: | 3256c2889c40c47faa30dd07093a61c137127ac4 |
---|---|
Date: | 2008-10-21 11:22:20 |
Original User: | anonymous |
Commands: | history | raw-text |
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
- You want to share a repository through your existing web infrastructure.
- You want to share more than one repository at the same time.
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 thefossil 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 sharingfossil 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
- Find your CGI scripts directory (if applicable). This is commonly something like <base>/cgi-bin/, but does not have to be.
- Inside that directory build a script file which looks like this:
#! /usr/bin/env fossil
repository: /full/path/to/repository/file.fsl - Ensure that the script file so generated is set executable for the CGI user account.
- Ensure that every directory in the path leading to the repository is browseable (chmod +x) to the CGI user account.
- 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
While it is far from a perfect set of instructions.. here are some quick notes that should help windows users along the way...
- you need fossil.exe accessible by your web server or on your path.. easiest is to just chuck it in \%SYSTEM_ROOT%\ (usually c:\windows\)
- assuming you are running apache, you need to either add the ExecCGI to the options on your DocumentRoot, or make sure the ScriptAlias directive is set and put your .cgi files in that folder..
- the contents of your cgi file needs to essentially the same as above.. however paths needs to be windows friendly.. i have made sure that all folders on my test box are free of spaces, and as such this file works for me (obviously your paths may differ)
#! fossil.exe repository: c:/wamp/www/dev/accounts.fossil
I suppose you could put fossil.exe somewhere more specific and set the path to it as well, but since you are probably using the same executable for cmdline and cgi it kind of just makes sense to put it somewhere more accessible - As with most Windows based web instructions, permission are not as important, however at the least, you need to make sure that your repository is not flagged read-only, as you will encounter database errors if it is.
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.