Babylon Candle

Thursday, June 25, 2009

VPNC with Firestarter

I had been using vpnc to connect to work for a while now. I was using Ubuntu 8.0.4 and recently upgraded to 8.10. Suddenly my vpnc would not work. I couldn't ping any of the target computers without getting this error:
sendmsg: Operation not permitted
After googling around I found the answer here and here.

Basically what you need to do is:

1. Make the /etc/firestarter/user-pre file editable with chmod 600 or equivalent.
2. Edit the user-pre file as sudo and add the following replacing xxx.xxx.xx.xxx with the ip of your gateway:
iptables -A INPUT -j ACCEPT -s xxx.xxx.xx.xxx -p esp
iptables -A INPUT -j ACCEPT -s xxx.xxx.xx.xxx -p udp -m multiport --sports isakmp,10000
iptables -A INPUT -j ACCEPT -i tun+
iptables -A OUTPUT -j ACCEPT -d xxx.xxx.xx.xxx -p esp
iptables -A OUTPUT -j ACCEPT -d xxx.xxx.xx.xxx -p udp -m multiport --dports isakmp,10000
iptables -A OUTPUT -j ACCEPT -o tun+

3. Save and exit
4. Restart firestarter with sudo ./etc/init.d/firestarter restart.

That should make it all work again.

Friday, June 12, 2009

Pondskum Lives!

After recently having moved to Bigpond (no thanks to IINET not getting their sh*t together) I wanted to install a linux widget that displayed my current Internet usage. It's easy enough to log into Bigpond but it's cumbersome and involves multiple clicks when all you want to know is your usage.

With Pondskum, I've created a small opensource Java API that logs into your Bigpond account and screen-scrapes (yukk!) data and gives it back to you in a bean. If only Bigpond had a webservice that provided usage information!

I've created 2 guis from the API. One command-line which gives you basic usage information like totals etc and a Swing version that gives you a day-by-day usage table for the current billing month.























This will work until the Bigpond site is redesigned. Have a look if you need an easy way to find out your Internet usage data.

Wednesday, April 29, 2009

Deploying Maven Artifacts to Googlecode

Recently I need to deploy a snapshot of one of my opensource projects, into a Maven repository so it could be used by another project. Having a quick look around it seemed that I needed to setup a Maven repository such as Archiva or deploy to a site such as java.net. Neither prospect appealed to me very much.

I had a look at Tom's instinct project and noticed that he was using googlecode to host his artifacts. Now that's more like it! I came across this article that Tom had written on how to export artifacts from Ant into subversion. I didn't fancy using Ant as I wanted to go a purely maven route.

Subsequently I came across this excellent blurb on how to deploy artifacts to a WebDAv server. The author goes on to say that "The trick to this one is to realize that when you share a Subversion repository over HTTP(S), it is actually implemented as a superset of WebDAV". Who knew? That basically means you can use your subversion repository on googlecode as a WebDAv repository.

Cool. I implemented his proposed solution and it all worked with minimal fussing around.

So here are the steps I used to get this working:

1. Update your project pom.xml with the following:


<distributionManagement>
<repository>
<id>your-reposiotory-id</id>
<name>your-reposiotory-name</name>
<url>dav:https://your-googlecode-project/svn/maven/repository</url>
</repository>
<snapshotRepository>
<id>your-snapshot-repository-id</id>
<url>dav:https://your-googlecode-project/svn/maven/repository-snapshot</url>
<uniqueVersion>false</uniqueVersion>
</snapshotRepository>
</distributionManagement>

<build>
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-webdav</artifactId>
<version>1.0-beta-2</version>
</extension>
</extensions>

2. Update your settings.xml with the following:

<servers>
<server>
<id>your-repository-id</id>
<username>your-googlecode-username</username>
<password>your-googlecode-password</password>
<filePermissions>775</filePermissions>
<directoryPermissions>775</directoryPermissions>
</server>
</servers>
</settings>


The repository id from the pom and the server id from the settings.xml link up a repository with it's server properties. The wagon extension in the pom is needed to do the actual upload.

Now to upload your artifact to your maven repository do a:


mvn clean install deploy:deploy


That's about it if it all goes well. If you get an 401 http error or the like check the file and directory permissions under the server tag in your settings.xml.

For a client to access your freshly created maven repository and artifacts, they need to add the following to an active profile in their settings.xml file:



<profiles>
<profile>
<id>active-profile-id</id>
<repositories>
<repository>
<id>snapshot-repository-id</id>
<url>http://your-googlecode-project/svn/maven/repository-snapshot</url>
</repository>
<repository>
<id>release-repository-id</id>
<url>http://your-googlecode-project/svn/maven/repository</url>
</repository>
</repositories>
</profile>
</profiles>


That should all work and now you can use your googlecode subversion as a maven repository! :)

Tuesday, April 28, 2009

No SSH - No No Machine

I've been using No Machine to remote into machines for quite a while now and all I can say is that I'll never go back to VNC.

I recently completely reinstalled my fileserver with Ubuntu 8.10 and installed the no machine server in the recommended way. I fired up the client and got a "connection refused on port 22". What thaa?

It had been so long since I did a fresh installation of Ubuntu that I'd forgotten that Ubuntu ships with a SSH client but not the server. I found some useful info here. To get your system upto speed all you need to do is:

sudo apt-get install openssh-server openssh-client

You can test it with:

ssh your_user@localhost

Now your system can frolic in its No Machine goodness! :)

Wednesday, January 7, 2009

Syntax Highlighting Blogger Code

I finally decided to get some decent syntax highlighting going on blog posts. I hunted around and decided to use the rather cool SyntaxHighlighter. I did run into a few problems though. I've document the steps I've used to get it working, below:

1. Download the latest version of SyntaxHighlighter
2. Unrar the contents into a temporary directory.
3. Host the exploded files on a web server somwhere or in subversion. (which has its own challenges. See below)
4. Edit your blogger layout (Layout -> Edit HTML)
5. Add the following lines just above the end </html> tag, changing http://pinthura.googlecode.com/svn/blogs to match your own path:




The above adds support for the following:

1. C#
2. Java
3. XML
4. CSS
5. Javascript
6. SQL

To add additional language support add the appropriate brush from the http://your_path_/dp.SyntaxHighlighter/Scripts/ directory.

6. Add the following just before the </body> tag:




7. To use highlight code use:

<pre name="code" class="java" >
//your java code here
</pre>

or

<textarea name="code" class="java" >
//your java code here
</textarea>

If you are using a language other than java then check its alias here.


Gotha's with SVN and CSS and HTML files

One problem that had me stumped was that the CSS files could not be read from SVN although they were actually in SVN. The problem stems from using SVN as a HTML source directly and having the correct MIME types. CSS and HTML files by default are returned from http-accessed SVN as "text/plain" which is incorrect. For CSS files we need text/css and for html we need text/html. To achieve this do the following:

Update your ~/.subversion/config file:
1. Uncomment the line enable-auto-props = yes
2. Add the following lines:
*.html = svn:mime-type=text/html
*.css = svn:mime-type=text/css

Now if you import your files into SVN it will get returned with the correct mime types when access via the web.

References

1. SyntaxHighlighter
2. Blog without an Important Name