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...
#!/bin/bash
case "$1" in
'start')
echo "Starting git-daemon"
/home/git/scripts/start.sh >> /home/git/gitT.log
;;
'stop')
echo "Stopping git-daemon"
/home/git/scripts/stop.sh >> /home/git/gitT.log
;;
'restart')
echo "Bouncing git-daemon"
/home/git/scripts/bounce.sh >> /home/git/gitT.log
;;
'status')
echo "Status of git-daemon"
/home/git/scripts/status.sh
;;
*)
echo "`basename $0`: usage: `basename $0` { stop | start | restart | status }"
;;
esac
Secondary scripts are...
start.sh
#!/bin/bash
# --------------------------
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`"
stop.sh
#!/bin/bash
# --------------------------
echo "---------------------"
pkill -F /home/git/git-daemon.pid
echo "---------------------"
echo "STOPPED at `date`"
bounce.sh
#!/bin/bash
# --------------------------
echo "====================="
/home/git/scripts/stop.sh
echo "====================="
sleep 5
echo "====================="
/home/git/scripts/start.sh
echo "====================="
echo "BOUNCED"
and status.sh
#!/bin/bash
# --------------------------
echo "====================="
ps -x --forest
echo "====================="
Finally I created a service file (git-daemon.service)...
[Unit]
Description=Git Daemon
Documentation=man:git-daemon(1)
ConditionPathExists=/home/git/repos
[Service]
Type=oneshot
ExecStart=/bin/bash /home/git/gitT start
ExecStop=/bin/bash /home/git/gitT stop
RemainAfterExit=yes
User=git
Group=git
[Install]
WantedBy=multi-user.target
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