1ec9c1d83ebd618edfc25b975fc52e39a2db0389
[ikiwiki.git] / docs / docs / howtos / How_to_mirror_DragonFly_with_Git / index.mdwn
1 This guide will outline the basics of running a git mirror of DragonFlyBSD. You should be somewhat familiar with git.
2
3 ## Choose a directory
4 I tend to choose <tt>/srv/git</tt>, other typical places could include <tt>/usr/local/git</tt>, <tt>/home/git</tt> or <tt>/var/lib/git</tt>. The location isn't important, find a place that fits your preference or OS recommendations, but make sure you have a couple of GB free (as of 2009). It is a good idea to use a top-level <tt>git</tt>-folder, so you can mirror multiple DragonFly sub-projects in hierarchy. This is a pre-requisite for running the <tt>update-repo</tt> shell-script (more about that in a bit).
5
6 This is my configuration:
7
8 <pre>
9 /srv/git
10         /dragonfly.git
11         /update-repo.git
12         /df-webtool
13         run
14         supervise
15 </pre>
16
17 As you can see <tt>df-webtool</tt> is not named with ".git"-extention, this is because the update-repo script mirrors <tt>/srv/git/*.git</tt>, and I do not want to mirror <tt>df-webtool</tt>, because it has no origin. The <tt>run</tt> and <tt>supervise</tt> files are special files that are created by <tt>daemon-tools</tt>. Daemon-tools (and many others like it), keeps the git-daemon running, and is not necessary for running a git mirror.
18
19 ## Clone the DragonFly source
20 After creating a git-user to run the git mirror (I use 'gitlog', which came with the git-package under Debian), login as this user, and perform a checkout. To find a suitable git-server to clone from ( <tt>$MASTER_GIT_SERVER</tt> ), look at [[the list of mirrors|/mirrors]]. This system should be a system user, and does not need to have a homedirectory or valid shell.
21
22 <pre>
23 # REPODIR=/srv/git
24 # cd $REPODIR && git clone --bare $MASTER_GIT_SERVER
25 </pre>
26
27 Make sure this is done using the git-user.
28
29 ## Setup the update-repo script
30 <pre>
31 # cd $REPODIR && git clone git://leaf.dragonflybsd.org/~corecode/update-repo.git
32 </pre>
33
34 You might want to use root, or a different user, so the git-user doesn't have permission to modify the update-repo script.
35
36 As the user running the git daemon, run:
37 <pre>
38 # repodir=/srv/git /srv/git/update-repo.git/update-git.sh
39 </pre>
40
41 If this fails, you need to diagnose the problem and fix it before proceeding. Feel free to ask the community for help or advice.
42
43 ## Add entry to crontab
44
45 Run every 20 minutes:
46 <pre>
47 0,20,40 * * * * repodir=/srv/git srv/git/update-repo.git/update-git.sh
48 </pre>
49
50 Make sure you forward the mails from the git-user, to detect potential problems. This is usually done in <tt>/etc/aliases</tt>.
51
52 ## Start the git-daemon
53 A startup script should be provided via package-manager, or you can use a service-tool like daemon-tools (or others). This is an example run-file:
54
55 <pre>
56 #!/bin/sh
57 exec setuidgid gitlog git-daemon --export-all --verbose --base-path=/srv/git /srv/git
58 </pre>
59
60 ## Notes for Linux/Debian users
61
62 The update-repo script uses lockf(1), if this tool is not available to you, but you have lockfile(1), you can pull my workaround for lockfile(1). I say workaround, because it is not elegant - but it's the best I could think of at the time. To get this script, pull branch <tt>debian/linux</tt> from <tt>git://blazefire.danielbond.org/update-repo.git</tt>.
63
64
65 ### Crontab example
66 <pre>
67 0,20,40 * * * * repodir=/srv/git locktype=lockfile /srv/git/update-repo.git/update-git.sh
68 </pre>