Today, the svn version control service is deployed in the Ubuntu environment.
1. Download and Install
# apt-get install subversion
2. Creating directories
# mkdir /home/svn # mkdir /home/svn/repository # chmod -R 777 /home/svn/repository
3. Creating warehouses
# svnadmin create /home/svn/repository
View the repository directory:
# cd /home/svn/repository /home/svn/repository# ls -l total 24 -rw-r--r-- 1 root root 246 Sep 2 14:13 README.txt drwxr-xr-x 2 root root 4096 Sep 2 14:13 conf drwxr-sr-x 6 root root 4096 Sep 2 14:13 db -r--r--r-- 1 root root 2 Sep 2 14:13 format drwxr-xr-x 2 root root 4096 Sep 2 14:13 hooks drwxr-xr-x 2 root root 4096 Sep 2 14:13 locks
IV. Modify Profile
Enter the configuration file:
root@docker:/home/svn/repository# cd conf root@docker:/home/svn/repository/conf# ls -l total 20 -rw-r--r-- 1 root root 1080 Sep 2 14:13 authz -rw-r--r-- 1 root root 885 Sep 2 14:13 hooks-env.tmpl -rw-r--r-- 1 root root 309 Sep 2 14:13 passwd -rw-r--r-- 1 root root 4371 Sep 2 14:13 svnserve.conf
1. Modify svnserve.conf
vim svnserve.conf
Remove comments for the following parameters:
[general] anon-access = none #Anonymous access, default read, none is no access auth-access = write #Authenticate user rights password-db = passwd #User information holds files, either by default under Version Library/conf or by absolute path authz-db = authz
2. Modify passwd file
vim passwd
Add a user name and password, for example
corwien = corwien_123
3. Modify authz file
vim authz
Under [group], add:
admin=corwien [/] @admin=rw
V. Start svn Service
# svnserve -d -r /home/svn
Check to see if the process has started:
# ps aux | grep svnserver root 134 0.0 0.0 11460 1052 pts/1 S+ 14:22 0:00 grep --color=auto svnserver
From above, the process has started.
6. Testing on Client
The address of the SVN service we built is: svn://ip/repository
Note: The default port is 3690, which you want to open.
7. Set the power-on self-start
Check the location of svnserve first
which svnserve
For example, return
/usr/bin/svnserve
Remember this, later scripts need to
Start scripting
cd /etc/init.d vim svn.sh
Write after opening
#!/bin/bash /usr/bin/svnserve -d -r /home/svn
Add executable permissions to files after save exits
chmod +x /etc/init.d/svn.sh
Open/etc/rc.d/rc.local, add in new line
etc/init.d/svn.sh
Restart the system to see if svn starts
7. Hook
Enter the project svn to find the hooks folder
root@docker:/home/svn/repository/hooks# ls -l total 36 -rwxr-xr-x 1 root root 2634 Sep 2 14:13 post-commit.tmpl -rwxr-xr-x 1 root root 2773 Sep 2 14:13 post-lock.tmpl -rwxr-xr-x 1 root root 2994 Sep 2 14:13 post-revprop-change.tmpl -rwxr-xr-x 1 root root 2605 Sep 2 14:13 post-unlock.tmpl -rwxr-xr-x 1 root root 4038 Sep 2 14:13 pre-commit.tmpl -rwxr-xr-x 1 root root 3621 Sep 2 14:13 pre-lock.tmpl -rwxr-xr-x 1 root root 3469 Sep 2 14:13 pre-revprop-change.tmpl -rwxr-xr-x 1 root root 3309 Sep 2 14:13 pre-unlock.tmpl -rwxr-xr-x 1 root root 3754 Sep 2 14:13 start-commit.tmpl
Introduction to hooks template function of svn
Trigger a transaction before start-commit commits Trigger transaction before pre-commit commit completes Trigger transaction when post-commit commit completes Trigger transactions before pro-revprop-change version properties are modified post-revprop-change version property changes trigger transaction Execute the script after post-lock locks the file
Example:
chmod 755 post-commit && vim post-commit
#!/bin/sh # POST-COMMIT HOOK REPOS="$1" REV="$2" export LANG=en_US.UTF-8 SVN=/usr/bin/svn #The svn file in the svn install bin directory is configured here WEB=/var/www/myweb #Directory to update $SVN update $WEB --username adm --password adm chown -R www:www $WEB
Enter/var/www/myweb folder Manually check out a svn version library The next svn version will be automatically updated to the server
Related articles:
Install svn under ubuntu
Ubuntu 14.04 Quickly Build SVN Server and Daily Use
SVN Practice Notes (Theoretical Concepts) --Version Control