Skip to content

Instantly share code, notes, and snippets.

@moschlar
Created August 4, 2015 06:19
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save moschlar/9b57eec3a2a8483e7e43 to your computer and use it in GitHub Desktop.
Save moschlar/9b57eec3a2a8483e7e43 to your computer and use it in GitHub Desktop.
systemd-unit for git-daemon
# conf.d file for git-daemon
#
# Please check man 1 git-daemon for more information about the options
# git-daemon accepts. You MUST edit this to include your repositories you wish
# to serve.
#
# Some of the meaningful options are:
# --syslog --- Enables syslog logging
# --verbose --- Enables verbose logging
# --export-all --- Exports all repositories
# --port=XXXX --- Starts in port XXXX instead of 9418
#
GITDAEMON_OPTS="--syslog --base-path=/var/git"
# To run an anonymous git safely, the following user should be able to only
# read your Git repositories. It should not be able to write to anywhere on
# your system, esp. not the repositories.
GIT_USER="nobody"
GIT_GROUP="nobody"
[Unit]
Description=Git Activation Socket
[Socket]
ListenStream=9418
Accept=true
[Install]
WantedBy=sockets.target
[Unit]
Description=Git Repositories Server Daemon
Documentation=man:git-daemon(1)
[Service]
User=nobody
Group=nobody
EnvironmentFile=/etc/conf.d/git-daemon
# Ignore non-zero exit status, access error makes git-daemon return them
ExecStart=-/usr/libexec/git-core/git-daemon --inetd --base-path=/var/git --verbose $GITDAEMON_OPTS
StandardInput=socket
StandardOutput=inherit
StandardError=journal
@jankal
Copy link

jankal commented Jun 15, 2016

It just doesn'T work as I see:

git-daemon.service failed to run 'start' task: Invalid argument

Only changed the user to git-daemon everywhere and the directory to my git repos.

@jeremiah
Copy link

@jankal What command did you run?

@penguin359
Copy link

@jankal It should be git-daemon@.service with the at-sign attached. I think that might be the issue. Also, it's the socket that needs to be enabled and started for Git, not the service.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment