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