Ubuntu 10.04 Server ACPI/APM Support

Advance Configuration and Power Interface (ACPI) or APM ( Advance Power Management ) support for Ubuntu 10.04 was not installed by default after server installation.  I needed this so that during power outage I can just press the power button to automatically shutdown the PC.

sudo aptitude install acpi acpi-support apm

This will install the power-button-power-off feature in you server.

Enable Built-in Intel 82579 Based Ethernet Card in Intel DH61WW Motherboard under Ubuntu 10.04 Server LTS

82579 based Ethernet network cards are only supported in Kernel 2.6.36 and up, thus Ubuntu 10.04 LTS will not have out-of-the-box support for the network card. I needed this to work since I’ll be using this as my server and 11.04 is not LTS, I have no choice. To fix this with the motherboard I have from Intel, here are the steps that I did…

  1. Download the driver source from Intel driver webpage here, or the latest one they have. Double check if the driver supports the version of the network card, the one I have is 82579.
  2. Ready the Ubuntu server, install make gcc g++ and linux headers
    aptitude install make gcc g++ linux-headers-`uname -r`
  3. Un-pack the src driver that you just downloaded, compile and install.
    gunzip [filename].tar.gz
    tar -xvf [filename].tar
    cd [folder_name]/src
    make install
  4. If everything goes well, no error should come out, then enable your new ethernet card.
    modprobe e1000e
  5. You can check your new network card via ifconfig
    Enjoy! 😉

Note: If you update your kernel or linux image via aptitude safe-upgrade or dist-upgrade, you need to remove the e1000e module, re-compile the driver and install the newly compiled driver again.

Blocking DNS requests with Shorewall to prevent OpenDNS Bypass

Here’s a way to block users from using a different DNS address other than your own local DNS server to bypass OpenDNS filtering. I’m currently using Shorewall in an Ubuntu 8.04 LTS server setup as my Firewall, Gateway and DNS, and works nicely. This should also work in 10.04 or other Ubuntu install that has Shorewall firewall. Side effect for the user will be that they wont be able to surf the net until they revert back to the assigned DNS to use.

In your Shorewall Rules file, add this above the other rules.


DNS/ACCEPT  $FW     net
DNS/ACCEPT  net     $FW
DNS/DROP    loc     net
DNS/DROP    net     loc

$FW is your firewall/gateway and in my setup my DNS. You can change $FW to loc:<dns_ip_address> if your DNS is located in another machine other than your gateway.

Have fun raining in on their parade 😉

P.S. You can add filters to allow certain IP or MAC addresses to use DNS outside (i.e. Google DNS ).

Auto Updating OpenDNS with Dynamic IP Address via Ubuntu Server

I have a linux Ubuntu server and a dynamic IP for the DSL connection. The office needs web filtering and getting a static IP will just add cost to the now tight budget. Looking around there is actually a way to update OpenDNS IP address under linux. Below are what is needed to be installed and configured.

  • Any latest Ubuntu server ( I’m using Ubuntu 10.10 Server )
  • ddclient installed (use “aptitude install ddclient”)
  • net connection, I have set up my linux server as a firewall/gateway

After installing ddclient, go to /etc and edit ddclient.conf, below is the format that I used, modify it to suite your configuration.

ssl=yes
use=web, web=whatismyip.org
server=updates.opendns.com
protocol=dyndns2
login=<openDNS_username_here>
password='<openDNS_password_here>'
<openDNS_network_label_here> #this can be found under settings, just the label, nothing else should be added here

Save the new configuration file and restart the client /etc/init.d/ddclient restart
Also make sure that the network that your going to update the IP address has set its Dynamic IP Update option enabled. This can be found under the advance setting of the network.

Special Character Encoding in XML

Ran into a problem returning an XML data with special characters encoded into it through an AJAX call. The problem was that special characters (i.e. &ntilde; -> ñ) throws an error when being returned through XML and is in the process of being parsed by the browser.

The catch?
XML does not support named entities by default, you have to declare it before hand. Only &lt; &gt; &amp; &quot; and &apos; are predefined.

Something like:

1
2
3
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#160;"> ]>
<xsl:stylesheet xmlns="http://www.w3.org/1999/XSL/Transform" version="1.0">

Got this from here…

The fix…
Instead of using named entities in the XML (I think this also affects JSON, I could be wrong since I didn’t test this is JSON) like &ntilde;, use character references to support special character encoding.

Example:
white space = &nbsp; = &#160;
ñ = &ntilde; = &#241;

they are all the same… #160 is referenced/mapped to ” ” and #241 is referenced/mapped to ñ

So when forming your XML before returning it through an AJAX call, form the special characters via character reference.

Hope this helps you out there having this problem.

Java IO Problem in Tomcat

Encountered this problem today while testing an image upload AJAX script in tomcat. Later on I found out that the folder is actually protected Win7 and tomcat couldn’t write the cache or temporary file into the folder.

So anyone having this problem, check the following…

  • What OS are you running? Vista/Win7?
  • What IDE are you using?
  • Was your IDE elevated to admin status?

So, check your OS, I’m using Win7. I was developing this under WinXP a few months back, and now under Win7, the folder is protected since it was under the “Program Files (x86)” folder group. (Argh!)
I closed my IDE, using IDEA IntelliJ 9.0, ran the IDE under “Administrator Level” and the problem disappeared!

So check those out first.

Updates to come…

Been busy around.. but a little heads-up, I’ll be posting and update to installing tomcat and java to Ubuntu 9.10 since I’m “forced” to upgrade now lol… also I’ll be posting a tutorial on how to login-authenticate and query google Analytics using flash AS2, which I think some of you there are also having some problems 😉

Weird turn of events…

I’m now developing in flash actionscript 2…. ok from one language to the other….

Java JNI: Unsatisfied Link Error in Library Path

I’m currently playing around with Java Native Interfaces(JNI) and I must say its been too long since I programmed in Java. Its good to be back! Anyway, lets hop to the main topic…

I was following the tutorial from Sun in creating my first JNI and calling my compiled C++ library, I was stuck in the last part where this error popped out whenever I tried to invoke

java HelloWorld

the error was…

java.lang.UnsatisfiedLinkError: no HelloWorld in java.library.path
          at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1709)
          at java.lang.Runtime.loadLibrary0(Runtime.java:823)
          at java.lang.System.loadLibrary(System.java:1030)
          at HelloWorld.<clinit>(HelloWorld.java:<line number>)
Could not find the main class: HelloWorld. Program will exit.

one way of fixing this is to include the current location of your newly compiled shared library (ex. HelloWorld.so). I’m using Ubuntu linux,so to include the current folder where your “.so” file is located, invoke…

LD_LIBRARY_PATH=`pwd`
export LD_LIBRARY_PATH

or you can also do …
Continue Reading

Overdue Post…

Seems like I got caught up with my work again, ah well que sera sera… I’ll be posting some new stuffs later on, one will be mysql replication through SSH tunneling and the other are tips on extjs javascript framework I have been using for over 2 years now. Should have done this a looooong time ago.

Stay tune 😉