CentOS6.9 svn quick installation configuration method
- 2020-11-18 06:33:32
- OfStack
The example of this paper shares the specific code of CentOS6.9 quick installation and configuration of svn for your reference. The specific content is as follows
Environment Introduction:
Operating System: CentOS release 6.9 (Final)
192.168.65.130 (svn server)
192.168.65.129 (svn client)
1. svn installation inspection (performed on both platforms)
if [ ! -f /usr/bin/svn ]; then
yum -y install subversion >/dev/null
echo "svn has been installed." >/dev/null
/usr/bin/svn --version|head -1|awk -F" " '{print $3}'
fi
2. Create a version library folder (only available on 130)
mkdir -p /data/svn/sinsvn
# Create a version library
svnadmin create /data/svn/sinsvn
mkdir -p /data/www/sinsvn
3. Main operation
# Import the project you want to manage into the version library repository In the
svn import /data/www/sinsvn/ file:///data/svn/sinsvn -m "svn first test"
# Check if the import was successful
svn list --verbose file:///data/svn/sinsvn
# Modify the configuration file for the repository
# vim /data/svn/sinsvn/conf/svnserve.conf
cat >/data/svn/sinsvn/conf/svnserve.conf <<"EOF"
[general]
anon-access = none
auth-access = write
password-db = /data/svn/passwd
authz-db = /data/svn/authz
realm =sinsvn
EOF
cp /data/svn/sinsvn/conf/passwd /data/svn
cp /data/svn/sinsvn/conf/authz /data/svn
# Modify user files that allow access to the repository
# vim /data/svn/passwd
cat >/data/svn/passwd <<"EOF"
[users]
harry = harry
sin = sin
EOF
# vim /data/svn/authz
cat >/data/svn/authz <<"EOF"
[groups]
myteam = harry,sin
[/]
harry = rw
[sinsvn:/]
@myteam = rw
[secsvn:/www]
@myteam =r
sin= rw
[sincms:/]
sin= rw
harry=
EOF
# Start the svn service
svnserve -d -r /data/svn/
# To view
ps -ef|grep svnserve|grep -v 'grep'
netstat -anltp|grep 3690
4. Test
# test , On the other 1 Operate on a machine (129) The aim is to be more effective
# 1 , mkdir -p /data/www
mkdir -p /data/www
cd /data/www/
# 2 , svn co code
svn co svn://192.168.65.130/sinsvn --username=harry --password=harry
# 3 , add branches,tags,trunk directory
cd sinsvn/
mkdir branches
mkdir tags
mkdir trunk
svn add branches trunk tags
svn ci -m 'create branches trunk tags dir'
# 4 And in the trunk Add test files and submit them to the repository
cd trunk
touch index.php
mkdir class
touch class/conn.php
svn add index.php
svn add class/
......
svn ci -m 'test file'
svn delete index.php class class/ index.php
svn ci -m 'delete files'
mkdir webgame
svn add webgame/
svn ci -m 'add webgame dir'
# Additional operating
cd webgame
cp /tmp/VMwareTools-10.2.0-7259539.tar.gz .
cp /tmp/yum.log .
svn add *
svn ci -m 'add VMwareTools yum.log for test'
############### It is assumed that 130 There's one on the machine web project
mkdir -p /data/webdir
cd /data/webdir
svn co svn://192.168.65.130/sinsvn/trunk/webgame --username=harry --password=harry
# Additional operating
cd /data/webdir/webgame/
svn update
ll # You can see the updated results
5. Script customization updates
# Regular update script ( A script that updates automatically for the entire directory , Passive mode )
cat >/root/svnauto_update.sh<<"EOF"
cd /data/webdir/webgame/
svn update &>>/tmp/svnauto_update.log
EOF
chmod +x /root/svnauto_update.sh
chmod +x /etc/crontab
/etc/init.d/crond restart
# Added to the crontab On a planned mission
cat >>/var/spool/cron/root<<"EOF"
# svnauto_update.sh
* 09-23 * * * /bin/sh /root/svnauto_update.sh
EOF
# Automatic update script ( Trigger updates for the version number )
#svn Directory: /data/svn/sinsvn
# Site directory: /data/webdir/webgame
# Implementation:
#1. find svn The project hooks Directory. Here it is /data/svn/sinsvn/hooks . By default there are several hook templates for the corresponding operation in the directory that we need to create 1 a post-commit The file.
find /data/svn/sinsvn/ -name hooks
#2. new post-commit , which reads as follows
cat >/data/svn/sinsvn/hooks/post-commit<<"EOF"
#!/bin/bash
REPOS="$1"
REV="$2"
export LANG=zh_CN.UTF-8
echo "Code Deployed at "$1" Committed revision "$2" ; `date "+%Y-%m-%d %H:%M:%S"`" >> /tmp/post-commit.log
/usr/bin/svn update --username harry --password harry /data/webdir/webgame >> /tmp/post-commit.log
EOF
chmod +x /data/svn/sinsvn/hooks/post-commit