SVN hooks
A hook script is the way the shell is written, and a hook is a program that is triggered by some repository events.
Common hooks:
Post-commit: Executes the hook after the commit has completed successful creation. (Submission has been completed and cannot be changed)
After the update, by mail, notification
UPDATE triggers the checkout program, and then pushes it to the server
Pre-commit: Triggers execution of the script before the commit is completed.
Limit the size and extension of uploaded files, and control the submission of information to be entered
Here is a small example:
Rsync combined with SVN hooks for real-time data synchronization to the server
1. Create a synchronization web directory
Mkdir/data/www
2. Checkout the contents of SVN into the web directory
SVN Co svn://ip/sadoc/data/www--username=syk--password=syk123
3. Setting hooks
CP Post-commit.tmpl Post-commit
4. Writing scripts
1), > Post-commit
2), chmod post-commit
3), Vim Post-commit add:
#!/bin/bash
Repos= "$"
rev= "$"
Export Lang=en_us. UTF-8
Logpath= "/tmp/log"
[!-D ${logpath}] && mkdir ${logpath}-P
Svn=/usr/bin/svn
$SVN update--username SYK--password syk123/data/www
If [$?-eq 0]
Then
/usr/bin/rsync-az--delete/data/www/tmp/
Fi
5. Testing
Then we create a new file on SVN and submit it, and in the TMP directory we can see the new file.
This article is from the "Linux" blog, so be sure to keep this source http://syklinux.blog.51cto.com/9631548/1792475
About SVN hooks