subversion package in debian jessie does not include a systemd service file. what is the simplest solution for automatic start. i try
[Unit]
Description=Subversion protocol daemon
After=syslog.target network.target
[Service]
Type=forking
#EnvironmentFile=/etc/conf.d/svnserve
#ExecStart=/usr/bin/svnserve --daemon $SVNSERVE_ARGS
ExecStart=/usr/bin/svnserve -d -r /svnFolder/repositories
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure
[Install]
WantedBy=multi-user.target
Alias=svnserve.service
it is an adaptation of https://bbs.archlinux.org/viewtopic.php?id=190127 but i have put the arguments directly for svnserve directly here.
what can be improved?
Here is a proposal to setup
svnserve
service "the-Debian-way" running with a dedicatedsvn
service account with proper logging. According to FHS, repositories should be stored in/srv/
:First, the service configuration for systemd
/etc/systemd/system/svnserve.service
:Second, the service startup options at
/etc/default/svnserve
:To work properly, the folder for log files must be created with proper ownership:
To end with log rotation configuration
/etc/logrotate.d/svnserve
:Hope this helps.
(I'd make this a comment on @Yves Martin's answer, but this is a new account and I'm not allowed to comment. :-P )
With SELinux, this solution doesn't allow for an autostart of the daemon. I made a few changes to make it happy. The svnserve daemon does not have open rights in the /var/log tree. Placing the log in the svn account's domain resolves a security whine.
In /etc/systemd/system/svnserve.service:
In /etc/logrotate.d/svnserve:
Finally, make the svn repos and log directory have the correct ownership and security type:
(Obviously, change /project/svn to wherever you have decided to put your repo structure. /var/svn is common and the rules already exist for that directory tree, making the last couple lines above unnecessary.)
Update: My answer below has been obsoleted. These improvements and others have been incorporated into Yves Martin's excellent solution.
I have two improvements: it's generally recommended not to run such things as root. Create a user for this, for example 'svn'. It is also recommended to explicitly specify a PID file when using forking. My svnserve.service looks much like yours except I add the lines:
One comment on Yves Martin's excellent answer above (I don't have the rep points to comment yet):
When trying to enable the service to start on boot, I'd get an error:
After doing some research I found you apparently cannot set an alias to the same name as the service. Deleting the Alias line from the [Install] section of the svnserve.service solved the issue: