Linux configuration svn automatically sends mail __linux

Source: Internet
Author: User
Tags auth chmod commit diff new set svn

Company game Operation needs, a new set up SVN and configured a bit to submit the function of automatic mail delivery, a few key steps to forget the content, for useful reference to the students ha


1. Ready to install Package:

Apr-1.3.8.tar.gz

Apr-util-1.3.9.tar.gz

Httpd-2.2.4.tar.gz

Subversion-1.6.5.tar.gz

Subversion-deps-1.6.5.tar.gz


2. Install APR and Apr-util package

3. Install Apache

# TAR–ZVXF Httpd-2.2.4.tar.gz
# CD httpd-2.2.4
#./configure
--prefix=/usr/local/apache
--with-apr=/usr/local/apr
--with-apr-util=/usr/local/apr-utl
--ENABLE-MODULES=SO/* DSO mode to install Apache (or--enable-so)
--enable-dav
--enable-maintainer-mode
--Enable-rewrite
# make; Make install
When installed, start Apache
#/usr/local/apache/bin/apachectl–k Start
Using the browser to view http://localhost/, get it works, indicating that Apache has been configured successfully.

4. Install and configure Subversion
#tar –ZVXF subversion-1.4.5.tar.gz
#tar –ZVXF subversion-deps-1.4.5.tar.gz/* These two automatically unzip into a package subversion-1.4.5
#cd subversion-1.4.5
#rm –RF Apr
#rm-RF Apr-util
Note: SVN relies on the APR version to be correct. If Apache is 2.0.x, the corresponding APR version should be 0.9.x;apache 2.2.x, and the corresponding APR version should be 1.2.x. Because the APR in the Subversion-deps bag is 0.9.x, you will need to remove the APR, apr-util from the Deps, and use the Apache 2.2 in the compilation SVN. (This is designated as the beginning of the installation of the APR directory), this knowledge is very important, their previous installation has not been successful, it is now understood to be stuck in this point, but eventually I solved, learning, and continuous practice will make you grow!
#./configure
--prefix=/usr/local/svn
--with-apxs=/usr/local/apache/bin/apxs
--with-apr=/usr/local/apr/bin/apr-1-config
--with-apr-util=/usr/local/apr/bin/apu-1-config
--with-ssl
--with-zlib
--enable-maintainer-mode
#make
#make Install
Determine if SVN has a successful installation
#/usr/local/svn/bin/svnserve--version

You will see the relevant version information.
And then look at the Apache related modules are not loaded. As follows.
LoadModule Dav_svn_module modules/mod_dav_svn.so
LoadModule Authz_svn_module modules/mod_authz_svn.so

Start building a version library
Create warehouse "test" #svnadmin create/opt/svnrepo/test/*

Ls/svn/project/test/* See if you have created it, if you have more files, the version library has been created.

Configuring to improve the security of the SVN version library
#chmod –R 700/opt/svnrepo/test does not allow other people to have permissions on the directory
Note: Direct such chmod can cause SVN clients to be inaccessible and need to modify the Apache configuration file./conf/httpd.conf file (if your level is not high enough, this step can be skipped, lest give yourself trouble!) After the service is completely finished and then to further improve security) there is a section in the httpd.conf file

(My system automatically increases the Apache user and the Apache group when you install Apache, and if you don't have the user or group, add the user and group yourself)
Modify the owner of the SVN warehouse
#chown-R Apache:apache/opt/svnrepo/test

5, configure Apache support SVN

Add the httpd.conf content to the back

#Svn Configuration
<Location/svn>
DAV SVN
Svnparentpath/opt/svnrepo
AuthType Basic
AuthName "Hello Welcome to Here"
Authuserfile/opt/svnrepo/upublish/conf/passwd.conf
Authzsvnaccessfile/opt/svnrepo/upublish/conf/authz.conf
Require Valid-user
</Location>

6, configure SVN Rights Management

1. Add User:
#/USR/LOCAL/APACHE/BIN/HTPASSWD–C/SVN/PASSWD User1
The first time you set up a user, use-c indicates a new user file. Enter user password after carriage return, complete the increase to the user
The second time you add users do not need to take –c parameters such as:
#/usr/local/apache/bin/htpasswd/svn/passwd User2

2. Permission Assignment:
#vi/svn/auth.conf
[Groups]
Team_admin = Zhangsan
team_yunying = Lisi,wangwu


[/]
@team_admin = RW
# &joe = R
# * =

[upublish:/]
@team_admin = RW
* = R
[Upublish:/yunying]
@team_admin = RW
@team_yunying = RW
* = R

7. Configure mail delivery

A: Use SendMail, install SendMail service

B: Modify/ETC/MAIL/SENDMAIL.MC Modify Daemon_options (' port=smtp,addr=10.10.209.44, Name=mta ') dnl for native IP

C: Modify/etc/mail.rc Add content

Set from=xxx@126.com smtp=smtp.126.com smtp-auth-user=xxx smtp-auth-password=123456 smtp-auth=login

D: Increase the svn_email_commit.sh send mail script, the contents are as follows:

#!/bin/bash
Repos=$1
Rev=$2
Sendto=$3
Sendfrom=xxx@126.com

limitdiff=200
Changelog= ' Svnlook log-r $REV $REPOS '
Author= ' Svnlook author-r $REV $REPOS '
Changed= ' Svnlook changed-r $REV $REPOS '
diff= ' Svnlook diff-r $REV $REPOS | Head--lines= $LIMITDIFF '
Date= ' Date '
tmpfile=/tmp/svn$rev-$RANDOM. Message

Subject= "Svncommit ($AUTHOR) $REPOS [$REV]"
echo "--------------------SVN Commit Notification--------------------
Repository: $REPOS
Revision: $REV
Author: $AUTHOR
Date: $DATE

-----------------------------------------------------------------
Log message:
-----------------------------------------------------------------
$CHANGELOG

-----------------------------------------------------------------
Changes:
-----------------------------------------------------------------
$CHANGED

-----------------------------------------------------------------
Diff: (only $LIMITDIFF lines shown)
-----------------------------------------------------------------
$DIFF
"> $TMPFILE
# Send Email
#cat $TMPFILE | Mail-a "From: $SENDFROM"-S "$SUBJECT" "$SENDTO"
Cat $TMPFILE | Mail-a "$TMPFILE"-S "$SUBJECT" "$SENDTO"

# Cleanup
RM $TMPFILE

E: Modifying the Post-commit script

#!/bin/sh
Export Lc_ctype=en_us. UTF-8

Export path= $PATH:/usr/local/svn/bin:/opt/svnrepo/upublish/hooks:
Repos= "$"
rev= "$"

Sendto= "Aaa@126.com"
# Send It to these people, calling the script we created above
/opt/svnrepo/upublish/hooks/svn_email_commit.sh "$REPOS" "$REV" "$SENDTO"


8. Automatic SendMail Service

Service SendMail Start


10, can test

Mail-s "Test" bbb@126.com


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.