The SVN server in CentOS automatically updates files to the Web Directory configuration.

Source: Internet
Author: User
Tags auth commit svn svn client svn update centos

Note:

Server operating system: CentOS

Server IP address: 192.168.21.134

SVN installation path:/usr/local/svn

SVN project path:/home/svn

SVN logon account: osyunwei

SVN logon password 123456

Root directory of the Web site:/home/web

Purpose:

When any changes are made to the svn project, the system automatically detects files from svn in real time and synchronizes them to the root directory of the Web site.

Specific operations:

I. Use post-commit in SVN to automatically detect files from svn in real time and synchronize the files to the root directory of the Web site

Cd/home/svn/hooks

Vi post-commit # edit and add the following code

#! /Bin/sh

REPOS = "$1"

REV = "$2"

SVN_PATH =/usr/local/svn/bin

WEB_PATH =/home/web

SVN_USER = osyunwei

SVN_PASS = 123456

WEB_USER = www

LOG_PATH =/tmp/svn. log

Echo 'date "+ % Y-% m-% d % H: % M: % S" '>>$ LOG_PATH

Echo 'whoam', $ REPOS, $ REV> $ LOG_PATH

$ SVN_PATH/svn update $ WEB_PATH -- username $ SVN_USER -- password $ SVN_PASS -- no-auth-cache> $ LOG_PATH

Chown $ WEB_USER. $ WEB_USER-R $ WEB_PATH

: Wq! # Save and exit

Chown www: www/home/svn/hooks/post-commit # set the user group to which the script belongs. www is the web service running account and group.

Chmod + x/home/svn/hooks/post-commit # add the script execution permission

Note:

Whoami # The user who executes the program

REPOS = "$1" # svn project absolute path value

REV = "$2" # Latest version

-- No-auth-cache # Do not save account authentication information

2. Client testing

After a file is added to the svn client, the Web page is displayed in real time! As shown in the following figure:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.