|
Installing gitolite on dreamhostby Paal, last mod: Mon Jun 13 14:40:24 -0700 2011
Create a new user user called for example repouser on dreamhost (using dreamhost panel) with ssh access.
On your local machine create a key-pair for the "virtual gitolite admin user" called gitlit (not the same user as repouser, repouser needs no keypair):
cd ~/.ssh
ssh-keygen -t rsa -f gitlit
scp gitlit.pub gitlit@yourhost.dreamhost.com:~/gitlit.pub
Log into your dreamhost machine:
ssh repouser@yourhost.dreamhost.com
On your server, as repouser (the "hosting user"), first check if $HOME/bin is on the default PATH. If not, fiddle with the .bashrc or .bash_profile or similar files and add it somehow.
git clone git://github.com/sitaramc/gitolite
cd gitolite
src/gl-system-install
# defaults to being the same as:
# src/gl-system-install $HOME/bin $HOME/share/gitolite/conf $HOME/share/gitolite/hooks
Then do:
gl-setup gitlit.pub
The default settings in the rc file (/home/repouser/.gitolite.rc) are fine for most
people but if you wish to make any changes, you can do so now.
hit enter...
creating gitolite-admin...
Initialized empty Git repository in /home/repouser/repositories/gitolite-admin.git/
creating testing...
Initialized empty Git repository in /home/repouser/repositories/testing.git/
[master (root-commit) e49a668] start
2 files changed, 6 insertions(+), 0 deletions(-)
create mode 100644 conf/gitolite.conf
create mode 100644 keydir/gitlit.pub
Then do:
rm gitlit.pub
Back on your local machine:
Go to wherever you want the gitolite-admin repo. Do:
git clone repouser@yourhost.dreamhost.com:gitolite-admin.git
The user you want to commit and pull as does not have to be the same as the one you are logged in as on your local machine (no surprise). To use the user foo for communicating with gitolite, then put the following in your ~/.ssh/config
Host yourhost.dreamhost.com
User foo
Hostname yourhost.dreamhost.com
Port 22
IdentityFile ~/.ssh/foo
Ensure that .ssh/foo is the private key of foo, and that foo.pub has been added to keydir in gitolite-admin (which initially only can be edited when your .ssh identifies you as gitlit (because that is the user you specified as input to gl-setup)). conf can look like this:
more conf/gitolite.conf
repo gitolite-admin
RW+ = gitlit
repo testing
RW+ = @all
repo bar
RW = foo
Whenever you commit a change to gitlite-admin, make sure you also do git push origin master, to ACTUALLY create the new users and repos.
~/.ssh/config should look like this when working as gitlit:
Host yourhost.dreamhost.com
User gitlit
Hostname yourhost.dreamhost.com
Port 22
IdentityFile ~/.ssh/gitlit
Again, make sure ~/.ssh/gitlit is actually there on your local machine AND is the private key that matches gitlib.pub which you fed to gl-setup. Make sure you have no other entries to yourhost.dreamhost.com.
NOTE: I did not get this method of changing user login working on both of my local machines. On one, no matter what I put in .ssh/config I was always logged on as my default local user. This was possibly due to lack of .ssh/config knowledge. In any case, I worked around it by adding my default local user with RW+ permissions to gitolite-admin repo (from the machine where I did have access).
If you need to login on the server with repouser BYPASSING gitolite, then make sure you have no references to yourhost.dreamhost.com in your .ssh/config file.
Please note the following. VERY IMPORTANT All commits and pulls for all users should be with user repouser in the url. The individual user is determined by your keys and config in the .ssh dir.
Inspired by:
http://sitaramc.github.com/gitolite/doc/1-INSTALL.html#_non_root_method
On the same dreamhost user (let's call him julius) which is running redmine, log in and create a directory which you for example can call ~/repositories. We assume now that it is not the same user in which user directory gitolite is installed.
Go to .ssh (still logged in as julius on dreamhost). Create a ssh keypair to be able to pull git repositories from your gitolite server:
ssh-keygen -t rsa -f mydreamhostredmine
In .ssh/config add the following:
Host yourhost.dreamhost.com
User mydreamhostredmine
Hostname yourhost.dreamhost.com
Port 22
IdentityFile ~/.ssh/mydreamhostredmine
Copy the public key to your local box (where you have access to gitolite-admin). Add it to the keydir. Add mydreamhostredmine as a user to the repositories to which it should have access in conf/gitolite.conf like so:
repo foo
R = mydreamhostredmine
Commit and push gitolite-admin.
Back on dreamhost logged in as julius, go to ~/repositories/ and do:
git clone repouser@yourhost.dreamhost.com:foo
Now you should see your repository being checked out.
To connect the git repository foo to redmine, log into redmine through a web browser. Enter the project which should be linked to the repository foo. Go to settings. Enter repository. Create a new git repository. The path given should be /home/julius/repositories/foo/.git
Now we need to connect regularly pull update to the repository. We will do it every ten minutes through a dreamhost cronjob. Logged in on dreamhost through ssh as julius, add script doing updates, e.g. ~/scripts/repo_get_foo_updates.sh
It should contain the following:
cd /home/julius/repositories/foo && git pull
cd /home/paalvibe/yourredminepath.com && /usr/bin/ruby1.8 script/runner "Repository.fetch_changesets" -e production
yourredminepath.com should be replace by the path to your redmine dir (which should be a rails root dir).
If you want to track all branches (not just master) the first line should be:
cd /home/julius/repositories/foo && git pull --all
Note that if your redmine has several repositories, calling Repository.fetch_changesets will try to pull all of them and if some of them are still empty you could get an error like:
fatal: bad default revision 'HEAD'
The fix for this is to make sure they have at least an empty README file (so to have a HEAD), and add pull statements for each repository right after the foo statement like so:
cd /home/julius/repositories/foo && git pull
cd /home/julius/repositories/bar && git pull
cd /home/paalvibe/yourredminepath.com && /usr/bin/ruby1.8 script/runner "Repository.fetch_changesets" -e production
In dreamhost web panel go to Goodies->Cron Jobs add a new cronjob and set it up to run your script in scripts/repo_get_foo_updates.sh every ten minutes as julius. Make sure there is no newline after the script path.
Inspired by http://www.simonecarletti.com/blog/2009/07/configuring-git-repository-with-redmine/tags: gitolite, ssh, git, dreamhost, redmine Edit |
||
