OwnCloud Update

OC has been updated to version 5. Some of the shared files are not compatible between major versions. If you are missing any shares, just recreate them.

Rest should be ok. If you have any issues, let me know.

Happy New Year 2013!

Good luck in 2013 to everyone. I hope that it will be quieter than 2012 and we get some time to consolidate some of the big trends that started in 2012. My favourite ones are the Raspberry Pi and ownCloud.

I also applied the latest 3.5 update to WordPress. This brought some changes in media management. So in case you miss some pictures, just check for the correct paths in your posts. Generally most stuff should still work.

OwnCloud 4.5 released

This morning version 4.5 of the excellent owncloud package was released. This is excellent competition to all those Apples and Googles who fight to take control of your personal data. Finally there is a decent solution to host all of this yourself.

Calendar, as well as sharing it works flawless without problems. For addressbooks, there seems to be a flaw in Mac OSX, which prevents the addressbook app to see more than one of them. It just picks the first it sees. If someone shares an addressbook with you, it can even cover up your own contacts. This is quite annoying and I recommend not using this feature for now. Hopefully a workaround is found soon.

Rest should work fine. You can install all settings via profiles as usually. Old installations will continue to work as well. In case you experience any problems, just reinstall your configuration profile and let it sync again.

Scan image via SSH

We have an ancient Brother scan+print combination in our apartment. Cheap and reliable. Printing works well over CUPS, also from iPads with Airprint. My only issue was scanning. It works well with SANE, which also works via your network. Only problem is that the packages provided by Mattias Ellert on his website are a bit outdated and don’t always work with the latest Mac OSX. So here is a quick trick to scan on a remote machine without the trouble of moving the file later:

 ssh cyrus@gaia.local "sudo scanimage --resolution 400 --format=tiff" | convert tiff:- -quality 90 -quiet `date "+%Y-%m-%d_%H-%M-%S"`.jpg  

Basically this command pipes the image over SSH and hands it over to the local convert for compression. Neat and elegant. :-)

XBian – Raspberry Pi-based distro for running XBMC

Here just some upaid advertising for a nice armhf-based XBMC distro, I discovered some time ago. If you just want to use your RPI for watching movies and TV-shows, this is definitely for you. It auto-starts XBMC, mounts USB-drives and lets you connect to NFS and SMB as well. They only thing you might want to do is keep your XMBC-user folder on a different drive, so you can easily switch versions and always have a backup.

Link: http://xbian.org/

Raspberry Pi for CCTV using motion

I wrote about doing CCTV with zoneminder before, but realized that this might be overkill for many people. If you use less than 4 cameras, you can use the motion package. It works nicely with the Logitech webcam, I connected to my Raspberry.

The camera worked out of the box except that saturation, brightness, etc was way off. You can configure it with the v4l2-utils package. Once you have verified that the picture is OK by using uvccapture, you should be ready to install motion. For my USB webcam, motion worked out of the box. No settings needed at all. For finetuning, I changed the framerate in /etc/motion/motion.conf to 25. Even at that rate, load stayed at 0.00 with abotu 20% CPU usage. Maybe the GPU is doing the bulk of the image processing work.

By default motion captures .swf and .jpg. For me .swf is enough, so I disabled .jpg output with output_normal off.  If you want to view your cam over a browser, set webcam_localhost off. That way every IP address can access the video stream over a local address like http://10.0.0.19:8081. Further up, you can see my stream. Unfortunately brightness is still a bit too low. I’ll change that later.

Now comes the part where we make our setup really useful. By default motion saves all captures .swf files in the current working directory. When using the init-script, you should save a sensible default output directory. You can change that with the target_dir parameter in /etc/motion/thread1.conf or motion.conf.

So far so good. By now we have motion running and saving all observations to a directory. That’s OK, as long as we can just SFTP into the raspberry and view the footage. If you want your mum to use it, there needs to be something simpler. I used the PHP-script MotionBrowser by Carlos Ladeira as a simple way to view events by day and hour.

For the script to run, you need to install a web server with PHP-support. Apache is overkill here, so I recommend lighttpd or nginx. I won’t go into the details of how to install a webserver, but believe there are many tutorials out there. On top of that you also need mysql to manage the event list. The setup is described on the MotionBrowser site.

Once your webserver is running download motionbrowser.tar and unpack it into /var/www or any other web server root dir. The script worked well, except for serving the .swf-files. When checking download.php, you will notice that the script is actually made to serve .avi-files. We could change that in the motion-settings, but I prefer to stay at .swf because they can be viewed in the browser. Here is what needs to be changed:

In line 53 change avi to swf, so only .swf-files can be downloaded.

1
 if (strtolower(substr(strrchr($filename,"."),1)) != "swf") return;

And also replace the whole header part with just one line to simply view the SWF.

1
 header('Content-Type: application/x-Shockwave-Flash');

That should be it. Enjoy your USD 35 surveillance system.

Update:

If you don’t like refreshing your browser all the time, you can view the live stream in vlc as well.

Discontinued: DaviCal

The outdated and little-used calDAV and cardDAV service at cal.snapdragon.cc:8443 has been discontinued in favor of the more modern ownCloud. Users are encouraged to move their data to the new platform. The OTA-profiles are already adapted to the new service. The service will probably be turned off on 1 Nov 2012 or after ownCloud gets better calendar sharing.

Using Raspberry Pi for CCTV with Zoneminder

Note: zoneminder might be overkill for many people. If you have less than 4 cameras, also read my article about doing CCTV with the motion package.

One of the first uses, for the Raspberry Pi, I thought of was qick-and-dirty CCTV. This could be useful for scenarios, like remote construction sites, senior citizens, holiday homes, etc.

The only gear needed is a Raspberry Pi, a USB webcam and internet access through a router. The webcam could also be a network camera or a network digitizer. That way you have more flexibility with your location. The router could be substituted for a 3G data stick. If you have a spare TV, you could also use it for viewing those cameras. The steps for setup are:

  1. Connect router, USB-camera and power to your Raspberry.
  2. Flash my favourite SD-card image on a card. Steps are describe on the website. Be sure to enable SSH-access. Or connect a TV via HDMI.
  3. Install the zoneminder package and dependencies with apt-get install zoneminder
  4. Make sure zoneminder and its related services are working with service zoneminder restart
  5. Now you should be able to access the zoneminder interface via http://raspberry-pi/zm
  6. If you got that far, you could already add IP network cameras to your interface. There are some really cheap Chinese models to be found on ebay for about 35 EUR. Just make sure they provide you the image over a fixed path like 10.0.0.22/image.jpg. If they only come with an ActiveX web interface, they are pretty much worthless.
  7. To include a USB camera, make sure it is supported by the Linux kernel. You can check connected devices with lsusb and dmesg after plugging it in. If everything is working, your camera should show up with zoneminder as local interface.
  8. If you want to view your camera on your phone, there are a number of apps available for Android and iPhone/iPad. EyeZM worked particularly well and also allows you to view recorded events. The only thing you need is an external domain with some kind of dynamic DNS and port forwarding on your router. You could use DD-WRT to do both jobs. Or install a cron-job on the Raspberry to update its external IP regularly. A flexible and open DNS-service is ClouDNS. Try to avoid DynDNS. They are way to expensive for what they offer and use questionable tactics to buy out competitors.

These are the rough steps to turn your Raspberry Pi into a surveillance machine. Since the machine is not particularly high powered, don’t connect more than 2 or 3 cameras at a time. Motion detection and recording will also put some pressure on it. There are some tricks to install optimized JPEG-libaries. This is something you can try.

If you already have analogue cameras, I recommend the Aviosys IP9100. It costs around 100 EUR and can digitze up to 4 analogue cameras. To pull separate streams, install this alternative firmware. It allows you to access each channel through /usr/yoics[0-3].jpg

I hope this article gave you some inspirations and ideas of what can be done. Be warned that zoneminder is not the easiest beast to configure and install. I will try to come up with a setup script or a pre-built SD-card image at some point.

Access your Raspberry-Pi through any Browser with VNC

The other day I set up Ubuntu in a virtual Machine to do some preparation work before deploying a similar setup in Amazon’s EC2. This basically included programming some Java in Eclipse. When I had to show some stuff to a colleage, I found a quick trick to share a screen remotely on Lifehacker.

This also works well, if you don’t have a screen for your Raspberry or want to access some work files, while on the road. First you need to install the necessary packages

1
sudo apt-get install x11vnc vnc-java

Then just set a password. Username is not required.

1
x11vnc -storepasswd

Now start VNC with

1
x11vnc -forever -usepw -httpdir /usr/share/vnc-java/ -httpport 5800

Now you can try accessing your Raspberry Pi on the local network on http://raspberry-pi:5800. If you want outside access, you could either forward the necessary ports or maybe use IPv6, if already supported from your provider.

The port for plain vanilla VNC is 5400 and works with the same password. For Mac OSX, Chicken of the VNC is a good client. For extra security, you should add SSL to the VNC-connection.

Use Raspberry Pi to Print From Your iPad or iPhone

Yesterday, I described how you can use your Raspberry Pi to download and access torrents. Today my parents asked me to help them set up printing via their iPads. They have a rather old HP Deskjet 5940 printer with a simple USB interface.

First you need to install CUPS (common unix printing system) for printer access. In my case the required printer drivers were installed automatically (hplip). If you are using a different printer you might have to check which packages you need.

After cups is installed (took about 20 min here), enable remote access to it by editing the file /etc/cups/cupsd.conf in 3 places. Add those lines in the relevant places:

1
2
3
4
5
Listen *:631
Order allow,deny
Allow 10.0.0.*
Order allow,deny
Allow 10.0.0.*

After editing the file and restarting cups with service cups restart you can login to your print server on http://raspberry-pi.local:631. Simply click Administration > Add Printer and follow the steps. If the correct driver package is installed, and the printer is turned on, it should show up on the top of the list.

If your printer installed correctly, it show up in your list of nearby printers, as well as on your iPad and iPhone. It’s not necessary to produce a special avahi-script any more, as with older iOS versions.