[6ff0105] | 1 | <?xml version="1.0" encoding="ISO-8859-1"?>
|
---|
| 2 | <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
|
---|
| 3 | "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
|
---|
| 4 | <!ENTITY % general-entities SYSTEM "../../general.ent">
|
---|
| 5 | %general-entities;
|
---|
| 6 |
|
---|
| 7 | ]>
|
---|
| 8 |
|
---|
| 9 | <sect1 id="svnserver" xreflabel="Running a Subversion Server">
|
---|
[a0f03b0] | 10 | <sect1info>
|
---|
[5cd0959d] | 11 | <othername>$LastChangedBy$</othername>
|
---|
| 12 | <date>$Date$</date>
|
---|
[a0f03b0] | 13 | </sect1info>
|
---|
[6ff0105] | 14 | <?dbhtml filename="svnserver.html"?>
|
---|
| 15 | <title>Running a Subversion Server</title>
|
---|
| 16 |
|
---|
| 17 | <sect2>
|
---|
| 18 | <title>Running a Subversion Server</title>
|
---|
[42c74de] | 19 | <para>This section will describe how to set up, administer and secure
|
---|
[7afc6e2] | 20 | a <application>Subversion</application> server.</para>
|
---|
[6ff0105] | 21 |
|
---|
[42c74de] | 22 | <sect3><title><application>Subversion server</application> dependencies</title>
|
---|
| 23 | <sect4><title>Required</title>
|
---|
[01d5424] | 24 | <para><xref linkend="subversion"/> and <xref linkend="openssh"/></para>
|
---|
| 25 | </sect4>
|
---|
[42c74de] | 26 | </sect3>
|
---|
| 27 |
|
---|
| 28 | </sect2>
|
---|
| 29 |
|
---|
| 30 | <sect2>
|
---|
| 31 | <title>Setting up a <application>Subversion</application> server.</title>
|
---|
| 32 |
|
---|
[7afc6e2] | 33 | <para>The following instructions will install a
|
---|
| 34 | <application>Subversion</application> server, which will be set up to
|
---|
| 35 | use <application>OpenSSH</application> as the secure remote access method, with
|
---|
| 36 | <command>svnserve</command> available for anonymous access.</para>
|
---|
[42c74de] | 37 |
|
---|
| 38 | <para>Configuration of the <application>Subversion</application> server
|
---|
| 39 | consists of the following steps:</para>
|
---|
| 40 |
|
---|
[01d5424] | 41 | <sect3><title>1. Setup users, groups, and permissions</title>
|
---|
[42c74de] | 42 | <para>You'll need to be user root for the initial portion of
|
---|
[01d5424] | 43 | configuration. Create the svn user and group with the following
|
---|
[42c74de] | 44 | commands:</para>
|
---|
| 45 |
|
---|
| 46 | <screen><userinput><command>groupadd svn &&
|
---|
| 47 | useradd -c "SVN Owner" -d /home/svn -m -g svn -s /bin/false svn</command></userinput></screen>
|
---|
| 48 |
|
---|
| 49 | <para>If you plan to have multiple repositories, you should have a
|
---|
[01d5424] | 50 | group dedicated to each repository for ease of administration. Create
|
---|
| 51 | the svntest group for the test repository and add the svn user to that
|
---|
[42c74de] | 52 | group with the following commands:</para>
|
---|
| 53 |
|
---|
| 54 | <screen><userinput><command>groupadd svntest &&
|
---|
| 55 | usermod -G svntest svn</command></userinput></screen>
|
---|
| 56 |
|
---|
[01d5424] | 57 | <para>Additionally you should set <command>umask 002</command> while working
|
---|
| 58 | with a repository so that all new files will be writable by owner and group.
|
---|
| 59 | This is made mandatory by creating a wrapper script for
|
---|
[42c74de] | 60 | <command>svn</command> and <command>svnserve</command>:</para>
|
---|
| 61 |
|
---|
| 62 | <screen><userinput><command>mv /usr/bin/svn /usr/bin/svn.orig &&
|
---|
| 63 | mv /usr/bin/svnserve /usr/bin/svnserve.orig &&
|
---|
[5a3d9be7] | 64 | cat >> /usr/bin/svn << "EOF"</command>
|
---|
[42c74de] | 65 | #!/bin/sh
|
---|
| 66 | umask 002
|
---|
| 67 | /usr/bin/svn.orig "$@"
|
---|
| 68 | <command>EOF
|
---|
[5a3d9be7] | 69 | cat >> /usr/bin/svnserve << "EOF"</command>
|
---|
[42c74de] | 70 | #!/bin/sh
|
---|
| 71 | umask 002
|
---|
| 72 | /usr/bin/svnserve.orig "$@"
|
---|
| 73 | <command>EOF
|
---|
| 74 | chmod 0755 /usr/bin/svn{,serve}</command></userinput></screen>
|
---|
| 75 |
|
---|
[01d5424] | 76 | <note><para>If you use <application>Apache</application> for working with
|
---|
| 77 | the repository over <acronym>HTTP</acronym>, even for anonymous access, you
|
---|
| 78 | should wrap <command>/usr/sbin/httpd</command> in a similar
|
---|
| 79 | script.</para></note>
|
---|
[42c74de] | 80 |
|
---|
| 81 | </sect3>
|
---|
| 82 |
|
---|
[01d5424] | 83 | <sect3><title>2. Create a <application>Subversion</application>
|
---|
[42c74de] | 84 | repository.</title>
|
---|
[b8214dc6] | 85 |
|
---|
| 86 | <para>With subversion-1.1.0 and greater, a new type of repository
|
---|
[5a3d9be7] | 87 | data-store is available, <acronym>FSFS</acronym>. There is a tradeoff
|
---|
[b8214dc6] | 88 | for speed with the new backend, however, the repository can now be
|
---|
| 89 | placed on a network mount, and any corruption does not require an
|
---|
| 90 | admin to recover the repository. For more information and comparison
|
---|
| 91 | between <acronym>FSFS</acronym> and <acronym>BDB</acronym>, plese see
|
---|
| 92 | <ulink url="http://svnbook.red-bean.com/svnbook-1.1/ch05.html#svn-ch-5-sect-1.2.A"/>.
|
---|
| 93 | Optionally you can pass <parameter>bdb</parameter> in place of
|
---|
| 94 | <parameter>fsfs</parameter> in the following command to create a
|
---|
| 95 | BerkelyDB data-store.</para>
|
---|
| 96 |
|
---|
[42c74de] | 97 | <para>Create a new <application>Subversion</application> repository with
|
---|
| 98 | the following commands:</para>
|
---|
[01d5424] | 99 |
|
---|
[42c74de] | 100 | <screen><userinput><command>install -d -m0755 /srv &&
|
---|
| 101 | install -d -m0755 -o svn -g svn /srv/svn/repositories &&
|
---|
[b8214dc6] | 102 | svnadmin create --fs-type fsfs /srv/svn/repositories/svntest</command></userinput></screen>
|
---|
[42c74de] | 103 |
|
---|
| 104 | <para>Now that the repository is created, we need to populate it with
|
---|
[01d5424] | 105 | something useful. You'll need to have a predefined directory layout
|
---|
| 106 | setup exactly as you want your repository to look. For example, here
|
---|
[42c74de] | 107 | is a sample BLFS layout setup with a root of <filename>svntest/</filename>.
|
---|
| 108 | You'll need to setup a directory tree similar to the following:</para>
|
---|
| 109 |
|
---|
| 110 | <screen> svntest/ # The name of the repository
|
---|
| 111 | trunk/ # Contains the existing source tree
|
---|
| 112 | BOOK/
|
---|
| 113 | bootscripts/
|
---|
| 114 | edguide/
|
---|
| 115 | patches/
|
---|
| 116 | scripts/
|
---|
| 117 | branches/ # Needed for additional branches
|
---|
| 118 | tags/ # Needed for tagging release points</screen>
|
---|
| 119 |
|
---|
[01d5424] | 120 | <para>Once you've created your directory layout as shown above, you are ready
|
---|
| 121 | to do the initial import:</para>
|
---|
[42c74de] | 122 |
|
---|
| 123 | <screen><userinput><command>svn import -m "Initial import." \
|
---|
| 124 | <replaceable>[/path/to/source/tree]</replaceable> \
|
---|
| 125 | file:///srv/svn/repositories/svntest</command></userinput></screen>
|
---|
| 126 |
|
---|
| 127 | <para>Now go ahead and change owner and group information on the
|
---|
[7afc6e2] | 128 | repository, and add your normal user to the svn and svntest groups:</para>
|
---|
[42c74de] | 129 |
|
---|
| 130 | <screen><userinput><command>chown -R svn:svntest /srv/svn/repositories/svntest &&
|
---|
| 131 | chmod -R g+w /srv/svn/repositories/svntest &&
|
---|
| 132 | chmod g+s /srv/svn/repositories/svntest/db &&
|
---|
| 133 | usermod -G svn,svntest,<replaceable>[insert existing groups]</replaceable> <replaceable>[username]</replaceable></command></userinput></screen>
|
---|
| 134 |
|
---|
[01d5424] | 135 | <para>svntest is the group assigned to the svntest repository. As
|
---|
[7afc6e2] | 136 | mentioned earlier, this eases administration of multiple repositories
|
---|
[01d5424] | 137 | when using <application>OpenSSH</application> for authentication. Going
|
---|
[7afc6e2] | 138 | forward, you'll need to add your regular user, and any additional users
|
---|
| 139 | that you wish to have write access to the repository, to the svn and
|
---|
[42c74de] | 140 | svntest groups.</para>
|
---|
| 141 |
|
---|
| 142 | <para>In addition, you'll notice that the new repository's
|
---|
[01d5424] | 143 | <filename>db</filename> directory is set-groupID. If the reasoning is
|
---|
[42c74de] | 144 | not immediately obvious, when using any external authentication method
|
---|
[01d5424] | 145 | (such as <command>ssh</command>), the sticky bit is set so that all new files
|
---|
| 146 | will be owned by the user, but group of svntest. Anyone in the svntest group
|
---|
| 147 | can create files, but still give the entire group write access to those
|
---|
| 148 | files. This avoids locking out other users from the repository.</para>
|
---|
[42c74de] | 149 |
|
---|
| 150 | <para>Now, go ahead and return to your normal user account, and take a look at
|
---|
[7afc6e2] | 151 | your new repository using <command>svnlook</command>:</para>
|
---|
[42c74de] | 152 |
|
---|
| 153 | <screen><userinput><command>svnlook tree /srv/svn/repositories/svntest/</command></userinput></screen>
|
---|
| 154 |
|
---|
[01d5424] | 155 | <note><para>You may need to log out and back in again to refresh your group
|
---|
| 156 | memberships. '<command>su <replaceable>[username]</replaceable></command>'
|
---|
[7afc6e2] | 157 | should work around this as well.</para></note>
|
---|
[42c74de] | 158 |
|
---|
| 159 | </sect3>
|
---|
| 160 |
|
---|
[01d5424] | 161 | <sect3><title>3. Configure the server</title>
|
---|
[42c74de] | 162 |
|
---|
[7afc6e2] | 163 | <para>As mentioned previously, these instructions will configure the
|
---|
[01d5424] | 164 | server to use only <command>ssh</command> for write access to the repository
|
---|
| 165 | and to provide anonymous access using <command>svnserve</command>. There are
|
---|
| 166 | several other ways to provide access to the repository. These additional
|
---|
| 167 | configurations are best explained at
|
---|
| 168 | <ulink url="http://svnbook.red-bean.com/"/>.</para>
|
---|
[42c74de] | 169 |
|
---|
[01d5424] | 170 | <para>Access configuration needs to be done for each repository. Create
|
---|
[42c74de] | 171 | the <filename>svnserve.conf</filename> file for the svntest repository
|
---|
| 172 | using the following commands:</para>
|
---|
| 173 |
|
---|
| 174 | <screen><userinput><command>cp /srv/svn/repositories/svntest/conf/svnserve.conf \
|
---|
| 175 | /srv/svn/repositories/svntest/conf/svnserve.conf.default &&
|
---|
| 176 | cat > /srv/svn/repositories/svntest/conf/svnserve.conf << "EOF"</command>
|
---|
| 177 | [general]
|
---|
| 178 | anon-access = read
|
---|
| 179 | auth-access = write
|
---|
| 180 | <command>EOF</command></userinput></screen>
|
---|
| 181 |
|
---|
[01d5424] | 182 | <para>There is not a lot to the configuration file at all. You'll notice
|
---|
| 183 | that only the general section is required. Take a look at the
|
---|
| 184 | <filename>svnserve.conf.default</filename> file for information on using
|
---|
[42c74de] | 185 | <command>svnserve</command>'s built-in authentication method.</para>
|
---|
| 186 |
|
---|
| 187 | </sect3>
|
---|
| 188 |
|
---|
[01d5424] | 189 | <sect3><title>4. Starting the server</title>
|
---|
| 190 | <para>There are a couple of ways to start <command>svnserve</command>. The
|
---|
| 191 | most common way is to start it as an <command>inetd</command> or
|
---|
| 192 | <command>xinetd</command> process. Alternately, you can use a
|
---|
[42c74de] | 193 | bootscript to start the service at startup.</para>
|
---|
| 194 |
|
---|
[7afc6e2] | 195 | <note><para>If you do not wish to provide anonymous access to your svn
|
---|
| 196 | repositories or use <command>svnserve</command>'s built-in
|
---|
| 197 | authentication, you do not need to run
|
---|
| 198 | <command>svnserve</command>.</para></note>
|
---|
| 199 |
|
---|
[01d5424] | 200 | <para>If you use <command>inetd</command>, add a line to
|
---|
[42c74de] | 201 | <filename>/etc/inetd.conf</filename> using the following commands:</para>
|
---|
| 202 |
|
---|
| 203 | <screen><userinput><command>cat >> /etc/inetd.conf << "EOF"</command>
|
---|
| 204 | svn stream tcp nowait svn /usr/bin/svnserve svnserve -i
|
---|
| 205 | <command>EOF</command></userinput></screen>
|
---|
| 206 |
|
---|
[01d5424] | 207 | <para>If you use <command>xinetd</command>, add the following
|
---|
| 208 | lines to the <filename>/etc/xinetd.conf</filename> file:</para>
|
---|
[42c74de] | 209 |
|
---|
| 210 | <screen><userinput><command>cat >> /etc/xinetd.conf << "EOF"</command>
|
---|
| 211 | service svn
|
---|
| 212 | {
|
---|
| 213 | port = 3690
|
---|
| 214 | socket_type = stream
|
---|
| 215 | protocol = tcp
|
---|
| 216 | wait = no
|
---|
| 217 | user = svn
|
---|
| 218 | server = /usr/bin/svnserve
|
---|
| 219 | server_args = -i -r /srv/svn/repositories
|
---|
| 220 | }
|
---|
| 221 | <command>EOF</command></userinput></screen>
|
---|
| 222 |
|
---|
[b8214dc6] | 223 | <para>Finally, if you wish to simply start the sever at
|
---|
[42c74de] | 224 | startup, install the svn bootscript included in the
|
---|
| 225 | <xref linkend="intro-important-bootscripts"/> package.</para>
|
---|
| 226 |
|
---|
| 227 | <screen><userinput><command>make install-svn</command></userinput></screen>
|
---|
| 228 |
|
---|
| 229 | </sect3>
|
---|
[6ff0105] | 230 |
|
---|
| 231 | </sect2>
|
---|
| 232 |
|
---|
| 233 | </sect1>
|
---|
| 234 |
|
---|