Archive for September, 2010

OpenVPN on Android

Monday, September 13th, 2010

I have really enjoyed having a VPN so that I could remote into work. The other day though, I had to skip out on fishing because we had some computer issues and I didn’t have my laptop. It made me think, wouldn’t it be sweet if I could just use my super duper android phone to VPN into work. This is what I did. First off, an assumtion is made that you have a rooted device.

What you need is to have both busybox, and the tunnel device kernel driver, tun.ko. I am running Cyanogenmod 6 which has busybox already installed. For some reason this version of Cyanogenmod doesn’t have the tun.ko, and ones that I downloaded would not insert into the kernel. So, I installed a ChevyNO1 kernel that comes with the tun.ko driver, and we are to the races on that part. This may sound intimidating, but ROM Manager from the market makes this very easy.

Next thing to just make life easy is to install OpenVPN Installer and OpenVPN settings. They are in the market, go ahead, download it them. I will wait. OpenVPN Installer gives you the option to install all the openvpn stuff. Go ahead and run that. Unfortunately, at the time of this writing, openvpn won’t work still. The problem is a bug in the shipped OpenVPN binary noted here: http://code.google.com/p/android-openvpn-settings/issues/detail?id=26 . There is a link to get the OpenVPN binary that would work.

Once you have that use the OpenVPN Settings to establish connections. It will ask where your key files are and once it knows that and your server, you are up and going. Now I can really get to work wherever I am. Wait a second, maybe I don’t want to do that …

First Experience with Zend Framework

Friday, September 3rd, 2010

I wrote a review of Zend Enterprise PHP Patterns a while back. While I read the book, I had yet to jump into the Zend framework and really make a project that used it, or any of it for that matter. While doing a project for a client I had need of making several forms. Nothing is more tedious to me than making forms. The html tags for labels, the form input, and then the PHP on top of it to give default values. This is OK when making a short form. But I get extra sick of it when doing a form with even ten or more fields. When faced with such a situation this last week I decided to try just a piece of the Zend Framework.

This is possibly my favorite thing about the framework, the ability to use as much or as little as you would like. It gives great flexibility and allows you to include parts into a currently existing project.

To get started, you need to tell your PHP application where zend is, in addition, starting the autoloader at this time really makes life easy. The following code does just that:

  1. set_include_path(get_include_path() . PATH_SEPARATOR . ‘<wherever Zend is>’);
  2. require_once ‘<wherever Zend is>/Autoloader.php’;
  3. $autoloader = Zend_Loader_Autoloader::getInstance();

With these two items in place you can just begin to call Zend Classes and Functions without another thought about it. I put this in my included header.php file, where I have all kinds of includes. Now my functions are available to me wherever I am.

To start your form it is very easy.

  1. $form = new Zend_Form();

That is is, we have started a form. Everything else will use the newly created $form object and go forward from there.

Next, you must add attributes and elements to your form. I found certain parts of this very poorly documented. I wish there was a list of acceptable options, etc for each form addition type but there isn’t. Maybe I should just not complain and write it, but I digress. Adding attributes is rather easy

  1. $form->setAction(‘./action.php’)
  2.      ->setMethod(‘post’)
  3.      ->setAttrib(‘id’, ‘form_id’);

Now adding form fields, a couple options here, both quite easy. First is to just use the $form object and add directly:

  1. $form->addElement(‘text’, ‘text_input’, array(‘value’ => $_REQUEST[‘text_input’], ‘label’ => ‘Text Input:’));

The arguments passed to the addElement method are type, name, array of  options.

The second option is to create a Zend_Form_Element object and add that to the $form object:

  1. $select_input = new Zend_Form_Element_Select(‘select_input’);
  2. $select_input->setLabel(‘Select Input:’)
  3.      ->addMultiOptions(array(
  4.           ‘Option0′ => ‘Option0′,
  5.           ‘Option1′ => ‘Option1′,
  6.           ‘Option2′ => ‘Option2′))
  7.      ->setOptions(array(‘value’ => $_REQUEST[‘select_input’]));
  8. $form->addElement($select_input);

The last bit, actually rendering your form. Some caveats here, Zend Framework components can be used outside of the Zend MVC environment, but you still must define a view in order for the form to actually come up. If you do not, you will get an exception. It isn’t hard though, the following will do it for you:

  1. $form->setView(new Zend_View());
  2. echo $form;

Viola! The form magically appears in front of your eyes. A couple things to remember, anything that can be attribute of an HTML form of input elements can be added to the Zend_Form in the options array. This includes, value, class, specifically defined ID, etc. I will be using Zend_Form much more often. It is so easy to get forms together quickly and easily.

Lazyweb: VNC and RDP client for Android

Friday, September 3rd, 2010

I am looking for a good VNC and RDP client for android. Preferably this app would cost nothing, but if some money is needed no more than $5.00. Has anyone used anything that has been a really good VNC and RDP client? Is there suggestion of two separate ones, one for each protocol?

My experience updating ubuntu servers

Wednesday, September 1st, 2010

I had a contract to update three linux servers at various locations for my client. Each server presented a different set of issues.

Ubuntu has really made these updates easy with the do-release-upgrade command, part of the update-manager-core package. Running the command does pretty well everything for you, and all you have to do is follow a couple of on-screen instructions.

The first server to update was a public webserver. It sits in the datacenter at Xmission, and houses several websites, a database server, and some dns services. This was on ubuntu 8.04, and I was migrating it to 10.04. I logged in from my house via SSH, ran the do-release-upgrade command and we were off to the races. I rebooted afterwards, and waited about 5 minutes. Sure enough I can even SSH back into the box. Then I realize that the upgrade removed my MTA and Database server as part of cleaning up unused packages. Really seems silly to me that is would do that. Thankfully just installing the database was enough, all the databases and users, etc. were still there. Then a fight with apache to actually read the virtualhosts and serve them right. I don’t know what I changed, but it worked.

The second was a backup server onsite. It was at ubuntu 9.04, but with two release upgrades I was running strong on the LTS. Everything else just seemed to work, so that was an easy done.

Last machine was an internal webserver, running some intercompany webapps. It also served as a MTA for the office, allowing copy machines to send mail. It has been the real pain. Upgraded remotely via ssh and it never came back after the reboot. When I physically got to the machine to check it out it was saying something I have never seen before. Grub was complaining that it couldn’t find /dev/mapper/root-device and would drop me to a busybox shell. But I could see /dev/mapper/root-device from the shell. I fought with this for a while. After something like 100 restarts I got the bright idea and just typed ‘exit’ at the busybox shell. Guess what!!! The machine started fine! I have no idea what the machines damage is, but from now on I just type exit when restarting the machine. Thankfully the server doesn’t restart very often, in fact, this update was the first time in 1 1/2 years that I have restarted it. But my trial was not over then. Last large issue was the /etc/network/interfaces file. It kept the old file, but then would not work right. Weirdest symptoms, I could get to the machine fine from 2 of our 5 subnets and the computer could not get to the outside world. I fought with it a while and finally just disabled one of the interfaces and renamed some of the alias’ and away we ran.

I guess the moral of the story is, no server update ever goes smooth. Thankfully I am done for two years.