diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..1838ef89fb97122d0bb85aa87748072a490bffd0 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +Copyright (c) 2013 Sam Gleske +Copyright (c) 2013 Drexel University + +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. + diff --git a/README.md b/README.md index 317e4ddbf6168361071c29b30665cef621b1e6a4..6d0c02daedb886177e545f9d9e1362944f8e1227 100644 --- a/README.md +++ b/README.md @@ -2,85 +2,35 @@ The git-mirrors project is designed to fill in a feature which is currently missing from GitLab: the ability to mirror remote repositories. git-mirrors creates read only copies of remote repositories in gitlab. It provides a CLI management interface for managing the mirrored repositories (e.g. add, delete, update) so that an admin may regularly update all mirrors using `crontab`. It operates by interacting with the [GitLab API][1] using [python-gitlab][2]. -This adds git mirror functionality to gitlab. The whole purpose of this project is to mirror projects using the [Mirror group](https://comet.irt.drexel.edu/admin/groups/mirrors). - --- -# Prerequisites - -### Required software - -* [GitLab 6.x][3] -* [python-gitlab @ 5da9bc7][2] -* [GNU coreutils][4] -* [git 1.8.4][5] - -### Required software install snippets -python-gitlab - - yum install python-setuptools - git clone https://github.com/Itxaka/python-gitlab.git - cd python-gitlab - git checkout 5da9bc7ffcfdca34d86cc69c34caa7a84d27cfaa - python setup.py - -You can find the source to git at the [git-core project](http://code.google.com/p/git-core/). For instructions on other platforms see the [Getting Started - Installing Git section of the git book](http://git-scm.com/book/en/Getting-Started-Installing-Git). - - yum install perl-ExtUtils-MakeMaker zlib zlib-devel openssh libcurl libcurl-devel expat expat-devel gettext gettext-devel - cd /usr/local/src/ - git clone https://code.google.com/p/git-core/ - cd git-core/ - git tag - git checkout v1.8.4 - make configure - ./configure --prefix=/usr/local - make - make install +# Three easy steps -Your git should now be located in `/usr/local/bin/git`. You should edit `/etc/profile` and place `/usr/local/bin` at the beginning of your `$PATH`. +1. [Setup prerequisites](docs/prerequisites.md) +2. [Install git-mirrors](docs/installation.md) +3. [Manage your mirrors](docs/management.md) --- -# Installation and Setup - -Create a system user called `gitmirror` and generate SSH keys. - - adduser gitmirror - su - gitmirror - ssh-keygen - -Create `~/.ssh/config` for the `gitmirror` user. Add your GitLab server host and the user used to talk to GitLab. - - Host gitlab.example.com - User git - -Create a gitmirror user in gitlab. Set up the SSH keys with the gitmirror user in GitLab. Obtain the Private token from the user. - -Clone the git-mirrors repository and set values in config.sh. - - su - gitmirrors - mkdir repositories - touch private_token - git clone https://comet.irt.drexel.edu/gitlab/gitlab-mirrors.git - cd gitlab-mirrors - chmod 755 *.sh - cp config.sh.SAMPLE config.sh +# License -Modify the values in `config.sh` for your setup. Be sure to add your private token for the gitmirror user in gitlab to `~/private_token` of your `gitmirror` system user. +Created by Sam Gleske under [MIT License](LICENSE). This project is meant to temporarily fill in a gap left by GitLab for managing remote git mirrors. See the following user voice topics which made me create this project in the mean time. -Once you have set up your `config.sh` let's add the `git-mirrors.sh` script to `crontab`. Just execute `crontab -e` and add the following value to it. +* [Mirror git/svn into repo.][3] +* [Feature request -- Multi-Master mirroring][4] - @hourly /home/gitmirror/gitlab-mirrors/git-mirrors.sh --- ## References -* [Git mirror](http://stackoverflow.com/questions/2756747/mirror-a-git-repository-by-pulling) -* [Git push all branches](http://stackoverflow.com/questions/1914579/set-up-git-to-pull-and-push-all-branches) -* [Git update mirror](https://github.com/ndechesne/git-mirror/blob/master/git-mirror) +* [Git mirror][5] +* [Git push all branches][6] +* [Git update mirror][7] [1]: https://github.com/gitlabhq/gitlabhq/blob/master/doc/api/README.md [2]: https://github.com/Itxaka/python-gitlab -[3]: https://github.com/gitlabhq/gitlabhq/tree/6-0-stable -[4]: http://www.gnu.org/software/coreutils/ -[5]: http://git-scm.com/ +[3]: http://feedback.gitlab.com/forums/176466-general/suggestions/4286666-mirror-git-svn-into-repo- +[4]: http://feedback.gitlab.com/forums/176466-general/suggestions/3697598-feature-request-multi-master-mirroring +[5]: http://stackoverflow.com/questions/2756747/mirror-a-git-repository-by-pulling +[6]: http://stackoverflow.com/questions/1914579/set-up-git-to-pull-and-push-all-branches +[7]: https://github.com/ndechesne/git-mirror/blob/master/git-mirror diff --git a/docs/installation.md b/docs/installation.md new file mode 100644 index 0000000000000000000000000000000000000000..29c183e5435b3a4fc3e80a9a6b3085b5c53d48e8 --- /dev/null +++ b/docs/installation.md @@ -0,0 +1,31 @@ +# Installation and Setup + +Create a system user called `gitmirror` and generate SSH keys. + + adduser gitmirror + su - gitmirror + ssh-keygen + +Create `~/.ssh/config` for the `gitmirror` user. Add your GitLab server host and the user used to talk to GitLab. + + Host gitlab.example.com + User git + +Create a gitmirror user in gitlab. Set up the SSH keys with the gitmirror user in GitLab. Obtain the Private token from the user. + +Clone the git-mirrors repository and set values in config.sh. + + su - gitmirrors + mkdir repositories + touch private_token + git clone https://github.com/sag47/git-mirrors.git + cd gitlab-mirrors + chmod 755 *.sh + cp config.sh.SAMPLE config.sh + +Modify the values in `config.sh` for your setup. Be sure to add your private token for the gitmirror user in gitlab to `~/private_token` of your `gitmirror` system user. + +Once you have set up your `config.sh` let's add the `git-mirrors.sh` script to `crontab`. Just execute `crontab -e` and add the following value to it. + + @hourly /home/gitmirror/gitlab-mirrors/git-mirrors.sh + diff --git a/docs/management.md b/docs/management.md new file mode 100644 index 0000000000000000000000000000000000000000..ab34a8e8ce739306282cbfb8740bbaf7215865e4 --- /dev/null +++ b/docs/management.md @@ -0,0 +1,25 @@ +# Managing mirrored repositories + +A short overview of managing mirrored repositories. This assumes you have already [installed git-mirrors](installation.md). + +### Create a mirror + + su - gitmirror + cd git-mirrors + ./add_mirror.sh project_name http://example.com/repository.git + +### Update a mirror + + su - gitmirror + cd git-mirrors + ./update_mirror.sh project_name + +### Update all known mirrors + + su - gitmirror + cd git-mirrors + ./git-mirrors.sh + +Updating all known mirrors is also meant to be used with `crontab`. + + @hourly /home/gitmirror/git-mirrors/git-mirrors.sh diff --git a/docs/prerequisites.md b/docs/prerequisites.md new file mode 100644 index 0000000000000000000000000000000000000000..9e8f694e375b0975f53a65a5f87bf4b07dd17ae9 --- /dev/null +++ b/docs/prerequisites.md @@ -0,0 +1,39 @@ +# Prerequisites + +### Required software + +* [GitLab 6.x][1] +* [python-gitlab @ 5da9bc7][2] +* [GNU coreutils][3] +* [git 1.8.4][4] + +### Required software install snippets +python-gitlab + + yum install python-setuptools + git clone https://github.com/Itxaka/python-gitlab.git + cd python-gitlab + git checkout 5da9bc7ffcfdca34d86cc69c34caa7a84d27cfaa + python setup.py + +You can find the source to git at the [git-core project][5]. For instructions on other platforms see the [Getting Started - Installing Git section of the git book][6]. + + yum install perl-ExtUtils-MakeMaker zlib zlib-devel openssh libcurl libcurl-devel expat expat-devel gettext gettext-devel + cd /usr/local/src/ + git clone https://code.google.com/p/git-core/ + cd git-core/ + git tag + git checkout v1.8.4 + make configure + ./configure --prefix=/usr/local + make + make install + +Your git should now be located in `/usr/local/bin/git`. You should edit `/etc/profile` and place `/usr/local/bin` at the beginning of your `$PATH`. + +[1]: https://github.com/gitlabhq/gitlabhq/tree/6-0-stable +[2]: https://github.com/Itxaka/python-gitlab +[3]: http://www.gnu.org/software/coreutils/ +[4]: http://git-scm.com/ +[5]: http://code.google.com/p/git-core/ +[6]: http://git-scm.com/book/en/Getting-Started-Installing-Git