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