[6ff0105] | 1 | <?xml version="1.0" encoding="ISO-8859-1"?>
|
---|
[6732c094] | 2 | <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
|
---|
| 3 | "http://www.oasis-open.org/docbook/xml/4.5/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 &&
|
---|
[3a79861] | 62 | usermod -G svntest -a svn</userinput></screen>
|
---|
[eae0107f] | 63 |
|
---|
[2037ec4] | 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 &&
|
---|
| 70 | mv /usr/bin/svnserve /usr/bin/svnserve.orig &&
|
---|
| 71 | cat >> /usr/bin/svn << "EOF"
|
---|
| 72 | <literal>#!/bin/sh
|
---|
| 73 | umask 002
|
---|
| 74 | /usr/bin/svn.orig "$@"</literal>
|
---|
| 75 | EOF
|
---|
| 76 | cat >> /usr/bin/svnserve << "EOF"
|
---|
| 77 | <literal>#!/bin/sh
|
---|
| 78 | umask 002
|
---|
| 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 |
|
---|
[eae0107f] | 89 | </sect3>
|
---|
| 90 |
|
---|
| 91 | <sect3>
|
---|
| 92 | <title>2. Create a Subversion repository.</title>
|
---|
| 93 |
|
---|
[678c25bd] | 94 | <para>
|
---|
| 95 | There are several ways to set up a subversion repository. It is
|
---|
| 96 | recommended to have a look at the <ulink
|
---|
| 97 | url="http://svnbook.red-bean.com/nightly/en/svn.reposadmin.html">SVN
|
---|
| 98 | Book</ulink> corresponding chapter. A basic repository can be set up
|
---|
| 99 | with the instructions below.
|
---|
[cf5c43f3] | 100 | </para>
|
---|
[eae0107f] | 101 |
|
---|
| 102 | <para>Create a new <application>Subversion</application> repository with
|
---|
| 103 | the following commands:</para>
|
---|
| 104 |
|
---|
[975fb37e] | 105 | <screen role="root"><userinput>install -v -m 0755 -d /srv/svn &&
|
---|
[cf5c43f3] | 106 | install -v -m 0755 -o svn -g svn -d /srv/svn/repositories &&
|
---|
[678c25bd] | 107 | svnadmin create /srv/svn/repositories/svntest</userinput></screen>
|
---|
[42c74de] | 108 |
|
---|
[cf5c43f3] | 109 | <para>Now that the repository is created, it should be populated with
|
---|
[678c25bd] | 110 | something useful. You'll need to have a predefined directory
|
---|
[cf5c43f3] | 111 | layout set up exactly as you want your repository to look. For
|
---|
[eae0107f] | 112 | example, here is a sample BLFS layout setup with a root of
|
---|
| 113 | <filename>svntest/</filename>. You'll need to setup a directory
|
---|
| 114 | tree similar to the following:</para>
|
---|
[42c74de] | 115 |
|
---|
[efd03f7] | 116 | <screen><literal>svntest/ # The name of the repository
|
---|
| 117 | trunk/ # Contains the existing source tree
|
---|
| 118 | BOOK/
|
---|
| 119 | bootscripts/
|
---|
| 120 | edguide/
|
---|
| 121 | patches/
|
---|
| 122 | scripts/
|
---|
| 123 | branches/ # Needed for additional branches
|
---|
| 124 | tags/ # Needed for tagging release points</literal></screen>
|
---|
[42c74de] | 125 |
|
---|
[eae0107f] | 126 | <para>Once you've created your directory layout as shown above, you
|
---|
| 127 | are ready to do the initial import:</para>
|
---|
[42c74de] | 128 |
|
---|
[eae0107f] | 129 | <screen role="root"><userinput>svn import -m "Initial import." \
|
---|
[efd03f7] | 130 | <replaceable></path/to/source/tree></replaceable> \
|
---|
[eae0107f] | 131 | file:///srv/svn/repositories/svntest</userinput></screen>
|
---|
[42c74de] | 132 |
|
---|
[cf5c43f3] | 133 | <para>Now change owner and group information on the
|
---|
[e615d9b] | 134 | repository, and add an unprivileged user to the
|
---|
[eae0107f] | 135 | <systemitem class="groupname">svn</systemitem> and
|
---|
| 136 | <systemitem class="groupname">svntest</systemitem> groups:</para>
|
---|
[42c74de] | 137 |
|
---|
[efd03f7] | 138 | <screen role="root"><userinput>chown -R svn:svntest /srv/svn/repositories/svntest &&
|
---|
| 139 | chmod -R g+w /srv/svn/repositories/svntest &&
|
---|
| 140 | chmod g+s /srv/svn/repositories/svntest/db &&
|
---|
[3a79861] | 141 | usermod -G svn,svntest -a <replaceable><username></replaceable></userinput></screen>
|
---|
[eae0107f] | 142 |
|
---|
| 143 | <para><systemitem class="groupname">svntest</systemitem> is the group
|
---|
| 144 | assigned to the svntest repository. As mentioned earlier, this eases
|
---|
| 145 | administration of multiple repositories when using
|
---|
| 146 | <application>OpenSSH</application> for authentication. Going forward,
|
---|
[4c288b0] | 147 | you'll need to add your unprivileged user, and any additional users that
|
---|
[eae0107f] | 148 | you wish to have write access to the repository, to the
|
---|
| 149 | <systemitem class="groupname">svn</systemitem> and
|
---|
| 150 | <systemitem class="groupname">svntest</systemitem> groups.</para>
|
---|
| 151 |
|
---|
| 152 | <para>In addition, you'll notice that the new repository's
|
---|
| 153 | <filename>db</filename> directory is set-groupID. If the reasoning is
|
---|
| 154 | not immediately obvious, when using any external authentication method
|
---|
| 155 | (such as <command>ssh</command>), the sticky bit is set so that all
|
---|
| 156 | new files will be owned by the user, but group of
|
---|
| 157 | <systemitem class="groupname">svntest</systemitem>. Anyone in the
|
---|
| 158 | <systemitem class="groupname">svntest</systemitem> group can create
|
---|
| 159 | files, but still give the entire group write access to those
|
---|
| 160 | files. This avoids locking out other users from the repository.</para>
|
---|
| 161 |
|
---|
[cf5c43f3] | 162 | <para>Now, return to an unprivileged user account, and take a
|
---|
| 163 | look at the new repository using <command>svnlook</command>:</para>
|
---|
[eae0107f] | 164 |
|
---|
| 165 | <screen><userinput>svnlook tree /srv/svn/repositories/svntest/</userinput></screen>
|
---|
| 166 |
|
---|
| 167 | <note>
|
---|
| 168 | <para>You may need to log out and back in again to refresh your group
|
---|
[3cb0c57] | 169 | memberships. '<command>su <replaceable><username></replaceable></command>'
|
---|
[c5923846] | 170 | should work as well.</para>
|
---|
[eae0107f] | 171 | </note>
|
---|
| 172 |
|
---|
| 173 | </sect3>
|
---|
| 174 |
|
---|
| 175 | <sect3>
|
---|
| 176 | <title>3. Configure the Server</title>
|
---|
| 177 |
|
---|
| 178 | <para>As mentioned previously, these instructions will configure the
|
---|
| 179 | server to use only <command>ssh</command> for write access to the
|
---|
| 180 | repository and to provide anonymous access using
|
---|
| 181 | <command>svnserve</command>. There are several other ways to provide
|
---|
| 182 | access to the repository. These additional configurations are best
|
---|
| 183 | explained at <ulink url="http://svnbook.red-bean.com/"/>.</para>
|
---|
| 184 |
|
---|
| 185 | <para>Access configuration needs to be done for each repository.
|
---|
| 186 | Create the <filename>svnserve.conf</filename> file for the svntest
|
---|
| 187 | repository using the following commands:</para>
|
---|
| 188 |
|
---|
| 189 | <screen role="root"><userinput>cp /srv/svn/repositories/svntest/conf/svnserve.conf \
|
---|
[efd03f7] | 190 | /srv/svn/repositories/svntest/conf/svnserve.conf.default &&
|
---|
| 191 |
|
---|
[eae0107f] | 192 | cat > /srv/svn/repositories/svntest/conf/svnserve.conf << "EOF"
|
---|
| 193 | <literal>[general]
|
---|
| 194 | anon-access = read
|
---|
| 195 | auth-access = write</literal>
|
---|
| 196 | EOF</userinput></screen>
|
---|
[42c74de] | 197 |
|
---|
[eae0107f] | 198 | <para>There is not a lot to the configuration file at all. You'll
|
---|
| 199 | notice that only the general section is required. Take a look at the
|
---|
| 200 | <filename>svnserve.conf.default</filename> file for information on using
|
---|
| 201 | <command>svnserve</command>'s built-in authentication method.</para>
|
---|
[42c74de] | 202 |
|
---|
[eae0107f] | 203 | </sect3>
|
---|
[42c74de] | 204 |
|
---|
[eae0107f] | 205 | <sect3 id="svnserver-init">
|
---|
| 206 | <title>4. Starting the Server</title>
|
---|
[42c74de] | 207 |
|
---|
[ab4735a7] | 208 | <para>
|
---|
| 209 | To start the <command>svnserve</command> daemon at boot,
|
---|
| 210 | install the systemd unit from the <xref linkend="bootscripts"/>
|
---|
| 211 | package by running the following command as the
|
---|
| 212 | <systemitem class="username">root</systemitem> user:
|
---|
| 213 | </para>
|
---|
[42c74de] | 214 |
|
---|
[eae0107f] | 215 | <indexterm zone="svnserver svnserver-init">
|
---|
[ab4735a7] | 216 | <primary sortas="f-svnserve">svnserve</primary>
|
---|
[eae0107f] | 217 | </indexterm>
|
---|
[42c74de] | 218 |
|
---|
[ab4735a7] | 219 | <screen role="root"><userinput>make install-svnserve</userinput></screen>
|
---|
| 220 |
|
---|
| 221 | <para>Additionally, the instructions above require that svn server
|
---|
| 222 | uses <command>umask 002</command> so that all new files will
|
---|
| 223 | be writable by owner and group. This can be achieved by creating
|
---|
| 224 | a systemd unit override file by running the following command:</para>
|
---|
| 225 |
|
---|
| 226 | <screen role="root"><userinput>mkdir -p /etc/systemd/system/svnserve.service.d
|
---|
| 227 | echo "UMask=0002" > /etc/systemd/system/svnserve.service.d/99-user.conf</userinput></screen>
|
---|
| 228 |
|
---|
| 229 | <para>Options which are passed to <command>svnserve</command> daemon
|
---|
| 230 | can be changed in <filename>/etc/default/svnserve</filename>.</para>
|
---|
[6ff0105] | 231 |
|
---|
[eae0107f] | 232 | </sect3>
|
---|
[6ff0105] | 233 |
|
---|
[eae0107f] | 234 | </sect2>
|
---|
[6ff0105] | 235 |
|
---|
[eae0107f] | 236 | </sect1>
|
---|