CVS 服務(wù)器的安裝配置以及使用 redhat9
作者: Khan
時(shí)間: 2006-1-9
環(huán)境: 服務(wù)器 Redhat 9.1? ,客戶端 :window 2000 pro
因?yàn)橛袀€(gè)項(xiàng)目要多人合作,所以選擇了cvs, 其實(shí)有其他選擇,如subversion,但是資料少所以只有使用這個(gè)
早上9:00 - 15:00 終于配置完了服務(wù)器端和客戶端,并建立了一個(gè)倉(cāng)庫(kù)使用,就將一些安裝使用的心得歸納
了下來
一 CVS服務(wù)器的安裝:
1.查看你的操作系統(tǒng)上是否安裝了CVS:
#> rpm -qa|grep cvs
2.建立cvs用戶組:
#> groupadd cvs
3.建立cvs組的cvsroot用戶和所屬的目錄:
#> useradd cvsroot -g cvs
4.為cvsroot用戶添加密碼:
#> passwd cvsroot
5.改變 /cvsroot/ 的目錄屬性:
#> chmod –R 770 /cvsroot
6.改變用戶登陸身份:
#> su cvsroot
7.開始創(chuàng)建單個(gè)項(xiàng)目:
#> cd /home/cvsroot
#> mkdir smscgw
#> mkdir smgp
8.開始建立倉(cāng)庫(kù):
這里我建立了兩個(gè)倉(cāng)庫(kù),用以介紹用戶名,密碼的設(shè)置方法
cvs –d /home/cvsroot/smscgw init
cvs –d /home/cvsroot/smgp init
#> chmod –R 770 ./smscgw/ ./smgp/
9.建立CVS服務(wù)啟動(dòng)文件,我們使用xinetd方式:
#> su - root 切換到root用戶身份
#> cd /etc/xinetd.d
#> vi cvspserver
service cvspserver
{
? disable = no
? flags = REUSE
? socket_type = stream
? wait = no
? user = root
? server= /usr/bin/cvs
? server_args= -f --allow-root=/home/cvsroot/smscgw --allow-root=/home/cvsroot/smgp pserver
? log_on_failure += USERID
}
10.加入cvs服務(wù):
#>vi /etc/services
cvspserver 2401/tcp #pserver cvs service
cvspserver 2401/udp #pserver cvs service
11。啟動(dòng)cvs服務(wù):
#> /etc/init.d/xinetd restart
12.檢查cvspserver服務(wù)是否已經(jīng)啟動(dòng):
#> netstat -l |grep cvspserver
應(yīng)該有如下結(jié)果:
tcp 0 0 *:cvspserver *:* LISTEN
二.CVS服務(wù)的用戶管理:
1.創(chuàng)建可以登陸cvs服務(wù)器的用戶名和密碼:
#> su cvsroot
#> vi /home/cvsroot/smscgw/CVSROOT/passwd
trotter:*****:cvsroot
mimi:*****:cvsroot
#>vi /home/cvsroot/smgp/CVSROOT/passwd
trotter:*****:cvsroot
gary:*****:cvsroot
這兩個(gè)文件的意思是有trotter,mimi,gary三個(gè)cvs用戶,mimi擁有smscgw的使用權(quán)限,gary擁有smgp的使用權(quán)限,trotter擁有project1和project2的使用權(quán)限。登陸后的權(quán)限是cvsroot權(quán)限。
注意:這里的cvs用戶和系統(tǒng)用戶是不同的。
2.*****為密碼,由以下文件生成:
#> vi /home/cvsroot/smscgw/passwd.pl
#!/usr/bin/perl
srand (time());
my $randletter = "(int (rand (26)) + (int (rand (1) + .5) % 2 ? 65 : 97))";
my $salt = sprintf ("%c%c", eval $randletter, eval $randletter);
my $plaintext = shift;
my $crypttext = crypt ($plaintext, $salt);
print "${crypttext}
";
#>chmod a+x ./passwd.pl
3.如果你想生成一個(gè)密碼是"123456",則:
#> /cvsroot/passwd.pl "123456"
回車即可得到加密密碼,用其替換passwd文件中的*****
4.配置倉(cāng)庫(kù)
以smscgw倉(cāng)庫(kù)為例
#> cvs –d /home/cvsroot/smscgw init 這個(gè)指令執(zhí)行成功的話,會(huì)產(chǎn)生/home/cvsroot/smscgw/CVSROOT這個(gè)目錄
編輯modules模塊文件(直接在服務(wù)器上用vi編輯,也可以用cvs客戶端將CVSROOT導(dǎo)出后,本地編輯,然后提交)
#> vi /home/cvsroot/smscgw/CVSROOT/modules
# Three different line formats are valid:
#?? ?key?? ?-a??? aliases...
#?? ?key [options] directory
#?? ?key [options] directory files...
#
#????? 模塊名 [options] ?
?????? SMSCGW??? -a???????? smscgw3
# 其他選項(xiàng)
# Where "options" are composed of:
#?? ?-i prog?? ??? ?Run "prog" on "cvs commit" from top-level of module.
#?? ?-o prog?? ??? ?Run "prog" on "cvs checkout" of module.
#?? ?-e prog?? ??? ?Run "prog" on "cvs export" of module.
#?? ?-t prog?? ??? ?Run "prog" on "cvs rtag" of module.
#?? ?-u prog?? ??? ?Run "prog" on "cvs update" of module.
#?? ?-d dir?? ??? ?Place module in directory "dir" instead of module name.
#?? ?-l?? ??? ?Top-level directory only -- do not recurse.
#
# NOTE:? If you change any of the "Run" options above, you'll have to
# release and re-checkout any working directories of these modules.
#
# And "directory" is a path to a directory relative to $CVSROOT.
#
# The "-a" option specifies an alias.? An alias is interpreted as if
# everything on the right of the "-a" had been typed on the command line.
#
# You can encode a module within a module by using the special '&'
# character to interpose another module into the current module.? This
# can be useful for creating a module that consists of many directories
# spread out over the entire source repository.
三.使用
1.將本地工程導(dǎo)入到遠(yuǎn)程倉(cāng)庫(kù)
以windows 下的cvs客戶端為例,我使用的是TortoiseCVS 這個(gè)軟件,一個(gè)嵌入Explorer的客戶端
在你需要導(dǎo)入到服務(wù)器的工程目錄上點(diǎn)鼠標(biāo)右鍵,選擇 cvs-->創(chuàng)建新模塊
選擇協(xié)議,輸入帳號(hào)密碼,端口,倉(cāng)庫(kù)文件夾,模塊名
也可以選擇在CVSROOT輸入框中輸入:pserver:username:password@ip:port/home/cvsroot/repository/smscgw
注意目錄結(jié)構(gòu)父目錄和子目錄最好不要重名,也就是說最好不要出現(xiàn) smscgw/smscgw這樣的目錄結(jié)構(gòu)
輸入完以后選擇 "確定"
成功導(dǎo)入,該文件夾會(huì)有一個(gè)綠色的小標(biāo)志,進(jìn)入該目錄,鼠標(biāo)右鍵 "CVS添加",將需要導(dǎo)入的文件添加到倉(cāng)庫(kù)
2.將遠(yuǎn)程倉(cāng)庫(kù)導(dǎo)出到本地
在任何一個(gè)目錄下 鼠標(biāo)右鍵 CVS取出
輸入相應(yīng)的信息, 選擇"確定"