Category Archives: IT - Page 2

Setting up Subversion on Debian

So it’s time to setup Subversion; I’ve been using CVS almost forever for my larger projects, and relying on Time Machine for my smaller projects.  Which don’t get me wrong, works great, but CVS is getting a little dated, and there’s no Time Machine type app that I can find, for my new Windows laptop.

So, subversion.  Sure, I could use GIT, that’s what folks seem to be using these days, but it seems not-quite-suited to what I want it for – which is one person, developing using multiple machines.

So, I’ll be setting it up on my existing source-control VM.  I don’t think I need to bother with Webdav access – just svn+ssh will do nicely for remote access, and plain svn for servers within GS fetching their new releases.


My environment is almost 100% Debian, so first we install the subversion package

vorlon:~# apt-get install subversion<
Setting up libsvn1 (1.6.12dfsg-6) ... 
Setting up subversion (1.6.12dfsg-6) ... 

Then we want to create our new repository.  I’m going to have a repository per project, just to make it easy to hand a repository over to a client, should they ever move development inhouse, or the like.  Lets setup TremSearch

vorlon:~# mkdir /var/lib/subversion/tremsearch 
vorlon:~# svnadmin create /var/lib/subversion/tremsearch

Ok, our repository is created, but we need to add users!

cat >> /var/lib/subversion/tremsearch/conf/passwd << __END__ 
damien = <redacted> 
webserver = <redacted> 

And we need to give them access – edit conf/svnserve.conf:

damien = write 
webserver = read 
anon-access = none 
password-db = passwd 

‘Note the anon-access = none’ – The SVN documentation seems to say that ’read’ is the default for anonymous users!  That seems a little daft to me, but I’ll set it to none, just incase they’re for real!

Oh, Subversion for debian does not have a start script! So we’ll add one..

cat > /etc/init.d/subversion << __END__
# Provides:          svnserve
# Required-Start:    $local_fs $remote_fs $network $syslog
# Required-Stop:     $local_fs $remote_fs $network $syslog
# Default-Start:     
# Default-Stop:      
# X-Interactive:     true
# Short-Description: Start/stop svnserve

svnserve -d -r /var/lib/subversion/
chmod u+x /etc/init.d/subversion
ln -s /etc/init.d/subversion /etc/rc2.d/S99subversion

Note that we’re locking base SVN url’s down to /var/lib/subversion.  We’ll see how this works below.

Start up the server (/etc/init.d/subversion) and we’re done!

Importing your code

Importing your code is fairly easy – change to the directory your code resides in, and import it.. And then, I move the original directory out of the way, and check it out:

damien@:/export/home/projects/tremsearch/www$ svn import -m "initial import" ./ svn://svnserver/tremsearch/www
Committed revision 1.
damien@:/export/home/projects/tremsearch/www$ cd ..
damien@:/export/home/projects/tremsearch$ mv www old-www
damien@:/export/home/projects/tremsearch$ svn checkout svn:// www
Checked out revision 1.

And done!. Now I can check it out on my laptops, and work with it! And the added bonus here, is that I don’t have to worry about SCP’ing changes up to the webserver anymore, and keeping track of changed files – I just jump into the www directory on the webserver, and ‘svn update’ 🙂

XenServer – Creating a local ISO repository

Starting a new job, I’m essentially starting from scratch, as far as development infrastructure goes – The live sites are hosted on a cpanel server with ftp access only – so debugging is basically a moot point – and there have been no development sites for quite a while – it’s a simple case of edit in dreamweaver/eclipse/zend studio/etc and FTP up and ‘see how it goes’ – so it’s either sync up the dev sites from current codebase, or start them from scratch with something a little more industry-standard.  Granted these are much smaller projects than my previous jobs, but they have the potential to still need multiple developers committing source changes, etc, in the somewhat near future.  So the current ftp-the-changes-up-to-the-server just won’t cut it.   My first step is running up a quick XenServer install, and bringing up a few VM’s for Subversion, LAMP, Jira, etc.  yes, they could all run on one, but if there’s one thing I’ve learnt of the years, it’s keep your environments separated.  Especially source control from development!

The environment here isn’t big enough to justify anything like I have in my small hosting business, with a SAN-backed XenServer cluster with HA licensing etc.  So a standalone XS server it is.  15 mins after finding a spare monitor, I had XenServer running.  And that’s about where I went ‘oh, bugger, ISO repository!’ – That’s right, there’s no fileserver in this office at present, so a-googling I went!

As it turned out, it wasn’t too bad at all 🙂  We basically create a small volume in LVM, mounted it, and add it as an ISO Storage Repository.

First up, get the name of the Volume Group

# pvscan
  PV /dev/sda3   VG VG_XenStorage-c0972b3b-ef4a-346f-42d2-8ddae19499da   lvm2 [690.62 GB / 690.61 GB free]
  Total: 1 [690.62 GB] / in use: 1 [690.62 GB] / in no VG: 0 [0   ]

Ok, so in this case, our VG is VG_XenStorage-c0972b3b-ef4a-346f-42d2-8ddae19499da. Now we want to create a Logical Volume.  I made it 40GB – if I was running small SCSI/SAS disks, I’d probably have made it smaller, but this box has a 750gb SATA disk.

[root@xenserver01 ~]# lvcreate -L 40G -n ISO VG_XenStorage-c0972b3b-ef4a-346f-42d2-8ddae19499da
  Logical volume "ISO" created

And of course, format it.  I use ext2 for anything ‘basic’, as I don’t need journalling, and I like my performance, especially in a SAN environment.  Not that that’s an issue here with a local disk, but it’s a good habit to form 😉

[root@xenserver01 ~]# mkfs.ext2 /dev/VG_XenStorage-c0972b3b-ef4a-346f-42d2-8ddae19499da/ISO 
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
5242880 inodes, 10485760 blocks
524288 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=0
320 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks: 
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
4096000, 7962624
Writing inode tables: done                            
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 39 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

Well, that was easy. Let’s make a new directory to mount the LV.

[root@xenserver01 ~]# mkdir /mnt/iso_import

Mount the Storage Repository. Make sure that all Volume Groups are active, mount it, and attach it as a storage repository..

[root@xenserver01 ~]# vgchange -a y
  3 logical volume(s) in volume group "VG_XenStorage-c0972b3b-ef4a-346f-42d2-8ddae19499da" now active
[root@xenserver01 ~]# mount /dev/VG_XenStorage-c0972b3b-ef4a-346f-42d2-8ddae19499da/ISO  /mnt/iso_import/
[root@xenserver01 xen]# xe-mount-iso-sr /mnt/iso_import -o bind

Sweet, and make it come up at boot!

[root@xenserver01 ~]# cat >> /etc/rc.local << __END__
vgchange -a y
mount /dev/VG_XenStorage-c0972b3b-ef4a-346f-42d2-8ddae19499da/ISO  /mnt/iso_import/
xe-mount-iso-sr /mnt/iso_import -o bind

And we’re done!

Oh, and obviously, scp some isos to it! 🙂