Thursday, February 26, 2009

[VPN] How to install Cisco VPN client on Ubuntu

Here is a quick guide on how I set up Cisco VPN client.
  1. Install the "patch" tool if you haven't done already, eg. run "sudo apt-get install patch".
  2. Download the client: to whatever location.
  3. run "tar zxvf vpnclient-linux-x86_64-"
  4. Go to the new dir, eg. "cd vpnclient"
  5. Download the patch that matches your kernel into the directory where your vpn client was extracted. In my case:
  6. Run "patch < vpnclient-linux-2.6.24-final.diff" in the directory where you extracted the vpnclient.
  7. Install the vpnclient by running "sudo ./vpn_install" and follow the instructions.
  8. Start the vpn client: "sudo /etc/init.d/vpnclient_init start"
After installation you can add the VPN profiles you need (pcf files) to the cisco profile directory "/etc/opt/cisco-vpnclient/Profiles/".

Once everything has been set up, use "sudo vpnclient connect <your-vpn-profile>" to connect to the VPN.

That's it!


Tuesday, January 6, 2009

[CVS] How to overwrite all files in HEAD/TRUNK with all files from a BRANCH.

If you are using CVS and have a branch that contains whatever code is in production, and you use HEAD/TRUNK for future development, you can sometimes end up in situations where you really want to overwrite whatever is in HEAD/TRUNK with the latest production version from your BRANCH.

In this and many other cases the following might come in hand...

The bottom line is that you need to execute the following four cvs commands:
Reset sticky tag:
   cvs up -A <Filename>
Update from branch:
   cvs update -r<YourBranchName> -p <Filename> > <Filename>
Add uncommitted files:
   cvs add <UnCommmittedFilenames>
Commit changes:
   cvs commit

In case that wasn't enough for you, here's a little more info that I hope will be understandable... Otherwise, just ask!

- Run UNIX bash shell... :)
- filenames and pathnames can contain spaces (as the bash "for" will split the filename into separate files).
- Two directories exist, one with the development HEAD/TRUNK version called "/home/me/myproject_head" and one with the production BRANCH called "/home/me/myproject_branch".
- No new directories have been added/removed. If you have added or removed any directories you need to modify the bash commands below with something like "mkdir -p $i" (also remove the filename from $i) for creating the directories that doesn't exist.

Start out by removing all the files you have in your HEAD/TRUNK directory
for i in `find /home/me/myproject_head -type f \
   | grep -v CVS`; do rm $i;\

In the above case, I've added a grep -v for "CVS" as all files/directories containing this name should be excluded from the deletion, since we need these files if we later on want to commit (and we do!).

Now copy all files that you want to replace from the BRANCH directory to the HEAD directory.
Start out by running a "cd /home/me/myproject_branch".
for i in `find . -type f \ 
   | grep -v CVS | grep -v "org.eclipse" \
   | cut -b 3-`; do \
   cp /home/me/myproject_branch/$i `echo "/home/me/myproject_head/$i"`; \

In this case i have chosen not to copy the CVS directories (a MUST), however I've also chosen to exclude the org.eclipse from the copy, as I have directories that are eclipse specific that I don't want to copy. You can add more " | grep -v partialname" if you wish.

So, now we can work on the new files with the old cvs structure.

First we need to make sure no sticky tags exist:
for i in `find /home/me/myproject_head/ -type f \
   | grep -v CVS | grep -v "org.eclipse"`; do \
   cvs up -A $i; \

Then we replace the files in HEAD/TRUNK with the ones from the BRANCH in cvs:
for i in `find /home/me/myproject_head/ -type f \
   | grep -v CVS | grep -v "org.eclipse"`; do \
   cvs update -rMY_PROJECT_BRANCH_XX -p $i > $i; \

This states that we want to take all the files in our local HEAD/TRUNK version and overwrite them with the versions that exist in the "MY_PROJECT_BRANCH_XX" branch in cvs.

Finally, before we call commit we need to add all the files that exists in the BRANCH but haven't yet been added to HEAD/TRUNK. This requires that you execute "cd /home/me/myproject_head/"
for i in `cvs -nq up | grep "? " | cut -d " " -f2 `; do\
   cvs add $i; \

Now we are ready to commit:

That's it... You should now have a working HEAD containing the same as the stuff in your BRANCH!

The example above can probably be simplified, however this is how I did... Feel free to comment if you have a more simple solution!


Friday, November 21, 2008

[Spring 2.5] context:component-scan does not with @autowired in JUnit test.

A problem exists in Spring 2.5.1 (Maybe also later versions up until 2.5.4?) that cause context:component-scan not to detect the classes you wish to inject in your test classes. Instead you have to add a bean tag defining the bean that you wish to inject in your JUnit test case.


<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns=""
 <context:component-scan base-package="com.maaloe.spring" />

package com.maaloe.spring;

import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;

import dk.telia.cas.command.CommandException;
import dk.telia.cas.dataobject.CPRInfo;
import dk.telia.cas2.test.AbstractSpringTest;

public class MyServiceTest {

    private MyTestService myTestService;

    public void test() {
        System.out.println("Test service class: " + myTestService.myToString());

Service interface:
package com.maaloe.spring;

public interface MyTestService {
    String myToString();

Service Implementation:
package com.maaloe.spring;

import org.springframework.stereotype.Component;

public class MyTestServiceImpl implements MyTestService {
    public String myToString() {
        return "Ping...";

The above does not work until you add:

<bean id="myTestService" class="com.maaloe.spring.MyTestServiceImpl"/>

to your applicationContext.xml file if you are running Spring 2.5.1.

Anyways... Simply fix it by upgrading Spring to 2.5.4.