#! / 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/svnSet up a working copy update at commit - / usr / share / svn / hooks / post-commit hook:
update-rc.d svn defaults
invoke-rc.d svn start
#! / 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-commitAnd also - make sure that the user of the subversion : www-data has the right to write to the necessary directories / var / www / $ path .
Source: https://habr.com/ru/post/38084/
All Articles