Skip to content

Instantly share code, notes, and snippets.

@jeremiah
Forked from moschlar/git-daemon
Created August 25, 2016 17:52
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save jeremiah/32d7e696e86ca205509dfa5f9918ad3e to your computer and use it in GitHub Desktop.
Save jeremiah/32d7e696e86ca205509dfa5f9918ad3e 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
@jeremiah
Copy link
Author

HOWTO;

Edit git-daemon@.service to your local configuration. particularly this line;
"ExecStart=-/usr/lib/git-core/git-daemon --inetd --base-path=/home/jeremiah/GENIVI/local-repos --verbose $GITDAEMON_OPTS"
Obviously on our git.projects.g.o server the base path is /srv/repositores/ and I've changed where you find the git-daemon to match Debian.

  1. Move the git-daemon@.service template and git-daemon.socket files into /lib/systemd/system/
  2. sudo systemctl enable /lib/systemd/system/git-daemon.socket
  3. sudo systemctl start git-daemon.socket

That should work.

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