1. Create a user in your gitlab, name it `gitmirror`
2. Create a user on your linux machine, call it `gitmirror` by running: `sudo adduser gitmirror`
3. Switch to the new user by typing `su - gitmirror` and by default you are, but make sure you are in it's home directory by typing `cd ~`
4. Clone this repo by typing `git clone https://github.com/Facinorous-420/gitmirrors-bs.git`
5. Enter the new directory by typing `cd gitmirrors-bs`
6. Edit setup.conf by typing `nano setup.conf`
7. Give the setup script execute permissions by typing `chmod u+x ./setup`
<br>
Be sure to read the config and change all things to your desired specifications. Refer to the comments in that file for info on what everything is.
Do not edit anything under the system variables section, only the user variables. You'll need to generate a Personal Access Token in the user `gitmirror` on gitlab for the config.
**NOTE:** Currently you must create the groups in gitlab using the `gitmirror` user manually. This will be changed in a future update. Once this text is gone, it'll be automatic.
8. Run `./setup` to begin the automatic set up process.
9. Once the set up is done, you will be given a SSH key. Login to your `gitmirror` account on your gitlab instance, and add that SSH key to it.
10. Run `./setcron` to add the mirror cron jobs to the users cron table
# Mirroring
Run <code>./mirror</code> to set up a mirror
If you at any time want to add more groups you can mirror to, simply add them to the setup.conf file and rdo the set up process again.
<br>
The full syntax for the command is `./mirror -g GROUPNAME -n REPONAME -r SOURCEREPOLOCATION`
Where `-g` means **destination group name**, `-n` means **destination repo name**, and `-r` means **source repo location**
<br>
If you at any time want to add more groups you can mirror to, simply add them to the setup.conf file and redo the set up process.
== UPDATING DEPENDANCIES ==
# Updating
Use <code>./update</code> to update your gitlab-mirror dependancy
You might find out that gitlab-mirror doesn't actually update that often. Although, if it ever does, you can simply run `./update` to update your project's gitlab-mirror.
== FILE STRUCTURE ==
# Updating
When done, the file structure in your system should look as such:
```
/home/gitmirror/gitmirrors-bs
@ -41,3 +80,7 @@ Use <code>./update</code> to update your gitlab-mirror dependancy
└── Group2
└── GitLab Enterprise Edition
```
# Great Thanks
Great thanks to the original creator of [gitlab-mirrors](https://github.com/samrocketman/gitlab-mirrors), [samrocketman](https://github.com/samrocketman) obviously as that is the main foundation to these bash scripts.
sed "37s/.*/gitlab_namespace=\"${group}\"/" ~/$projectLocation/mirrormanagement/$group/config.sh.SAMPLE > ~/$projectLocation/mirrormanagement/$group/config.sh
sed -i "39s/.*/gitlab_url=\"${gitlabURL}\"/" ~/$projectLocation/mirrormanagement/$group/config.sh
sed -i "39s,.*,gitlab_url=\"${gitlabURL}\"," ~/$projectLocation/mirrormanagement/$group/config.sh
sed -i "42s/.*/gitlab_user=\"${gitlabUser}\"/" ~/$projectLocation/mirrormanagement/$group/config.sh
sed -i "50s/.*/http_remote=true/" ~/$projectLocation/mirrormanagement/$group/config.sh
sed -i "58s/.*/issues_enabled=\"${issues_enabled}\"/" ~/$projectLocation/mirrormanagement/$group/config.sh
sed -i "59s/.*/wall_enabled=\"${wall_enabled}\"/" ~/$projectLocation/mirrormanagement/$group/config.sh
sed -i "60s/.*/wiki_enabled=\"${wiki_enabled}\"/" ~/$projectLocation/mirrormanagement/$group/config.sh
sed -i "61s/.*/snippets_enabled=\"${snippets_enabled}\"/" ~/$projectLocation/mirrormanagement/$group/config.sh
sed -i "62s/.*/gitlab_user=\"${merge_requests_enabled}\"/" ~/$projectLocation/mirrormanagement/$group/config.sh
sed -i "62s/.*/merge_requests_enabled=\"${merge_requests_enabled}\"/" ~/$projectLocation/mirrormanagement/$group/config.sh
sed -i "63s/.*/public=\"${public}\"/" ~/$projectLocation/mirrormanagement/$group/config.sh
done
# Generate an ssh key
# Generate a ssh key
echo -e "\n\n\n" | ssh-keygen -t rsa
# Generate ssh server config
mkdir ~/.ssh
cat > ~/.ssh/config <<EOF
Host $gitlabURL
User git
@ -43,7 +43,7 @@ for group in "${groupArray[@]}"; do
sed "37s/.*/gitlab_namespace=\"${group}\"/" ~/$projectLocation/mirrormanagement/$group/config.sh.SAMPLE > ~/$projectLocation/mirrormanagement/$group/config.sh
sed -i "39s/.*/gitlab_url=\"${gitlabURL}\"/" ~/$projectLocation/mirrormanagement/$group/config.sh
sed -i "42s/.*/gitlab_user=\"${gitlabUser}\"/" ~/$projectLocation/mirrormanagement/$group/config.sh
@ -148,5 +149,5 @@ echo ""
echo "Please put this SSH key into your gitlab mirror user."