I've created scripts to control starting, stopping, etc. of my git-daemon on Fedora28. I'm now attempting to link these scripts to a systemd service so git-daemon will be available after reboot.

The primary script (gitT) is...

case "$1" in
    echo "Starting git-daemon"
    /home/git/scripts/start.sh >> /home/git/gitT.log
    echo "Stopping git-daemon"
    /home/git/scripts/stop.sh >> /home/git/gitT.log
    echo "Bouncing git-daemon"
    /home/git/scripts/bounce.sh >> /home/git/gitT.log
    echo "Status of git-daemon"
    echo "`basename $0`: usage: `basename $0` { stop | start | restart | status }"

Secondary scripts are...


# --------------------------
echo "---------------------"
/usr/bin/git daemon --export-all --enable=receive-pack --verbose --pid-file=/home/git/git-daemon.pid --base-path=/home/git/repos >> /home/git/git-daemon.out 2>> /home/git/git-daemon.err &
echo "---------------------"
echo "STARTED at `date`"


# --------------------------
echo "---------------------"
pkill -F /home/git/git-daemon.pid
echo "---------------------"
echo "STOPPED at `date`"


# --------------------------
echo "====================="
echo "====================="
sleep 5
echo "====================="
echo "====================="
echo "BOUNCED"

and status.sh

# --------------------------
echo "====================="
ps -x --forest
echo "====================="

Finally I created a service file (git-daemon.service)...

Description=Git Daemon

ExecStart=/bin/bash /home/git/gitT start
ExecStop=/bin/bash /home/git/gitT stop


Then I set it up with these commands...

cp /home/git/git-daemon.service /etc/systemd/system
systemctl enable git-daemon.service

Now if I run gitT start as the git user, everything starts fine. But it I run systemctl start git-daemon as root, this is the error...

fatal: base-path '/home/git/repos' does not exist or is not a directory
  • Does /home/git/repos exist at the time unit is to be started? – Mark Stosberg May 21 '18 at 17:43
  • Yes, it exists. I confirm this by writing a test into the start script prior to executing the git-daemon, and it was positive. – dacracot May 21 '18 at 17:48
  • The error appears to come from git-daemon not from systemd. But is there is a change if ConditionPathExists=/home/git/repos is removed? Also, what is the output of ls -ld /home/git/repos? Maybe it's a permissions issue and the error message is not accurate. – Mark Stosberg May 21 '18 at 20:04
  • I’ve tried it with and without the condition with no change. Permission shouldn’t be an issue since the directory is owned by the git user and set 775. – dacracot May 21 '18 at 20:10

You have created a system that is significantly more complicated to debug then needs to by duplicating a number of pieces of systemd functionality in unnecessary shell scripts. systemd has built-in facilities to start, stop and restart services, provide their status and handle their output.

By removing this layer of complexity, you will have eliminated a significant surface area where bugs can exist and will be that much closer to solving your problem.

I recommend using one of existing templates already posted online for managing git-daemon with systemd if your system doesn't already ship one.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.