source: general/prog/svnserver.xml@ a206343

10.0 10.1 11.0 11.1 11.2 11.3 12.0 12.1 8.4 9.0 9.1 bdubbs/svn elogind kea ken/TL2024 ken/inkscape-core-mods ken/tuningfonts lazarus lxqt plabs/newcss plabs/python-mods python3.11 qt5new rahul/power-profiles-daemon renodr/vulkan-addition trunk upgradedb xry111/intltool xry111/llvm18 xry111/soup3 xry111/test-20220226 xry111/xf86-video-removal
Last change on this file since a206343 was 0098ace6, checked in by DJ Lucas <dj@…>, 8 years ago

[Systemd merge] - Chapter 13

git-svn-id: svn://svn.linuxfromscratch.org/BLFS/trunk/BOOK@17468 af4574ff-66df-0310-9fd7-8a98e5e911e0

  • Property mode set to 100644
File size: 10.1 KB
Line 
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 <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
47 <para>You'll need to be user
48 <systemitem class='username'>root</systemitem> for the initial portion of
49 configuration. Create the <systemitem class="username">svn</systemitem>
50 user and group with the following commands:</para>
51
52<screen role="root"><userinput>groupadd -g 56 svn &amp;&amp;
53useradd -c "SVN Owner" -d /home/svn -m -g svn -s /bin/false -u 56 svn</userinput></screen>
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
61<screen role="root"><userinput>groupadd -g 57 svntest &amp;&amp;
62usermod -G svntest -a 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 &amp;&amp;
70mv /usr/bin/svnserve /usr/bin/svnserve.orig &amp;&amp;
71cat &gt;&gt; /usr/bin/svn &lt;&lt; "EOF"
72<literal>#!/bin/sh
73umask 002
74/usr/bin/svn.orig "$@"</literal>
75EOF
76cat &gt;&gt; /usr/bin/svnserve &lt;&lt; "EOF"
77<literal>#!/bin/sh
78umask 002
79/usr/bin/svnserve.orig "$@"</literal>
80EOF
81chmod 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>
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.
100 </para>
101
102 <para>
103 Create a new <application>Subversion</application> repository with
104 the following commands (as the <systemitem class="username">root
105 </systemitem> user):
106 </para>
107
108<screen role="root"><userinput>install -v -m 0755 -d /srv/svn &amp;&amp;
109install -v -m 0755 -o svn -g svn -d /srv/svn/repositories &amp;&amp;
110svnadmin create /srv/svn/repositories/svntest</userinput></screen>
111
112 <para>Now that the repository is created, it should be populated with
113 something useful. You'll need to have a predefined directory
114 layout set up 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>
118
119<screen><literal>svntest/ # The name of the repository
120 trunk/ # Contains the existing source tree
121 BOOK/
122 bootscripts/
123 edguide/
124 patches/
125 scripts/
126 branches/ # Needed for additional branches
127 tags/ # Needed for tagging release points</literal></screen>
128
129 <para>Once you've created your directory layout as shown above, you
130 are ready to do the initial import:</para>
131
132<screen role="root"><userinput>svn import -m "Initial import." \
133 <replaceable>&lt;/path/to/source/tree&gt;</replaceable> \
134 file:///srv/svn/repositories/svntest</userinput></screen>
135
136 <para>Now change owner and group information on the
137 repository, and add an unprivileged user to the
138 <systemitem class="groupname">svn</systemitem> and
139 <systemitem class="groupname">svntest</systemitem> groups:</para>
140
141<screen role="root"><userinput>chown -R svn:svntest /srv/svn/repositories/svntest &amp;&amp;
142chmod -R g+w /srv/svn/repositories/svntest &amp;&amp;
143chmod g+s /srv/svn/repositories/svntest/db &amp;&amp;
144usermod -G svn,svntest -a <replaceable>&lt;username&gt;</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,
150 you'll need to add your unprivileged user, and any additional users that
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
165 <para>Now, return to an unprivileged user account, and take a
166 look at the 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>&lt;username&gt;</replaceable></command>'
173 should work 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 &amp;&amp;
194
195cat &gt; /srv/svn/repositories/svntest/conf/svnserve.conf &lt;&lt; "EOF"
196<literal>[general]
197anon-access = read
198auth-access = write</literal>
199EOF</userinput></screen>
200
201 <para>There is not a lot to the configuration file at all. You'll
202 notice that only the general section is required. Take a look at the
203 <filename>svnserve.conf.default</filename> file for information on using
204 <command>svnserve</command>'s built-in authentication method.</para>
205
206 </sect3>
207
208 <sect3 id="svnserver-init">
209 <title>4. Starting the Server</title>
210
211 <para revision="sysv">To start the server at boot time, install the svn
212 bootscript included in the <xref linkend="bootscripts"/> package.</para>
213
214 <para revision="systemd">To start the server at boot time, install the
215 <filename>svnserve.service</filename> unit from the
216 <xref linkend="systemd-units"/> package.</para>
217
218 <indexterm zone="svnserver svnserver-init" revision="sysv">
219 <primary sortas="f-svn">svn</primary>
220 </indexterm>
221
222<screen role="root" revision="sysv"><userinput>make install-svn</userinput></screen>
223
224 <indexterm zone="svnserver svnserver-init" revision="systemd">
225 <primary sortas="f-svnserve">svnserve</primary>
226 </indexterm>
227
228<screen role="root" revision="systemd"><userinput>make install-svnserve</userinput></screen>
229
230 <para revision="systemd">Additionally, the instructions above require
231 that svn server uses <command>umask 002</command> so that all new files
232 will be writable by owner and group. This can be achieved by creating
233 a systemd unit override file by running the following command:</para>
234
235<screen role="root" revision="systemd"><userinput>mkdir -p /etc/systemd/system/svnserve.service.d
236echo "UMask=0002" > /etc/systemd/system/svnserve.service.d/99-user.conf</userinput></screen>
237
238 <para revision="systemd">Options which are passed to
239 <command>svnserve</command> daemon can be changed in
240 <filename>/etc/default/svnserve</filename>.</para>
241
242 </sect3>
243
244 </sect2>
245
246</sect1>
Note: See TracBrowser for help on using the repository browser.