| doc/syncgit.mdtext |
| 1 | # Plugin SyncGit by Céondo Ltd |
| 2 | |
| 3 | The SyncGit plugin allow the direct creation and synchronisation of |
| 4 | git repositories with the InDefero database. This requires giving |
| 5 | access to the repositories using a dedicated SSH account, usually the |
| 6 | `git` account. |
| 7 | |
| 8 | ## Prerequisites |
| 9 | |
| 10 | A good understanding of: |
| 11 | |
| 12 | * the security issues related to using a SSH account on a server; |
| 13 | * the principle of public/private SSH keys; |
| 14 | * the rights/ownership of files on a Linux/BSD/nix system; |
| 15 | |
| 16 | Yes, what you are going to do has security implications. |
| 17 | |
| 18 | ## Git user configuration |
| 19 | |
| 20 | On your system, you will need to create a new `git` account. This |
| 21 | account will only be used to access the git repositories and at the |
| 22 | moment cannot be shared for other use. |
| 23 | |
| 24 | First create a new git account: |
| 25 | |
| 26 | $ sudo adduser \ |
| 27 | --system \ |
| 28 | --shell /bin/sh \ |
| 29 | --gecos 'git version control' \ |
| 30 | --group \ |
| 31 | --disabled-password \ |
| 32 | --home /home/git \ |
| 33 | git |
| 34 | |
| 35 | Then, we need to create the base SSH files with the right permissions: |
| 36 | |
| 37 | $ sudo su git |
| 38 | $ mkdir /home/git/.ssh |
| 39 | $ touch /home/git/.ssh/authorized_keys |
| 40 | $ chmod 0700 /home/git/.ssh |
| 41 | $ chmod 0600 /home/git/.ssh/authorized_keys |
| 42 | $ exit |
| 43 | |
| 44 | ## Creation of the repositories base |
| 45 | |
| 46 | For each project using git in InDefero a corresponding bare repository |
| 47 | will be created in `/home/git/repositories`. For example, if the |
| 48 | shortname of your project is `wonder`, it will be created in |
| 49 | `/home/git/repositories/wonder.git` |
| 50 | |
| 51 | $ sudo -H -u git mkdir /home/git/repositories |
| 52 | |
| 53 | ## InDefero Configuration |
| 54 | |
| 55 | First, you need to have python installed on your system to be able to |
| 56 | run the very small python script `gitserve.py` in the `scripts` |
| 57 | folder. Here is a configuration example: |
| 58 | |
| 59 | |
| 60 | $cfg['git_repositories'] = '/home/git/repositories/%s.git'; |
| 61 | $cfg['git_remote_url'] = 'git://yourdomain.com/%s.git'; |
| 62 | $cfg['idf_plugin_syncgit_path_gitserve'] = '/home/www/indefero/scripts/gitserve.py'; # yes .py |
| 63 | $cfg['idf_plugin_syncgit_path_authorized_keys'] = '/home/git/.ssh/authorized_keys'; |
| 64 | $cfg['idf_plugin_syncgit_sync_file'] = '/tmp/SYNC-GIT'; |
| 65 | |
| 66 | When someone will change his SSH key or add a new one, the |
| 67 | `/tmp/SYNC-GIT` file will be created. The cron job |
| 68 | `/home/www/indefero/scripts/gitcron.php` will see the file and update |
| 69 | the content of the `authorized_keys` file. |
| 70 | |
| 71 | ## Cron Job Configuration |
| 72 | |
| 73 | You need to run a cron job every now and then to synchronize the SSH |
| 74 | keys. The command to run in the cron job is: |
| 75 | |
| 76 | php /home/www/indefero/scripts/gitcron.php |
| 77 | |
| 78 | The user of the cron job must be `git`. |