centos 7.5 安裝svn配置hooks

1.安裝

yum?install?subversion

2.檢查是否安裝成功

svnserve?–version

3.創(chuàng)建倉庫目錄

mkdir –p?/home/svn/test

4.創(chuàng)建項(xiàng)目

svnadmin?create?/home/svn/test

5.檢查是否創(chuàng)建成功

cd/home/svn/testll

如果成功,test目錄下會(huì)多出幾個(gè)文件夾


6.進(jìn)入conf目錄會(huì)看到3個(gè)配置文件拐袜,生成的文件中都有英文注釋說明

authz:用戶權(quán)限配置


### This file is an example authorization file for svnserve.

### Its format is identical to that of mod_authz_svn authorization

### files.

### As shown below each section defines authorizations for the path and

### (optional) repository specified by the section name.

### The authorizations follow. An authorization line can refer to:

###? - a single user,

###? - a group of users defined in a special [groups] section,

###? - an alias defined in a special [aliases] section,

###? - all authenticated users, using the '$authenticated' token,

###? - only anonymous users, using the '$anonymous' token,

###? - anyone, using the '*' wildcard.

###

### A match can be inverted by prefixing the rule with '~'. Rules can

### grant read ('r') access, read-write ('rw') access, or no access

### ('').

[aliases]

# joe = /C=XZ/ST=Dessert/L=Snake City/O=Snake Oil, Ltd./OU=Research Institute/CN=Joe Average

[groups]

# harry_and_sally = harry,sally

# harry_sally_and_joe = harry,sally,&joe

[/]

testusername = rw

# [/foo/bar]

# harry = rw

# &joe = r

# * =

# [repository:/baz/fuz]

# @harry_and_sally = rw

# * = r


passwd:用戶密碼

### This file is an example password file for svnserve.

### Its format is similar to that of svnserve.conf. As shown in the

### example below it contains one section labelled [users].

### The name and password for each user follow, one account per line.

[users]

# harry = harryssecret

# sally = sallyssecret

testusername =123456

svnserve.conf:

### This file controls the configuration of the svnserve daemon, if you

### use it to allow access to this repository.? (If you only allow

### access through http: and/or file: URLs, then this file is

### irrelevant.)

### Visit http://subversion.tigris.org/ for more information.

[general]

### These options control access to the repository for unauthenticated

### and authenticated users.? Valid values are "write", "read",

### and "none".? The sample settings below are the defaults.

anon-access = read

auth-access = write

### The password-db option controls the location of the password

### database file.? Unless you specify a path starting with a /,

### the file's location is relative to the directory containing

### this configuration file.

### If SASL is enabled (see below), this file will NOT be used.

### Uncomment the line below to use the default password file.

password-db = passwd

### The authz-db option controls the location of the authorization

### rules for path-based access control.? Unless you specify a path

### starting with a /, the file's location is relative to the the

### directory containing this file.? If you don't specify an

### authz-db, no path-based access control is done.

### Uncomment the line below to use the default authorization file.

authz-db = authz

### This option specifies the authentication realm of the repository.

### If two repositories have the same authentication realm, they should

### have the same password database, and vice versa.? The default realm

### is repository's uuid.

realm = /home/svn/test

[sasl]

### This option specifies whether you want to use the Cyrus SASL

### library for authentication. Default is false.

### This section will be ignored if svnserve is not built with Cyrus

### SASL support; to check, run 'svnserve --version' and look for a line

### reading 'Cyrus SASL authentication is available.'

# use-sasl = true

### These options specify the desired strength of the security layer

### that you want SASL to provide. 0 means no encryption, 1 means

### integrity-checking only, values larger than 1 are correlated

### to the effective key length for encryption (e.g. 128 means 128-bit

7.啟動(dòng)SVN服務(wù)

svnserve -d -r /home/svn

注意:不是svnserve -d -r /home/svn/test

8.在本機(jī)安裝TortoiseSVN

輸入svn://你的ip地址/test

如果彈出輸入賬號(hào)密碼的對(duì)話框吉嚣,表示上述設(shè)置正確。

9.Svn commit后自動(dòng)同步到網(wǎng)站根目錄的方法

為什么需要同步呢蹬铺?原因是我們commit的文件其實(shí)是提交到了svn的倉庫中尝哆,svn倉庫不是一個(gè)實(shí)際的網(wǎng)站根目錄。流程如下:本地文件commit到倉庫->倉庫同步到根目錄甜攀,可以把倉庫理解為一個(gè)中轉(zhuǎn)站秋泄。進(jìn)入到項(xiàng)目下的hooks文件夾

cd?/home/svn/test/hooks

把post-commit.tmpl的擴(kuò)展名去掉,并賦予777權(quán)限规阀。然后vim post-commit寫入如下內(nèi)容恒序。

#!/bin/sh

export LANG=zh_CN.UTF-8

svn co svn://你的ip/test /home/wwwroot/test/web

# POST-COMMIT HOOK

# The post-commit hook is invoked after a commit.? Subversion runs

# this hook by invoking a program (script, executable, binary, etc.)

# named 'post-commit' (for which this file is a template) with the

# following ordered arguments:

#

#? [1] REPOS-PATH? (the path to this repository)

#? [2] REV? ? ? ? ? (the number of the revision just committed)

#

# The default working directory for the invocation is undefined, so

# the program should set one explicitly if it cares.

#

# Because the commit has already completed and cannot be undone,

# the exit code of the hook program is ignored.? The hook program

# can use the 'svnlook' utility to help it examine the

# newly-committed tree.

#

# On a Unix system, the normal procedure is to have 'post-commit'

# invoke other programs to do the real work, though it may do the

# work itself too.

#

# Note that 'post-commit' must be executable by the user(s) who will

# invoke it (typically the user httpd runs as), and that user must

# have filesystem-level permission to access the repository.

#

# On a Windows system, you should name the hook program

# 'post-commit.bat' or 'post-commit.exe',

# but the basic idea is the same.

#

# The hook program typically does not inherit the environment of

# its parent process.? For example, a common problem is for the

# PATH environment variable to not be set to its usual value, so

# that subprograms fail to launch unless invoked via absolute path.

# If you're having unexpected problems with a hook program, the

# culprit may be unusual (or missing) environment variables.

#

# Here is an example hook script, for a Unix /bin/sh interpreter.

# For more examples and pre-written hooks, see those in

刪掉post-commit 最后一行

重要步驟:然后cd /回到根目錄,執(zhí)行以下語句姥敛,這一步的作用是讓服務(wù)器記憶你svn的賬號(hào)密碼,防止出現(xiàn)權(quán)限等問題瞎暑,首先讓你輸入你服務(wù)器的密碼彤敛,接著輸入svn的賬號(hào)密碼,其中會(huì)問你是否記憶了赌,輸入yes墨榄。

svn co?svn://你的ip/test /home/wwwroot/test/web

至此svn已經(jīng)配置完畢,并且可以實(shí)現(xiàn)本地一執(zhí)行上傳勿她,自動(dòng)同步到網(wǎng)站跟目錄袄秩。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市逢并,隨后出現(xiàn)的幾起案子之剧,更是在濱河造成了極大的恐慌,老刑警劉巖砍聊,帶你破解...
    沈念sama閱讀 218,525評(píng)論 6 507
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件背稼,死亡現(xiàn)場(chǎng)離奇詭異,居然都是意外死亡玻蝌,警方通過查閱死者的電腦和手機(jī)蟹肘,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,203評(píng)論 3 395
  • 文/潘曉璐 我一進(jìn)店門词疼,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人帘腹,你說我怎么就攤上這事贰盗。” “怎么了阳欲?”我有些...
    開封第一講書人閱讀 164,862評(píng)論 0 354
  • 文/不壞的土叔 我叫張陵舵盈,是天一觀的道長(zhǎng)。 經(jīng)常有香客問我胸完,道長(zhǎng)书释,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 58,728評(píng)論 1 294
  • 正文 為了忘掉前任赊窥,我火速辦了婚禮爆惧,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘锨能。我一直安慰自己扯再,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,743評(píng)論 6 392
  • 文/花漫 我一把揭開白布址遇。 她就那樣靜靜地躺著熄阻,像睡著了一般。 火紅的嫁衣襯著肌膚如雪倔约。 梳的紋絲不亂的頭發(fā)上秃殉,一...
    開封第一講書人閱讀 51,590評(píng)論 1 305
  • 那天,我揣著相機(jī)與錄音浸剩,去河邊找鬼钾军。 笑死,一個(gè)胖子當(dāng)著我的面吹牛绢要,可吹牛的內(nèi)容都是我干的吏恭。 我是一名探鬼主播,決...
    沈念sama閱讀 40,330評(píng)論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼重罪,長(zhǎng)吁一口氣:“原來是場(chǎng)噩夢(mèng)啊……” “哼樱哼!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起剿配,我...
    開封第一講書人閱讀 39,244評(píng)論 0 276
  • 序言:老撾萬榮一對(duì)情侶失蹤搅幅,失蹤者是張志新(化名)和其女友劉穎,沒想到半個(gè)月后呼胚,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體盏筐,經(jīng)...
    沈念sama閱讀 45,693評(píng)論 1 314
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,885評(píng)論 3 336
  • 正文 我和宋清朗相戀三年砸讳,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了琢融。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片界牡。...
    茶點(diǎn)故事閱讀 40,001評(píng)論 1 348
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡,死狀恐怖漾抬,靈堂內(nèi)的尸體忽然破棺而出宿亡,到底是詐尸還是另有隱情,我是刑警寧澤纳令,帶...
    沈念sama閱讀 35,723評(píng)論 5 346
  • 正文 年R本政府宣布挽荠,位于F島的核電站,受9級(jí)特大地震影響平绩,放射性物質(zhì)發(fā)生泄漏圈匆。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,343評(píng)論 3 330
  • 文/蒙蒙 一捏雌、第九天 我趴在偏房一處隱蔽的房頂上張望跃赚。 院中可真熱鬧,春花似錦性湿、人聲如沸纬傲。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,919評(píng)論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽叹括。三九已至,卻和暖如春宵荒,著一層夾襖步出監(jiān)牢的瞬間汁雷,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 33,042評(píng)論 1 270
  • 我被黑心中介騙來泰國(guó)打工报咳, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留侠讯,地道東北人。 一個(gè)月前我還...
    沈念sama閱讀 48,191評(píng)論 3 370
  • 正文 我出身青樓少孝,卻偏偏與公主長(zhǎng)得像继低,于是被迫代替她去往敵國(guó)和親熬苍。 傳聞我的和親對(duì)象是個(gè)殘疾皇子稍走,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 44,955評(píng)論 2 355