First commit
This commit is contained in:
commit
3054f253e8
|
@ -0,0 +1,19 @@
|
||||||
|
Copyright 2022 bursa-pastoris <bursapastoris at disroot dot org>
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
|
@ -0,0 +1,67 @@
|
||||||
|
`yagrmm` (Yet Another Git Remote Mirror Manager) is a simple script to
|
||||||
|
automatically update remote mirrors or git repositories. At the moment
|
||||||
|
`yagrmm` only works only if push and pull can be done without SSH keys without
|
||||||
|
passphrase or without authentication at all.
|
||||||
|
|
||||||
|
Whenever `yagrmm` is run, it will pull new commits from the original repo and
|
||||||
|
push them to the mirror. It can be run manually or periodically - e.g. with
|
||||||
|
`crontab`.
|
||||||
|
|
||||||
|
## Notice - Please read this
|
||||||
|
|
||||||
|
Some software provide the option to configure mirroring from the web interface,
|
||||||
|
so that the server automatically pulls commits from the original repo - that's
|
||||||
|
the case for
|
||||||
|
[GitLab](https://docs.gitlab.com/ee/user/project/repository/mirror/) and
|
||||||
|
[Gitea](https://docs.gitea.io/en-us/repo-mirror/#pulling-from-a-remote-repository).
|
||||||
|
If your provider uses one of these softwares but has disabled such function, he
|
||||||
|
probably has good reasons for doing so - usually limited server resources. If
|
||||||
|
your run `yagrmm` periodically, please limit yourself to the strictly necessary
|
||||||
|
and do not hoard your provider's resources.
|
||||||
|
|
||||||
|
## How-to
|
||||||
|
|
||||||
|
To use `yagrmm`, follow these steps.
|
||||||
|
|
||||||
|
1. Create a local mirror of the repository to mirror with `git clone --mirror
|
||||||
|
<original-repo-URL>`.
|
||||||
|
2. Add the path of the mirror to `~/.config/yagrmm/repolist`. `~` can be used
|
||||||
|
to refer to `/home/<user>` and is always expanded.
|
||||||
|
3. In the copy of the repository, edit `config` and in the section `[remote
|
||||||
|
"origin"]` add the following line below the one beginning with `URL = `:
|
||||||
|
|
||||||
|
pushUrl = <remote-mirror-URL>
|
||||||
|
|
||||||
|
so that the resulting section looks like
|
||||||
|
|
||||||
|
[remote "origin"]
|
||||||
|
url = <original-repo-URL>
|
||||||
|
pushUrl = <remote-mirror-URL>
|
||||||
|
fetch = +refs/*:refs/*
|
||||||
|
mirror = true
|
||||||
|
|
||||||
|
|
||||||
|
If - as you should - you push to the mirror with a key different from the one
|
||||||
|
you use to manual pushes to other repos (such as
|
||||||
|
[GitLab](https://docs.gitlab.com/ee/user/project/deploy_keys/) and Gitea's
|
||||||
|
deploy keys), you may find useful a trick to make SSH use the right one. You
|
||||||
|
must configure SSH adding a paragraph like the following to `~/.ssh/config`:
|
||||||
|
|
||||||
|
Host mirror.<remote-mirror-domain-name>
|
||||||
|
HostName <remote-mirror-domain-name>
|
||||||
|
IdentityFile <remote-mirror_push_key>
|
||||||
|
|
||||||
|
For example:
|
||||||
|
|
||||||
|
Host mirror.disroot.org
|
||||||
|
HostName disroot.org
|
||||||
|
IdentityFile ~/.ssh/mirror_push_key
|
||||||
|
|
||||||
|
And then you can use `mirror.<remote-mirror-domain-name>` as the domain name
|
||||||
|
for the `pushUrl`, for example
|
||||||
|
|
||||||
|
pushUrl = git@mirror.disroot.org:username/disroot-howto-mirror.git
|
||||||
|
|
||||||
|
# License
|
||||||
|
|
||||||
|
`yagrmm` is distributed under the [Expat (aka MIT) license](./LICENSE).
|
|
@ -0,0 +1,17 @@
|
||||||
|
#!/usr/bin/python3
|
||||||
|
|
||||||
|
from pathlib import Path as path
|
||||||
|
from subprocess import run
|
||||||
|
|
||||||
|
home = str(path.home())
|
||||||
|
|
||||||
|
with open(home+"/.config/yagrmm/repolist") as repolist_file:
|
||||||
|
repolist = repolist_file.read().splitlines()
|
||||||
|
|
||||||
|
for i in range(len(repolist)):
|
||||||
|
repolist[i] = repolist[i].replace("~", home)
|
||||||
|
|
||||||
|
for repo in repolist:
|
||||||
|
print(repo)
|
||||||
|
run(["git", "-C", repo, "pull"])
|
||||||
|
run(["git", "-C", repo, "push"])
|
Reference in New Issue