Youry's Blog

Youry's Blog

CVS server on CENTOS

leave a comment »

updated from Set Up CVS Server on Linux http://is.gd/W35qfq (some mistakes and some problems found)

Assumption: server: s.com   client: c.com
Goal: user mike can use the CVS on s.com (assumption: mike has an account as “mike” on s.com)

At the first we need to create users:

in MS Excel

useradd -c <comment> <username> -G cvs

=CONCATENATE(“useradd -c “,LOWER(LEFT(RIGHT(B7,LEN(B7)-FIND(“,”,B7)-1),1)&(LEFT(B7,FIND(“,”,B7)-1))))

change password

=CONCATENATE(“echo “,CHAR(34),LOWER(LEFT(RIGHT(B7,LEN(B7)-FIND(“,”,B7)-1),1)&(LEFT(B7,FIND(“,”,B7)-1))),”:”,E7,CHAR(34),” | chpasswd”)

++++++++++

Steps:
1. install cvs and xinetd on the server
$yum install cvs
$yum install xinetd

NOTE: check whether cvs (or xinetd) has been installed:
$rpm -qa | grep cvs

2. set up cvs group and user on the server:
$groupadd cvs
$useradd -g cvs -G cvs -d /home/cvsroot cvsroot
$passwd cvsroot # set up password for cvsroot

Add mike to the cvs group:
$usermod -G mike cvs

Check whether mike is in the cvs group:
$groups mike

3. change owner of /home/cvsroot if necessary, chmod for /home/cvsroot:
$chown -R cvsroot:cvs /home/cvsroot
$chmod -R 775 /home/cvsroot

4. initialize cvs:
(login as cvsroot)
$cd /home/cvsroot
$cvs -d /home/cvsroot init  # full path is required
$chmod 644 /home/cvsroot/CVSROOT/config

5. create file for CVS self-startup, as xinetd type
(login as root)
$cd /etc/xinetd.d
$cp cvs cvspserver
$vim cvspserver  # do the following modifications:

# default: off
# description: The CVS service can record the history of your source \
#              files. CVS stores all the versions of a file in a single \
#              file in a clever way that only stores the differences \
#              between versions.
service cvspserver
{
disable                 = no             # modify
port                       = 2401
socket_type       = stream
protocol               = tcp
wait                       = no
user                       = root
passenv               = PATH
server                   = /usr/bin/cvs
env                         = HOME=/home/cvsroot    # modify
server_args        = -f –allow-root=/home/cvsroot pserver    # modify
}

6. add CVS as a service:
$vim /etc/services

Add two lines if not in the file:
cvspserver 2401/tcp #pserver cvs service
cvspserver 2401/udp #pserver cvs service

7. restart xinetd:
$/etc/init.d/xinetd restart

8. check if cvspserver has started
$netstat -l |grep cvspserver

should return:
tcp   0    0            *:cvspserver           *:*               LISTEN

9. manage users
$cp /etc/shadow /home/cvsroot/CVSROOT/passwd   # owner of passwd should be cvsroot:cvs
($cd /home/cvsroot/CVSROOT)
$chmod 644 passwd

modify passwd, delete all lines except users cvsroot and mike (you can keep some lines if needed)
for every line, delete all the content after the second “:”, and append cvsroot to that “:”

10. on client c.com, log in to the CVS server:
$export CVSROOT=:pserver:mike@s.com:2401/home/cvsroot
$cvs login

11. on client c.com, import a project /home/mike/myproject onto CVS server:
$cd /home/mike/myproject
$cvs import -m “my project” myproject mike start

12. errors:
1) As follows:
[mike@c.com ~]$ cvs -d :pserver:mike@s.com:/home/cvsroot login
Logging in to :pserver:mike@s.com:2401/home/cvsroot
CVS password:
cvs [login aborted]: unrecognized auth response from localhost: cvs pserver: cannot open /home/cvsroot/CVSROOT/config: Permission denied

Solution: turn off SELinux on s.com.
Turn it off now:
$setenforce 0

Turn it off after next restart:
$vim /etc/selinux/config
modify SELINUX=enforcing to
SELINUX=disabled

2) As follows:
[mike@c.com ~]$ cvs login
Logging in to :pserver:mike@s.com:2401/home/cvsroot
CVS password:
cvs [login aborted]: connect to [s.com]:2401 failed: No route to host

Solution: turn off firewall on s.com, or allow 2401 port in the firewall
Turn off firewall now:
service iptables stop

Turn off firewall after next restart:
$chkconfig iptables off   # or $/sbin/chkconfig –level 2345 iptables off

Check firewall status:
$/etc/init.d/iptables status

NOTE: This method applies on Fedora 12 for CVS server

References:
[1]http://blog.chinaunix.net/u/19742/showart_2256544.html
[2]http://peak.javaeye.com/blog/200035
[3]http://blog.csdn.net/do/archive/2008/07/18/2674272.aspx
[4]http://www.zzxj.net/blog/fxs_2008/archive/2010/08/24/198.html
[5]http://prewind.blogbus.com/logs/1029157.html  (CVS 常用操作 Howto)

Advertisements

Written by youryblog

September 28, 2013 at 5:20 PM

Posted in Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: