Рубрики
Uncategorized

Создайте SVN под Ubuntu и используйте hook для синхронизации с веб-каталогом

Автор оригинала: David Wong.

Предисловие

В последнее время для сборки сервера использовался контроль версий, и в процессе сборки сервера возникло много проблем. Напишите это просто

шаг

1. Установите SVN

$ sudo apt-get install subversion

2. Создайте каталог проекта

$sudo MKDIR SVN // creates a folder to hold one or more items
$CD. / SVN // enter this directory
$sudo MKDIR project // create a new project directory
$sudo svnadmin create. / SVN / project // create SVN file warehouse (this step is to make this new folder into SVN version Library)

3. Настройки разрешений

$CD. / SVN / project / conf // enter the setting directory (including authz hooks-env.tmpl passwd svnserve. CONF)

$VIM passwd // add user set password

[users]
root = 123456
user1 = 123456
user2 = 123456

$VIM authz // edit user rights

[groups]
admin = user1,user2,root
[/]
@admin=rw
*=r

$VIM svnserve.conf // control access

[general]
Anon access = none - access rights of anonymous users
Auth access = write ා access of authorized users
Password DB = the location of the password database file, which points to the passwd file in the same level directory
Authz DB = authz ා the location of the user authorization rule file, which points to the authz file in the same level directory

4. Запустите SVN

Start SVN 
   $svnserve - D - R. / SVN // the / SVN directory here is the directory where you first create the project
   
   Close SVN 
   在配置过程中如果需要Close SVN则kill
   $ ps aux | grep svn 
   root     21618  0.0  0.0  69596   616 ?        Ss   19:07   0:00 svnserve -d -r /svn
   root     21927  0.0  0.2  11748  2156 pts/0    S+   19:10   0:00 grep --color=auto svn
   
   $ kill 21618

5. Настройте крючок (если вам не нужно настраивать его в веб-каталоге, вы можете проверить его после предыдущего шага)

$CD. / SVN / project / hooks // here SVN provides a good hook template. You can select a template according to your own situation, usually post-commit.tmpl (update after submitting)

$VIM post commit // create a new file

#!/bin/bash
EPOS="$1"
REV="$2"
TXN_NAME="$3"
export LANG=en_US.UTF-8
/Usr / bin / SVN update -- username root -- password 123456 / var / www / Project Directory > / TMP / www.log | Exit 1
exit 0

if [ $? == 0 ]

then

        echo "ok" >> /tmp/wwww.out

fi

6. Установите разрешение на выполнение шаблона

$ chmod 755 post-commit

7. Сначала проверьте это в каталоге WWW

$/ usr / bin / SVN checkout SVN: // your server address / your version repository

Note: if you are a new Alibaba cloud server, please remember to open the port access restriction

8. Локальная проверка завершена!

Теперь вы можете отправлять и синхронизировать с веб – каталогом