⬆️ ⬇️

Raise subversion for enjoyable development

One day I got tired of uploading all the changes to the project via ftp \ ssh. By this time, I had already hatched the idea of ​​transferring the development under the control of SVN - version control, still a nice thing. As a result, it was decided to combine business with pleasure - and version control, and automatic updating of the project. By tradition - the story will be conducted on the example of my beloved debian'a.

A note can be considered an addition to the article svn tips (at least - the first paragraph).



You can read about installing / configuring SVN in the following topics:We create an init-script to launch an svn-server with the system (initially the script was found somewhere on the Internet, it seems, I changed something in it :)).

/etc/init.d/svn :
  #! / bin / sh -e
 #
 # Default-Start: 2 3 4 5
 # Default-Stop: 0 1 6

 # Get LSB functions
 .  / lib / lsb / init-functions
 .  / etc / default / rcS

 SVNSERVE = / usr / bin / svnserve
 SVN_USER = subversion
 SVN_GROUP = www-data
 SVN_REPO_PATH = / usr / share / svn /

 # Check that the package is still installed
 [-x $ SVNSERVE] ||  exit 0;

 case "$ 1" in
  start)
   log_begin_msg "Starting svnserve ..."
   umask 002
   if start-stop-daemon --start --chuid $ SVN_USER: $ SVN_GROUP --exec $ SVNSERVE - -d -r $ SVN_REPO_PATH
   then
    log_end_msg 0
   else
    log_end_msg $?
   fi
  ;;
  stop)
   log_begin_msg "Stopping svnserve ..."
   if start-stop-daemon --stop --exec $ SVNSERVE
   then
    log_end_msg 0
   else
    log_end_msg $?
   fi
  ;;
  restart | force-reload)
   "$ 0" stop && "$ 0" start
  ;;
  *)
   echo "Usage: /etc/init.d/svn {start | stop | restart | force-reload}"
   exit 1
  ;;
 esac
 exit 0 
Let's give everyone the right to execute, we will strongly recommend the system to run svn at the start and at the same time start it:
chmod a + x /etc/init.d/svn

update-rc.d svn defaults

invoke-rc.d svn start
Set up a working copy update at commit - / usr / share / svn / hooks / post-commit hook:
  #! / bin / sh
 exec> / tmp / svnup 2> & 1
 # all script output will be sent to the / tmp / svnup file
 for path in svnlook dirs-changed / usr / share / svn |  fgrep '/ trunk /' |  cut -d '/' -f 2- |  sort -u`
 # get a list of directories changed in a commit, cut the first
 # part (in my turnip - / trunk) and, if there is such a path, do svn up there
 do
         if [-d "/ var / www / $ path"]
         then
                 echo $ path
                 / usr / bin / svn up -N / var / www / $ path
         fi
 done 
Do not forget to issue the right to perform:
chmod a + x / usr / share / svn / hooks / post-commit
And also - make sure that the user of the subversion : www-data has the right to write to the necessary directories / var / www / $ path .

Further work (arrangement of the repository) is already performed on the developer's machine (well, except that, then upload the working copy on the server to the required folder).

And, as usual, I hope that the material will be useful to someone.



')

Source: https://habr.com/ru/post/38084/



All Articles