我正在配置 Subversion 并希望它在启动时启动。使用以下命令系列:
sudo mkdir /var/svn
sudo useradd -r -s /bin/false svn
sudo mkdir /etc/svn
sudo cp /home/zipo/svnserve /etc/svn/svnserve
sudo chown root:root /etc/svn/svnserve
set execute to owner/group/other
sudo nano /lib/systemd/system/svn.service
sudo systemctl daemon-reload
sudo systemctl enable svn
sudo systemctl start svn
当我在 syslog 中键入手动命令以启动服务sudo systemctl start svn
时,会出现以下日志条目:
Oct 29 10:13:27 testserver systemd[1]: Started SVN server.
Oct 29 10:13:27 testserver svnserve[3128]: * Starting svnserve...
Oct 29 10:13:27 testserver svnserve[3128]: ...done.
但服务不起作用。我在正确的端口 9999 上检查它,如配置中所述。如果我使用以下命令手动运行它,它会启动并正常工作:sudo -H -u svn bash -c '/etc/svn/svnserve start'
我错过了什么?
svn.service 文件内容:
[Unit]
Description=SVN server
After=network.target
[Service]
User=svn
Group=svn
Type=simple
ExecStart=/etc/svn/svnserve start
GuessMainPID=no
[Install]
WantedBy=multi-user.target
svnserve 文件内容:
#! /bin/sh -e
#
# svnserve - brings up the svn server so anonymous users
# can access svn
#
# Get LSB functions
. /lib/lsb/init-functions
. /etc/default/rcS
SVNSERVE=/usr/bin/svnserve
SVN_USER=svn
SVN_GROUP=svn
SVN_REPO_PATH=/var/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 --listen-port=9999 -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/svnserve {start|stop|restart|force-reload}"
exit 1
;;
esac
exit 0