Friday, 18 December 2009

Virtually JODConverter II

Continued from Part One

Customization


All the hard work has been done by good people in the open source community, so all we do is plug some bits together. Simple!


The bits:


1) JODCoverter as Web app.

2) OpenOffice3 as Debian packages. (We *could* use apt-get but Turnkey is based on Ubuntu 8.04LTS and as far as I can tell doesn't include OO3).

3) An OpenOffice statup script. (there are others out there too, or make your own using /etc/init.d/skeleton).


Having downloaded these files, you need to get them to JOD1. You could attach JOD1 to the world (via NAT on NIC3 or something) and download them directly, but I preferred to keep JOD1 as clean as possible - either that or I like making work for myself - and so I downloaded the files onto MON1 and SCP'd them over to JOD1.


With the bits to hand, the steps are (all on JOD1 & as root):


1) Install the JODConverter WAR in JOD1's webapps directory:

- Unpack JODConverter and find the ".war" file. If you want, rename it to something else - this will be the path in the URL to JODConverter so I kept it simple and called it jodconv2.war.

- Move jodconv2.war to /var/lib/tomcat5.5/webapps/
(You could also "deploy" the WAR file via the Tomcat Web Admin interface).

Now, by default Turnkey runs Tomcat (wisely) with a SecurityManager running. This limits the things servlets can do. If you restart Tomcat now (/etc/init.d/tomcat5.5 restart) and visit /jodconv2/ you'll probably find it isn't running. This puzzled me for a while, but turns out the SecurityManager is to blame.
I tried to grant several (individual) permissions to JODConverter but to no avail so in the end gave it blanket rights by adding:

grant codeBase "file:/var/lib/tomcat5.5/webapps/jodconv2/WEB-INF/-"
{

permission java.security.AllPermission;
};


to the file:


/etc/tomcat5.5/policy.d/04webapps.policy


Restart Tomcat and with a bit of luck you'll get the jodconv2 page - a clean form that suggests you upload a document.

Try it and it fails! Why? Because you need to do step 2!


2) Install OpenOffice 3
- Unpack the OpenOffice tar.gz. Inside there is a directory /DEBS/. I'm sure they're not all needed, but rather than work out which ones to keep and which not, I installed them all (might want to revisit that one day). Install the contents of DEBS
-
cd [OO_DIR]/DEBS/
- ls *.deb | xargs dpkg -i

3) Install the init.d script - there are instructions at the link above, but in short:
- Cut and paste the script into a new file: /etc/init.d/soffice
- Edit the script to point to the right place for OO:

OOo_HOME=/usr/bin

to


OOo_HOME=/opt/openoffice.org3/program/


And, in theory, you're done!


Trying it out!
Shutdown and restart JOD1 and, using MON1 connect to:


http://yourIPofJOD1/jodconv2/


Upload a sample document and hopefully you'll get a nice fancy PDF back.

If you don't, I suspect it is because I missed some vital step along the way! Sorry about that!


Feel free to comment or email if you need a hand! :-)


Packaging the appliance
So we're done right?
Well, mostly. But what if we now want to deploy this appliance? Don't we need it neatly wrapped up and ready to roll?

Yep. I guess we do!

Since we didn't do anything "static" to JOD1 (set the IP for example) it is fairly simple to export it in OVF and, it can then be imported into any virtualization system and run just fine assuming it is connected to a real or virtual network with a DHCP server.

You may also want to create an ISO of JOD1 so it can be deployed by simple installation. This is made pretty easy with TKLPatch - a set of scripts that automate the process of creating an ISO from a OS patch.

The patch I created looks like this:

jodconv2/debs/*openoffice*.deb - ie. all the OpenOffice debs
jodconv2/overlay/
contains the following:


|-- overlay
| |-- etc
| | |-- init.d
| | | `-- soffice
| | `-- tomcat5.5
| | `-- policy.d
| | `-- 04webapps.policy
| `-- var
| `-- lib
| `-- tomcat5.5
| `-- webapps
| `-- jodconv2.war

and finally


jodconv2/conf is a simple one liner:

update-rc.d soffice defaults


Armed with those details and the TKLPatch guide you should have no worries making an ISO of a JODConverter appliance. However, there are a few caveats with TKLPatch.


Firstly, you might notice that Turnkey (and I guess Ubuntu) spread Tomcat all over the OS
- in /etc/ in /var/, etc. If you make a change (say to the policy files) and want to put that in the overlay, be sure you put the path to the *real* file rather than the symbolic path (ie. /etc/tomcat5.5 rather than /var/lib/tomcat5.5/conf).

Secondly, build the patch and create the ISO on a Turnkey Linux machine - I used JOD1 in the end. (This is mentioned in the TKL support forum).

Well, that is one long post! Sorry about that! I hope someone will find it useful one day. I
suspect I will in the New Year when I've forgotten just where this jodconv2 VM came from! :-)

1 comment:

Anonymous said...
This comment has been removed by a blog administrator.