1.新建脚本/etc/init.d/svnserver
#!/bin/sh
home=/svn/projects
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
case "$1" in
start)
/usr/bin/svnserve -d -r /svn/projects
;;
stop)
/usr/bin/killall svnserve
;;
status)
status=`netstat -ant |grep 3690`
if[ -n "$status" ]; then
echo "svnserve is started"
else
echo "svnserve is stoped"
fi
;;
restart)
/usr/bin/killall svnserve
/usr/bin/svnserve -d -r /svn/projects
;;
adduser)
if[ -z "$2" ];then
echo "please input username that needs to be added!"
exit 1
fi
/usr/bin/htpasswd /svn/projects/conf/pwdfile "$2"
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
exit 1
;;
esac
exit 0
2. 添加svnserver.service
cd /lib/systemd/system
mkdirsvnserver.service.d
vim svnserver.service.d/svnserver-systemd.conf
[Service]
Type=forking
RemainAfterExit=no
3.重启服务器