25 August 2009

Mercurial on Synology

First telnet, and boostrap to install ipkg, classic (look at this and uses this).

Then ipkg install py26-mercurial (many mercurial flavours in repository btw: one for every major python version).

Now mercurial should be installed somewhere in '/opt/bin' (which redirects to '/volume1/@optware/bin'), type hg -v to check this (or maybe hg-2.6 -v as ipkg apparently let me do the symbolic link: ln /opt/bin/hg /opt/bin/hg-2.6).

You need to have some directory ready to hold a code repository, e.g. '//volume1/repos', executing hg init /volume1/repos/testhg will init/create a mercurial dir with (hidden) management files in it.

We could start working in this, as a shared folder on the network (\\diskstation\repos\testhg), or via http (execute cd /volume1/repos/testhg, and hg serv, it mounts an http server on port 8000, accessible via 'http://192.168.0.X:8000' !), or via ssh (through 'ssh://user@192.168.0.x//volume1/repos/testhg') ! So Nice !

I finally choosed the ssh way, to easily secure transaction.

So, now ssh on synology:

Let's activate the service using the web interface.
Test it using kitty or plink with: plink.exe -ssh -2 root@192.168.0.X "set" should print a lot of variables contents.

But, if we execute plink.exe -ssh -2 root@192.168.0.X "hg": it should fail with ash: hg: not found. When the ssh daemon starts a session, it uses only a subset of the usual user environment, so our PATH variable is missing directories, hence cant find hg.

We might override this by editing (vi) /etc/ssh/sshd_config on the synology, to set PermitUserEnvironment yes.
(to restart the ssh daemon after this, type killall sshd and /usr/syno/etc.defaults/rc.d/S95sshd.sh start)
This script mod triggers the execution of a script $HOME/.ssh/environment for each ssh session creation: let's create such (executable) script with the line PATH=/opt/bin:/opt/sbin:$PATH in it.

Now back to plink: we should now be able to execute hg through ssh.

And... Everything should roll from this point :)

(Once in a while, telnet into your box (putty) and ipkg update and ipkg upgrade)