Archive for category Code

Web-CVS-Tools is now under GNU GPLv3

Web-CVS-Tools is now release under GNU GPLv3. Project migrated to, so now you can participate in development.

Web-CVS-Tools is a bunch of script written in Perl to automate and make easier web development using CVS. You can read about the intended web development team work flow in my earlier article, which can be found here.

To make some changes to source code just run:

git clone git://

Web-CVS-Tools on github –

Have fun!

No Comments

VirtualBox init.d service autostart script

I’ve just installed started using VirtualBox on my Fedora 11 x86_64 and it works just perfectly. I’ve migrated from VMWare when it figured out that it is unable to work with latest kernel version. So I need to start some virtual machines in the background with system startup. I’ve made a lot of googling and found some dirty scripts that were not meeting my criterias. I’ve decided to write my own system startup service.

You need to create file named vbox in /etc/sysconfig/ to list the virtual machine names that you want to start with system. Also when shutting down this service will save state to all running VMs. Here is the script:


# chkconfig: - 91 35
# description: Starts and stops vbox autostart VMs.

# Provides: vbox
# Required-Start: $network $named $vboxdrv
# Required-Stop: $network $named
# Default-Start:
# Default-Stop: 0 1 2 3 4 5 6
# Short-Description: Autostart some Virtual Box VMs
# Description: Autostart some Virtual Box VMs that are mentioned in /etc/sysconfig/vbox file

. /etc/rc.d/init.d/functions


[ -r /etc/sysconfig/vbox ] && . /etc/sysconfig/vbox

prog=$"Virtual Box Machines"

	echo -n $"Starting $prog: "

	for vbox_name in ${VBOX_AUTOSTART}
	    echo -n "${vbox_name} "
	    daemon $MANAGE_CMD startvm "${vbox_name}" -type vrdp >/dev/null 2>&1
	    [ "$RETVAL" -eq 0 ] || break
	if [ -z "$SERVS" ]; then
	    echo -n "no virtual machines configured "
	    if [ "$RETVAL" -eq 0 ]; then
		success $"vbox startup"
		touch /var/lock/subsys/vbox
		failure $"vbox start"
	return "$RETVAL"

	echo -n $"Shutting down $prog: "
	for vbox_name in ${VBOX_AUTOSTART}
	    echo -n "${vbox_name} "
	    runuser root -c "$MANAGE_CMD -q controlvm "${vbox_name}" savestate" >/dev/null 2>&1
	[ "$RETVAL" -eq 0 ] && success $"vbox shutdown" || \
	    failure $"vbox shutdown"
	[ "$RETVAL" -eq 0 ] && rm -f /var/lock/subsys/vbox
	return "$RETVAL"

	for vbox_name in ${VBOX_AUTOSTART}
	    echo -n "${vbox_name} "
	    $MANAGE_CMD showvminfo "${vbox_name}"|grep "^State:\s*.*$"

case "$1" in
	echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload|status}" >&2
	exit 3


And here is configuration file:


# Virtual box machines to autostart
# Example to start 2 machines
#	VBOX_AUTOSTART = "MachineName1 MachineName2"


Thats it. If you have any questions do not hesitate to contact me.

, , , ,


Howto delete all .svn folders from SVN working directory

To delete all .svn folders from SVN working directory for releasing folder from SVN just do this simple steps.
Create new file in /usr/local/bin with name svnrm with following content

find . -name .svn -print0 | xargs -0 rm -rf

Save it. From now on you can execute svnrm command in your working directory and it will delete all .svn folders at once.
Have fun!


No Comments

Bugfix: Howto turn off gpg-agent usage in Enigmail in Thunderbird

There is some bug in Enigmail v0.95.7 for Thunderbird. If you untick the checkbox “Use gpg-agent for passphrases” in Advanced tab of Advanced settings menu, Thunderbird in anyway will try to use gpg-agent if GPG_AGENT_INFO environment variable is set. The reason is some little bug in Enigmail source code. To fix it, first close Thunderbird, then just open .thunderbird folder in your home directory, search for enigmail.js file. It have to be in extensions folder in one of the random name folders. When you have found the enigmail.js file open it with your favorite text editor and find line number 1368. It have to be this:

useAgent= (this.gpgAgentInfo.envStr.length>0 || this.prefBranch.getBoolPref("useGpgAgent"));

Change the || sign to &&. After change this line have to look like this:

useAgent= (this.gpgAgentInfo.envStr.length>0 && this.prefBranch.getBoolPref("useGpgAgent"));

Save file. Now open Thunderbird and enjoy.

, , , , ,


Howto recursively add unversioned files into SVN repository

Because svn add command does not support recursive addition of unversioned files you can use this little script to do it.
Create new file in /usr/local/bin with name svnadd with following content

svn status | perl -ne 's/^\?\s+(\S.+)$/\1/g;chomp;system("svn add \"$_\"");'

Save it. From now on you can execute svnadd command in your working directory.



Efficient usage of CVS in web development

Hello. In this post I am going to introduce how we started using CVS in our work.

First of all I want to tell what our job is. We are developing several big websites with about 20 000 lines of source code. We have 4 dedicated servers with Linux OS. So we need good version control system and ability to make changes to website several times a day. Also it will be good not upload files to server by hand and to have some test place to test unstable code. So I have chosen CVS for this purpose. But the problem is that CVS mostly for application developers who make new releases once a month. So we have to think some scheme of work to deal with CVS in web development.

Here is my solution to this problem. Note that we are working with this scheme for more than month and it seems to fit all our requirements.

So every developer has its own work directory which is located on the development server. Let’s put them in /home. So for example developer Mike has /home/mike and if he developing project which called mysite then it will be located on /home/mike/mysite.

Development server has to have apache and bind configured to allow developers to work and test their work. Every project has to have its own first level domain on developer server. Every user has to have it’s own subdomain on every project. So we have domain http://mysite and Mike can access his copy of mysite at http://mike.mysite . Also we need special domain for testing joined stable version of the site. Let’s call it http://test and we can access current stable version of mysite at http://mysite.test . This files can be located in /home/test .

Our online server has to have 2 CVS copies of the site and one clean copy (without CVS folders) which will serve online site. Let’s put CVS copies in /home/mysite_test and /home/mysite_dev. Online site will be in /home/mysite. If online site’s address is then we have to also have and .

Start of a project

Project manager creates new CVS repository and new module. Let’s call it mysite. Then he tags whole project with tag which called mysite-stable-current.

cvs -q rtag -F -r HEAD mysite-stable-current mysite

Start making new job on project

When developper with name is Mike want to start making new job on the project he creates a new branch with name mysite-mike-job1 from tag mysite-current-stable and starts to work on it.

cvs -q rtag -B -b -F -r mysite-stable-current mysite-mike-job1 mysite

While developing

While developing developer may want to test his work on online server, but without joining it to main branch. In that case he have to commit his current files and execute following command from server in /home/mysite_dev.

cvs -q update -d -r mysite-mike-job1

Then he can test his unstable code on

When job is finished

When developer finishes and tested his job he needs commit all his files. After that project manager have to join the changes of the developer to the main branch. So he executes following commands:

mkdir /tmp/jkh23bhlh234
cd /tmp/jkh23bhlh234
cvs -q checkout -r mysite-mike-job1 mysite
cd mysite
cvs -q update -d -j mysite-stable-current
cvs -q commit -m "Updated with latest stable"
cd /home/manager/mysite
cvs -q update -d -j mysite-mike-job1
cvs -q commit -m "joined mysite-mike-job1"

Then we have to tag this branch as merged

cvs -q rtag -F -r mysite-mike-job1 mysite-mike-job1-merged mysite

To have history of stable versions we have to make additional tag in format mysite-stable-YEAR-MONTH-DAY_HOUR-MINUTE-SECOND

cvs -q rtag -r HEAD mysite-stable-108-7-1_6-40-21 mysite

Then we tag our joined version as mysite-stable-current

cvs -q rtag -F -r HEAD mysite-stable-current mysite

Uploading to online server

To upload last stable version to server we need to execute following command in online server’s /home/mysite_test directory

cvs -q update -d -r mysite-stable-current

Then we can make final test of the site on before putting it online. When we finished testing and code is ready to become online we just need to execute following command to copy site from test to online:

/bin/cp -aT /home/mysite_test /home/mysite
find /home/mysite -name CVS -prune -exec rm -rf {} \\;
find /home/mysite -name .cvsignore -prune -exec rm -rf {} \\;

That’s all.

I have wrote bunch of scripts in Perl to automate the process I have recently described. This project is called Web-CVS-Tools. You just need suexec to execute these scripts with privileges of the right user according to your system configuration.

You can download latest version of Web-CVS-Tools from here

Let me explain the purpose of each file in the Web-CVS-Tools. Let’s start from dev_server directory – Global configuration for developers work script. There is defined list of the project and list of the developers. – Main script for developers. It must NOT be called directly, it must be included by the dev_username/ scripts.
dev_username/ – Configuration for each developer.
dev_username/ – Script that developer should call to get his work interface.
manager/ – Script for project manager to merge developer’s work to main branch.

Now let’s look on online_server directory – Configuration for online server. There is array of sites where you must specify the directories of the dev, test main sites. Also there is array of developers and of course address of the CVSROOT. – Main script for uploading last stable version. Must be called directly.

That’s all.

If you have any questions, please do not hesitate to write me :)

For learning CVS I will advice to buy this book: [amazon-product]0596527039[/amazon-product]


Beryl => Compiz Fusion

Few days ago I was trying to get Compiz Fusion work on my Fedora 8. Compiz Fusion is a new name for famous 3D desktop which named Beryl. Now two composite desktop managers have merged and now this union is called Compiz Fusion. After downloading their repository for yum I have installed everything like they say in forum. Everything is fine, cool and everything like that, BUT! When switching to another viewport of the cube, items in taskbar remains the same. For example I open Konqueror on Cube side 1 and open Firefox on Cube side 2. On Cube side 1 I see both firefox and konqueror. It is very uncomfortable! I start googling and find the alternative for KDE’s default taskbar. It called taskbar-compiz. After download and compiling it I have got new taskbar which supports viewports!!! It’s GREAT!!! BUT! When compiz-fusion is in autostart and when KDE loads, viewports doesn’t work again!!! I have noticed that if you remove taskbar-compiz then add it again it works. So taskbar-compiz have to load after compiz-fusion. For this reason I wrote a little Perl script which executes compiz fusion, waits some time and then restarts kicker using dcop.
Here is my script:

  exec("dcop kicker kicker restart");

Put link to this script in ~/.kde/Autostart/


1 Comment

pptpconfig bugfix

I have WiFi in my home and I need to connect to provider’s VPN server to gain access to internet. Their VPN is pptp. So after some googling I find the pptpconfig project which brings ability to connect to pptp server in Linux. After installation everything was fine. This program has both cli and gui interfaces. Once I tried to to put pptpconfig in my /etc/rc.d/rc.local file to autostart pptp tunnel at system startup I noticed that it is not changing my default route in kernel routing tables. So every time I had to manualy change default route to have internet. After some investigations I noticed the error.
Here is the output of the program

# pptpconfig somename start

It gives this output:

pptpconfig: pppd process exit status 0 (started)
ip route replace dev eth1  src
pptpconfig: routes added to remote networks
ip route replace default dev
Command line is not complete. Try option "help"

pptpconfig: command failed, exit code 255
pptpconfig: default route changed to use tunnel
pptpconfig: DNS changes made to /etc/resolv.conf
pptpconfig: connected

Notice that there is a problem with invoking iproute command. So everything started, but nothing added to kernel routing table. I am used Fedora 8 at this time, but I think that this problem exists on earlier Fedoras too.
After some debugging of the code, I have fixed this problem. I have sent the patch file to pptpconfig’s developers, but James Cameron, one of the developers of this project, said that they are not planning to release a new version of pptpconfig in the near future, so anyone who have problem similar to mine, they can use CVS version of pptpconfig or just find my patch in the mailing list. Also I noticed that there were some people who used my patch and they said that it worked.
If anyone is experiencing problems like this apply this patch to pptpconfig.php

--- pptpconfig_fixed.php    2008-03-31 02:48:18.000000000 +0500
+++ pptpconfig.php    2008-01-07 21:53:56.000000000 +0400
@@ -1801,9 +1801,9 @@
$command .= 'exit $pppd_exit_code;';

$context['pipe'] = popen($command.' 2>&1', 'r');
+    socket_set_blocking($context['pipe'], FALSE);

if ($use_gui) {
-        socket_set_blocking($context['pipe'], FALSE);
$window->set_data('state', 'starting');
setup_list_set_state($name, 'starting');

, ,

No Comments