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