diff --git a/README.md b/README.md index e07b31a0fa61a8c63222ed3c53ca99e7d5351ca9..63b8f867612782c393231f8904a998e1535afdb7 100644 --- a/README.md +++ b/README.md @@ -11,9 +11,9 @@ This adds git mirror functionality to gitlab. The whole purpose of this project ### Required software * [GitLab 6.x][3] -* [python-gitlab @ 5da9bc][2] +* [python-gitlab @ 5da9bc7][2] * [GNU coreutils][4] -* [git][5] +* [git 1.8.4][5] ### Required software install snippets python-gitlab @@ -43,21 +43,41 @@ Your git should now be located in `/usr/local/bin/git`. You should edit `/etc/p --- #Installation and Setup -Create a system user called `gitmirror`. +Create a system user called `gitmirror` and generate SSH keys. adduser gitmirror su - gitmirror ssh-keygen -Create `~/.ssh/config` for the `gitmirror` user. +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 + +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 --- ## 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](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) [1]: https://github.com/gitlabhq/gitlabhq/blob/master/doc/api/README.md [2]: https://github.com/Itxaka/python-gitlab diff --git a/config.sh b/config.sh index 21440fab333f30e29d8250730df40d1a79e5aa07..2bc515279a1b2c6984ad1540e53f1add93cdce00 100644 --- a/config.sh +++ b/config.sh @@ -3,7 +3,10 @@ # # gitlab-mirror settings # -repo_dir="/home/gitmirror/repositories" + +system_user="gitmirror" +user_home="/home/${system_user}" +repo_dir="${user_home}/repositories" # # Gitlab settings @@ -16,4 +19,4 @@ gitlab_url="https://comet.irt.drexel.edu" #Special user you created in Gitlab whose only purpose is to update mirror sites and admin the $gitlab_namespace group. gitlab_user="gitmirror" #Generate a token for your $gitlab_user and set it here. -gitlab_user_token_secret="$(head -n1 /home/gitmirror/private_token)" +gitlab_user_token_secret="$(head -n1 "${user_home}/private_token")" diff --git a/config.sh.SAMPLE b/config.sh.SAMPLE new file mode 100644 index 0000000000000000000000000000000000000000..36c20582580fbe1477982fb5ecac37e5b289fa22 --- /dev/null +++ b/config.sh.SAMPLE @@ -0,0 +1,23 @@ +#Environment file + +# +# gitlab-mirrors settings +# + +#The user git-mirrors will run as. +system_user="gitmirror" +user_home="/home/${system_user}" +repo_dir="${user_home}/repositories" + +# +# Gitlab settings +# + +#This is the Gitlab group where all project mirrors will be grouped. +gitlab_namespace="Mirrors" +#This is the web url of your Gitlab server. no trailing slash, just the protocol and server name. +gitlab_url="https://gitlab.example.com" +#Special user you created in Gitlab whose only purpose is to update mirror sites and admin the $gitlab_namespace group. +gitlab_user="gitmirror" +#Generate a token for your $gitlab_user and set it here. +gitlab_user_token_secret="$(head -n1 "${user_home}/private_token")"