-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mirror public repos gitlab #3
Comments
I installed git-daemon which includes systemd [email protected] and git.socket files. I copied these to make a new service called git-daemon, like so: [root@gitlab ~]# cp /usr/lib/systemd/system/[email protected] \
/etc/systemd/system/[email protected]
[root@gitlab ~]# cp /usr/lib/systemd/system/git.socket \
/etc/systemd/system/git-daemon.socket
[root@gitlab ~]# systemctl daemon-reload Then I edited the git-daemon.socket to point it to the git repositories, [Unit]
Description=Git Repositories Server Daemon
Documentation=man:git-daemon(1)
[Service]
User=git
ExecStart=-/usr/libexec/git-core/git-daemon \
--base-path=/var/opt/gitlab/git-data/repositories/ \
--syslog --inetd --verbose
StandardInput=socket start enable the service
As per the git-daemon.service systemd file, you should now have git-daemon listening on port 9418, however you may need to open the port through the firewall:
Now, to enable git:// access to any given repository, you need to touch a file called git-daemon-export-ok in that repo’s git dir (it should be owned by your gitlab user, which is probably git). For example, a mirror of the Linux kernel: touch /var/opt/gitlab/git-data/repositories/mirror/linux.git/git-daemon-export-ok Success! If you wanted to, you could set up a cron job to make sure that any new mirrors that come along are exported without manual intervention. First, create an executable script somewhere, like /usr/local/bin/export_git-daemon_repos.sh (note, this excludes any wiki git repos). #!/bin/bash
set -eo pipefail
if [[ "$USER" != "git" ]]; then
echo "Only run this as the git user."
exit 1
fi
cd /var/opt/gitlab/git-data/repositories/mirror
for x in $(ls -d * |grep -v \.wiki\.git) ; do
pushd ${x}
if [[ ! -e "git-daemon-export-ok" ]]; then
touch git-daemon-export-ok
fi
popd
done Then add it as a cron job for the git user on your gitlab server to run every two hours, or whatever suits you, e.g.:
|
So for example, to mirror Linux, I first create a new project in the GitLab mirror group called linux (this would be accessed at something like https://gitlab/mirror/linux.git).
Then as the mrmirror user on GitLab I run a mirror clone:
Then the script takes care of future updates and pushes them directly to GitLab via localhost:
That’s managed by a simple cronjob that the mrmirror user has on the GitLab server:
And that seems to be working really well.
The text was updated successfully, but these errors were encountered: