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