SEISMIC stands for:
S – Self
E – Explanatory
I – Installer
S – Sharing
M – Mercurial
I – Intercourse
C – Cupcakes
Okay, so the last two words don’t fit with the topic. I had to put them in to pad out the acronym. Here’s how you run it:
wget http://earwicker.com/seismic.sh sudo bash seismic.sh
Ideally you’ll be typing those two lines into a fresh install of Ubuntu 11.10. Even if your install isn’t so fresh, the script tries to only set things up if they haven’t already been set up.
After it does the first-time steps, it offers you some options:
 Add user
 Add repository
Like I say, it’s self-explanatory. Maybe there’s a quicker way to get started and do the obvious maintenance tasks for sharing mercurial repositories, but I don’t know about it yet.
Once you’ve run it, you can see your new shared repositories here:
You’ll need to log in using one of the user accounts you’ve created. You can also clone a repository on a client machine:
And you can commit and push changes back to it – again,
hg push will require your Mercurial username/password.
Running Windows? Oh dear. Why not set up a VM? (Don’t have any VM hosting software? VirtualBox is free).
The config created by this script is very simple (so it has a high probability of working). But on the downside it’s not really secure, basic basic (plain text) authentication is used. But it gives you a working starting point to investigate further, e.g. as the song goes, “If you liked it then you should have put a certificate on it”.
Tips for setting up a VM:
– Download the Ubuntu server 64-bit .iso
– Set up your VM so it has a terabyte virtual disk and grows on demand, and a bridged network connection instead of NAT.
– During install you should get to specify a suitable hostname. If not (or you change your mind about it), after your first login:
sudo nano /etc/hostname
In case the script download site goes wrong, here’s what it contains:
# Install apache and mercurial apt-get install apache2 mercurial # Create dir /var/hg/repos where all repositories will live if [ -d /var/hg/repos ] then echo "Already created /var/hg/repos" else mkdir /var/hg mkdir /var/hg/repos chown -R www-data:www-data /var/hg/repos # Allow pushing without SSL echo "[web]" >> /etc/mercurial/hgrc echo "allow_push = *" >> /etc/mercurial/hgrc echo "push_ssl = false" >> /etc/mercurial/hgrc fi # Copy the hg .cgi script into place and make it runnable if [ -a /var/hg/hgweb.cgi ] then echo "Already created /var/hg/hgweb.cgi" else cp /usr/share/doc/mercurial/examples/hgweb.cgi /var/hg/hgweb.cgi chmod a+x /var/hg/hgweb.cgi sed -i.bak "s|/path/to/repo/or/config|/var/hg/hgweb.config|" /var/hg/hgweb.cgi fi if [ -a /var/hg/hgweb.config ] then echo "Already created /var/hg/hgweb.config" else echo "[paths] / = /var/hg/repos/*" > /var/hg/hgweb.config fi # Configure Apache if grep /var/hg/hgweb.cgi /etc/apache2/sites-available/default then echo "Already configured Apache" else sed -i.bak 's|</VirtualHost>|ScriptAlias /hg \"/var/hg/hgweb.cgi\"\ <Location /hg>\ AuthType Basic\ AuthName \"Mercurial repositories\"\ AuthUserFile /var/hg/hgusers\ Require valid-user\ </Location>\ </VirtualHost>|' /etc/apache2/sites-available/default apache2ctl restart fi shouldQuit=false while [ $shouldQuit == false ] do echo "" echo " Quit" echo " Add user" echo " Add repository" read menuoption case $menuoption in 0) shouldQuit=true;; 1) echo -n "Creating new Mercurial user - give them a name:" read hgnewusername if [ -a /var/hg/hgusers ] then htpasswd -m /var/hg/hgusers $hgnewusername else htpasswd -mc /var/hg/hgusers $hgnewusername fi ;; 2) echo "" echo "Existing repositories:" ls /var/hg/repos echo "" echo -n "Enter name for new repository:" read hgrepname echo -n "Enter contact name:" read hgrepcont echo -n "Enter description:" read hgrepdesc cd /var/hg/repos mkdir $hgrepname cd $hgrepname hg init echo "[web] contact = $hgrepcont description = $hgrepdesc" > .hg/hgrc cd .. chown -R www-data:www-data . ;; esac done