27ccf57c9f37f64c3a5bf7ac5b6391fdbd4f6fa8
[ikiwiki.git] / 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 **NOTE:** You must use a version of git that supports <tt>clone --mirror</tt>.
23
24 <pre>
25 # REPODIR=/srv/git
26 # cd $REPODIR && git clone --mirror $MASTER_GIT_SERVER
27 </pre>
28
29 Make sure this is done using the git-user.
30
31 ## Setup the update-repo script
32 <pre>
33 # cd $REPODIR && git clone git://leaf.dragonflybsd.org/~corecode/update-repo.git
34 </pre>
35
36 You might want to use root, or a different user, so the git-user doesn't have permission to modify the update-repo script.
37
38 As the user running the git daemon, run:
39 <pre>
40 # repodir=/srv/git /srv/git/update-repo.git/update-git.sh
41 </pre>
42
43 If this fails, you need to diagnose the problem and fix it before proceeding. Feel free to ask the community for help or advice.
44
45 ## Add entry to crontab
46
47 Run every 20 minutes:
48 <pre>
49 0,20,40 * * * * repodir=/srv/git /srv/git/update-repo.git/update-git.sh
50 </pre>
51
52 Make sure you forward the mails from the git-user, to detect potential problems. This is usually done in <tt>/etc/aliases</tt>.
53
54 ## Start the git-daemon
55 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:
56
57 <pre>
58 #!/bin/sh
59 exec setuidgid gitlog git-daemon --export-all --verbose --base-path=/srv/git /srv/git
60 </pre>
61
62 ## Notes for Linux/Debian users
63
64 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>.
65
66
67 ### Crontab example
68 <pre>
69 0,20,40 * * * * repodir=/srv/git locktype=lockfile /srv/git/update-repo.git/update-git.sh
70 </pre>