Install subversion run as svn protocol and run as services

Ngày 25 tháng 8 năm 2014 Trương Chương Dương
If you wish to run SVN server on protocol svn instead of http with apache, just do below steps:
  1. Install subversion package (use yum on Fedora/Centos or apt-get on Debian/Ubuntu)
  2. Create svn repo folder and data:
    mkdir /home/user/myrepo/ 
    svnadmin create /home/user/myrepo/
  3. The user may now edit the configuration file to change the access rules. An example /home/user/myrepo/conf/svnserve.conf will be:
    [general]
    anon-access = read
    auth-access = write
    realm = My First Repository
    password-db = passwd
  4. In this case, anonymous user can read the contents of the repository, but only an authenticated user can write to it, if you wish to disable anonymous user, change the anon-access to none. passwd is the file that will contain the usernames and passwords for all the users. The value of password-db can be an absolute or relative path to the users file. The format of this file is as follows (username followed by the password, separated by colon)
    [users]
    harry:passwd1
    sally:passwd2
  5. The passwd file contains nothing else except a list of user:passwd on each line. Is using svnserve, password needs to be stored in cleartext.
  6. The subversion server can now be started using the command svnserve -D -r -R /home/user/myrepo/ (this runs on port 631). Since this command needs to be executed every time the system reboots, the user may use the system init scripts.

Create script to run svnserve as service:
  1. Many linux distributions (like SuSE), which ship with svnserve provide the init script in /etc/init.d/. In this case the server can be started using (after modifying them to adjust the repository path):
    chkconfig svnserve on    #always start at boot
    service svnserve start    #start now
  2. If the init script is not available, following script can be copied to /etc/init.d/svnserve (do not forget to change the permissions to executable)
    #!/bin/bash
    #
    # chkconfig: 35 90 12
    # description: svnserve server
    #
    # Get function from functions library
    . /etc/init.d/functions
    # Start the service svnserve
    start() {
            echo -n "Starting SVN server:"
            /usr/bin/svnserve -d -r /home/global/svn &
            ### Create the lock file ###
            touch /var/lock/subsys/svnserve
            success $"SVN server startup"
            echo
    }
    # Restart the service svnserve
    stop() {
            echo -n "Stopping SVN server: "
            killproc svnserve
            ### Now, delete the lock file ###
            rm -f /var/lock/subsys/svnserve
            echo
    }
    ### main logic ###
    case "$1" in
      start)
            start
            ;;
      stop)
            stop
            ;;
      status)
            status svnserve
            ;;
      restart|reload|condrestart)
            stop
            start
            ;;
      *)
            echo $"Usage: $0 {start|stop|restart|reload|status}"
            exit 1
    esac
    exit 0
  3. Now you can run the command at step 1 ru enable svn run as service and start it

Custom permission each user on specific folder in a repo:

You can custom read/write a specific user on a subfolder in side a repo, it will overwrite the global permission.
Such as:
  • User hary will have full permission on repo svn://localhost/myproject/trunk but not able to write/commit into svn://localhost/myproject/release
  • User tom can read on both above branch but can commit only on svn://localhost/myproject/release
  • And so on...
Here is the solution: http://www.chuongduong.net/page/30/subversion--custom-permission-each-user-on-specific-folder-in-a-repo.html
Đang tải dữ liệu...