Running Apache Archiva on a Synology NAS

If you’re developing in Java and also using Maven you should be using a repository manager. You probably have one at work. But do have one for your hobby projects? As you probably know; proxying Maven repositories can be quite beneficial. It speeds up builds, as all dependencies only have to be downloaded from the remote repository once. And you will also have a nice place to store your own artifacts. Not everyone have a stock home server that can run such a repository manager, including myself. However I do have a Synology 1513+ NAS. This post shows how you can run Apache Archiva on this device and it’s sibilings in the 1×13+ series.

There are basically two ways of running Archiva; It can be a standalone application, or it can be a executing in a servlet container such as Apache Tomcat. The latter already comes in a handy package for Synology. In either case Java must be installed.

Using Tomcat

I started out by installing the Apache Tomcat package and continued by installing the Archiva WAR file into Tomcat. When I attempted to start Archiva I was rewarded with a wide range of error messages. A new one every time I tried something. I’m no Tomcat guru so I gave up and decided to run the standalone version of Archiva.

Standalone

This method requires that a wrapper application is built for the CPU that the the 1513+ has (Intel Atom D2700).  I suspected that one of the ones shipping with Archiva would work, but decided to cross compile the wrapper using spksrc. With a bit of tweaking the standard distribution actually worked. However it would be a lot better if Archiva could be distributed as a Synology DSM Package (*.spk). This way I could just install the file using the DSM package manager and no tweaking would be required.

So I ended up with a bash script that downloads the Archiva distribution from Apache, tweaks it some and packages it for the Synology NAS. The source code is at GitHub and also the package for download, Archiva-x64-2.0.1-47-bin.spk. This can easily be manually installed using the package manager. Feel free to try it out. It works nicely on my host, but there may be some bugs.

After installing Archiva you must tell your local Maven to use the new proxy. Simply add the following section to ~/.m2/settings.xml. Remember to replace 192.168.1.10 with the name or IP-address of your Synology DS.

You should probably set up the firewall so that one cannot access the server from the outside of your LAN. There are a lot of prying bots out there.

Happy coding!

Scanning woes revisited: A Raspberry Pi scanning machine

I‘ve decided to go paperless (as much as I can anyway). Nearly 20 years worth of various documents must be scanned – then saved to a safe place and the unimportant papers shredded. This pile of documents is pretty tall and I don’t really want to feed the scanner for days, so some ingenuity is required. As any decent software developer I hate doing the same thing over and over again so here was a chance to let the geek in me take over.

One of my old scanners, still waiting to be recycled, actually does have a document feeder. Even though I still would have to feed it, using it could make the job bearable. Or maybe not. The scanning software is not very good. So from the computer I would have to manually operate the program, handle each document and place the file in the destination folder.

Four years ago I wrote a bash script to automate scanning to PDF. It would handle a multi page document, which is nice. But the number of pages in each document had to be typed in. In this case most documents would have one page and some would have multiple. So this script would have to be elaborated upon. The basic idea was to do something like this:

  • Keep on scanning while there are sheets in the ADF.
  • One sheet of paper equals one page. Sheets are not turned.
  • Somehow detect that pages belong in the same document.
  • Convert each document to PDF.

The pixma_scan application that I used the previous time would have to be amended in order to be able to detect whether or not there are sheets in the ADF without actually scanning. So I did a minor tweak to the program allowing it to be used in this way. The code is available on GitHub. I also had to change the Bash script a bit to take advantage of this feature.

Raspberry Pi to the rescue

The Automatic Document Feeder (ADF) of the Pixma MP780 does not hold a lot of paper but it would still take quite some time to scan and convert a full ADF. I also don’t want to keep my laptop busy doing this work so I decided to utilize a Raspberry Pi. It runs Linux, so the scanning application would probably work. The same goes for the utilities the script calls for image manipulation. I had to change this script a bit and the initial test showed that this could work.

Detecting multi-page documents

Another good thing about using the Rapberry Pi is that I could make use of the camera module to detect whether or not a page should be in the same document as the current. I figured it would be possible to some degree of accuracy to analyze a portion of the image and detect whether or not it contains a marker. The images below show two documents with the marker placed in the bottom right corner of the sheet and one without.

tagno-tag

Using the convert utility of Imagemagick I was able to detect whether or not the image was mostly black or white. If it was mostly black the document belongs to the current document and should be appended. The problem that blocked progress was that the ADF could not be trusted to place the sheet of paper in the same position every time. I could probaly get it working if I put black separator sheets in between documents. However I did not continue down this path; as I it would take some time to tune and I am still able to merge PDF files after they have been scanned if need be.

Conclusion

This set-up has proved to be quite useful. It has so far scanned 68 documents in about one hour and half, which would take far longer to do manually. I still have to sort all the document files and place them where they belong. But at least I have a digital copy.

Now I’ll drop a stack at the ADF and get some Battlefield 4 quality time 🙂

Scanning woes dispelled part 2

A few months ago I wrote a post about using a Pixma scanner on Linux to create PDF documents from hard copies. The script has been greatly enhanced and now has a few more features:

  • Select scanner resolution
  • Select page size
  • Option to not pause between pages
  • Option to send PDF as e-mail

The code is released under the Eclipse Public License version 1.0 which means that you can pretty much do what you want with it.

Scanning woes dispelled

Once again I found myself in a situation where I had to print a document, sign it, scan it and return it as PDF. Being a Linux user and owning a scanner/printer/fax that is largely unsupported (Canon Pixma MP780), I’ve usually ended up using the nifty scan to PDF scanner at work. However the scanner feature of the Pixma is to some extent supported using pixma_scan. (The printer works using TurboPrint). So I figured it should be possible to somehow merge the PNM files the scanner program produces into a multi-page document and convert this to PDF.

Google revealed that quite a few people have asked similar questions but no answers provided a complete solution. So I set about to write a bash script that would save me the hassle next time:

The script will use the automatic document feeder, does not care about document size and is quite simple. But it does the job. Most of the tools here (except pixma_scan) should be readily available in your favourite distro.