Introducing Trackserver WordPress plugin

(Originally published here)

A while ago, I wrote a post titled “Self-hosted live online GPS tracking with Android“, in which I evaluated a few Android apps that can be used for, you guessed it, live online location tracking. The idea is, that you have your phone periodicially send your location to a web service while you’re on the go. The web service stores the location updates and optionally publishes them on a map.

While there are some apps that do this, there aren’t many (free) options for hosting your own server. That’s why I decided to write my own, and do it as a free and open source WordPress plugin, to make it as accessible as possible. Please meet Trackserver.

Trackserver is designed to work with TrackMe and OruxMaps. OsmAnd support is on the roadmap and I’m thinking about adding GpsGate support. All of these apps offer the possibility to periodically post location updates to a web URL that you can specify. Your own WordPress blog with the Trackserver plugin can ‘listen’ on such a URL to receive the updates and store them in a database. The plugin also offers a WordPress shortcode to include maps with your GPS tracks in your posts and pages, using the fantastic Leaflet library. Collecting and publishing your tracks has never been easier, at least not in a self-hosted website!

A short list of Trackserver’s features:

  • Collect location updates using several mobile apps
  • Publish your collected tracks on a map in your posts and pages
  • Upload tracks via an upload form in the WordPress admin backend
  • Upload tracks by sharing a GPX file from your mobile, using a sharing app like Autoshare
  • View, edit, delete and merge your tracks in the WordPress admin backend
  • Live tracking of your location, with automatic updates of the map view in your WordPress post
  • Full-screen map views

Trackserver’s WordPress admin allows you to upload GPX files to add new tracks, view, delete and merge tracks and edit their properties (name, comment, etc.). Please take a look at the plugin page at wordpress.org or the source code repository at Github. Both pages have more information on Trackserver’s features. The current version is 1.0, which has all the basic features described above.

Getting started with Trackserver is quite easy:

  1. Install the plugin in your WordPress site
  2. Install TrackeMe and/or OruxMaps on your Android phone
  3. Configure the app(s) with your WordPress URL, username and password (HowTo with screenshots is included in the plugin)
  4. Start tracking!

Feel free to give it a go, and if you do, let me know what you think!

 

DCC 1.3.154 for Wheezy

DCC (Distributed Checksum Clearinghouse) version 1.3.154, released on December 03, 2013, is now available in wheezy-custom for amd64 only.

Php-zendopcache 7.0.3 for Wheezy

Starting with PHP 5.5.0, an opcode cache and optimizer module called Zend Opcache is bundled with PHP. It is intended to be the first choice in opcode caches, making APC and friends obsolete.

Zend Opcache is not bundled with PHP 5.4, but it is available and works with 5.4 too. You can get it from PECL and build it yourself. If you run Debian Wheezy, which ships with PHP 5.4.4, you can also install Zend Opcache from debian.dev-zero.nl.

Php5-zendopcache-7.0.3-1tzz3 is available (amd64 only) in wheezy-custom.

Docker on Debian Wheezy

Maybe you have already heard of the next revolution in application deployment called Docker. I quote:

Docker is an open-source engine which automates the deployment of applications as highly portable, self-sufficient containers which are independent of hardware, language, framework, packaging system and hosting provider.

On the getting started page, you can see that you need an Ubuntu machine to get it running:

Requirements

  • Ubuntu 12.04 (LTS) (64-bit)
  • or Ubuntu 12.10 (quantal) (64-bit)
  • The 3.8 Linux Kernel

One thing that is missing from this list, is AUFS support in the kernel, which isn’t a sure thing these days in Ubuntu.

However, I was interested in running Docker on a 64-bit Debian Wheezy machine, and this post explains how to do it. It’s not really hard, but you need to install an Ubuntu kernel. At least, I haven’t been able to find a 3.8 kernel for Wheezy just yet.

Your best bet is the 3.8 kernel from Ubuntu 13.04 Raring, backported for Ubuntu 12.04 LTS Precise. If that link is broken, try this one or get the right page from here. I have tried a kernel from Ubuntu’s mainline kernel PPA, but the 3.8 and 3.9 kernels for Raring from there seem to lack AUFS support.

I downloaded the deb named linux-image-3.8.0-23-generic_3.8.0-23.34~precise1_amd64.deb, which installs on Wheezy without problems. Just do:

$ sudo dpkg -i linux-image-3.8.0-23-generic_3.8.0-23.34~precise1_amd64.deb
$ sudo reboot

Now find a Docker package on Launchpad. Get the one that is built for Precise.

First install the dependencies:

$ sudo apt-get install lxc bsdtar

and then Docker. This will not succeed:

$ sudo dpkg -i lxc-docker_0.4.0-1_amd64.deb
Selecting previously unselected package lxc-docker.
(Reading database ... 40929 files and directories currently installed.)
Unpacking lxc-docker (from lxc-docker_0.4.0-1_amd64.deb) ...
Setting up lxc-docker (0.4.0-1) ...
/var/lib/dpkg/info/lxc-docker.postinst: 4: /var/lib/dpkg/info/lxc-docker.postinst: /sbin/start: not found
dpkg: error processing lxc-docker (--install):
 subprocess installed post-installation script returned error exit status 127
Errors were encountered while processing:
 lxc-docker

This is caused by Docker’s Ubuntu package trying to use upstart to start the daemon, which does not work on Debian. Disable that:

sed -i 's~/sbin/start~#/sbin/start~' /var/lib/dpkg/info/lxc-docker.postinst
sed -i 's~/sbin/stop~#/sbin/stop~' /var/lib/dpkg/info/lxc-docker.prerm

If you now have apt-get fix its state, it should work:

$ sudo apt-get -f install
Reading package lists... Done
Building dependency tree
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up lxc-docker (0.4.0-1) ...

That’s it!

Now continue with the examples on Docker’s website. Happy Docker’ing!

Taggert v1.2

If you don’t know what Taggert is, please see this post and the introduction on my personal blog (opens in a new window).

V1.2 was released on 5 November, but I only just now got around to building a package and uploading it to debian.dev-zero.nl. The changelog for v1.2 is:

  • Make application appear more responsive during time-consuming operations
  • Track line width on the map is now configurable
  • Add image markers on the map for tagged images and add an option to hide them
  • Color and size of image markers are configurable
  • Use GObject property bind functionality to automatically save settings
  • Add inline documentation to the code
  • Move general purpose functions outside the main app module
  • Make image markers 50% opaque
  • Many general code improvements and optimizations
  • Let Exiv2 decide on the supported file formats, instead of just reading JPG
  • Implement “select all from this camera” for images
  • Add camera ID column to images list, hidden by default
  • Show the current image directory in the statusbar

Taggert v1.2 is now available (arch-independent binary + source) in wheezy-custom. Please give it a try 🙂

 

Taggert v1.1

Chances are, you have never heard of ‘Taggert’. Taggert is a Python/GTK+ 3 geo-tagging application. An introduction to the application is on my personal blog.

Yesterday, I released version 1.1, with some new features and lots of general improvements and bugfixes. The changelog for v1.1 is:

  • Restructure directory layout and add Python distutils and Debian packaging
  • Add an icon and a .desktop file
  • Disable Google map sources by default
  • Feature: copy/paste coordinates with CTRL-C/CTRL-V
  • Add two mapsources: Mapbox Streets and (just for fun) Stamen Watercolor
  • Handle elevation/altitude in geo-tags
  • Screen redrawing during time-consuming operations, to make it look snappier
  • Marker size is now configurable
  • Bookmarks are now properly sorted by name
  • Add many menu-accelerators (keyboard shortcuts)
  • Make functions from some action buttons available under view menu too

Taggert v1.1 is now available (i386 + source only at the moment) in wheezy-custom.

Gexiv2 0.5.0 with GObject Introspection support

Gexiv2 is a GObject-based wrapper around the Exiv2 library. It makes the basic features of Exiv2 available to GNOME applications.

At the time of writing, the current version in Debian unstable/testing is 0.4.1. On 1 October 2012, upstream version 0.5.0 was released, with support for GObject Introspection and shipped with a Python module, to allow gexiv2 to be used from Python.

This is important, because the existing Python bindings for Exiv2 (pyexiv2) will not (or cannot) be ported to Python 3. Gexiv2 0.5.0 fills this gap.

Debian.dev-zero.nl now hosts Gexiv2 packages with GObject Introspection support, but only for Wheezy. The source package is also available. The binary package named ‘gir1.2-gexiv2-0.4’ is new, and contains all the magic.

To use it, do something like this:

#!/usr/bin/python
from gi.repository import GExiv2
from pprint import pprint

metadata = GExiv2.Metadata('/path/to/image')
pprint (metadata.get_tags())
pprint (metadata.get_gps_info())
# and so on...

In the mean time, I have filed a wishlist bug report with Debian to ask version 0.5.0 to be included in Debian.

Update, 8 January 2013

I didn’t check in a while, but is seems that GExiv2 0.5.0 with GI support entered experimental on November 28th, 2012.

MixRamp and ReplayGain

I have a small mp3 collection, and whenever I throw a party, I use MPD to play songs from it, so I don’t have to care about the music during the party.

MPD has always fulfilled my needs in mp3-playback, except for one detail: a good mix from one song into the next, or at least some sort of ”gapless playback”, that goes beyond the classical definition (the kind that is good for live concerts or classical music), and is a little more intelligent than simple time-based crossfading, because that sounds horrible most of the time.

A while ago, I decided to take a crack at building my own player (mostly as a programming exercise), and I played around with Gstreamer and its Python bindings for a while, using a pluging called ”level” to detect when the volume level of a song drops below a certain threshold near the end, and use that to start playback of the next song at the right time. The results were promising, not to say quite satisfactory, but my initial goal to create a drop-in replacement for MPD, or at least keep protocol compatibility to a large extent, seems a little too far-fetched right now.

Little did I know. Last Saturday, I discovered something called ‘MixRamp’, invented by Tim Phipps, already back in 2009, which has the exact same goal as my MPD rip-off, and implements it in a way similar to mine, only slightly better. Where my implementation was real-time (meaning audio level analysis is done during playback) and only considered the end of a song to set the mix-point, MixRamp considers both the start and the end of a song to create a better mix, and it is tag-based, so the audio analysis has to be done only once. And the best part: MPD has built-in support for MixRamp since version 0.16. The only thing I like better about my own solution is the fact, that in my case, the mixing is left to the audio output channel (I like PulseAudio, but it could be ALSA, or anything that Gstreamer supports), where with MPD + MixRamp, MPD does the mixing itself.

It would seem that the MixRamp approach is easily portable, although MPD seems to be the only player supporting it so far. If you know of any others, please let me know.

 

Adding MixRamp tags

So, what do you need?

  • MPD, version 0.16 or newer (if you’re on Wheezy or newer, just ”apt-get install mpd”)
  • MixRamp, latest version
  • eyeD3 (apt-get install eyed3); used by the mixramp-tag wrapper script that comes with MixRamp
  • mpg123 (apt-get install mpg123); also used by mixramp-tag
  • (optional) a script called ‘ramptag‘, to make tagging even easier
  • (optional) mid3v2 (apt-get install python-mutagen); ramptag uses it to read ID3 tags and find out if a file is already tagged

MixRamp is not in Debian, so you will have to compile it yourself. You need libaudiofile-dev installed to make that work. Normally it would suffice to type ‘make’ in the unpacked archive directory, but on Wheezy (GCC 4.6), some (presumably harmless) compiler warnings turned up, and I had to edit the Makefile and remove -Werror (“treat all warnings as errors”) from CFLAGS.

For the rest of this post, I assume you have mixramp, mixramp-tag and ramptag installed, somewhere in your PATH (p.e. /usr/local/bin). Tagging is now as easy as:

cd /path/to/mp3/collection && ramptag *

The result will be, that the mp3-files will have some TXXX tags, that look something like this:

TXXX=mixramp_end=-31.22 0.26;-15.93 3.96;-14.23 4.06;-7.86 4.16;-2.62 4.26;
TXXX=mixramp_start=1.83 0.00;3.72 0.10;6.06 2.30;
TXXX=mixramp_ref=89.00

The sequences of numbers can be quite a bit longer than this, though.

 

Making MPD use the MixRamp tags

Like I said, MPD has had built-in support for MixRamp tags since version 0.16, so using them is a matter of tuning some MPD settings:

mpc crossfade 1
mpc mixrampdelay 0
mpc mixrampdb -5

It seems necessary to enable crossfading to make MPD use MixRamp. Traditional crossfading will be done as a fallback when MixRamp tags are not available, so I tend to keep the crossfade setting as low as possible. As for mixrampdelay and mixrampdb, you’d have to play a little with those to find the result that you like. The settings above are quite agressive: the next song is started pretty quickly, and the overlap is relatively big. You might want to set mixrampdb to a lower number. It is the threshold in dB, where MPD places the mix-point, so the lower the number, the longer MPD will wait to start the mix.

A note: at some point, I noticed the following in MPD’s logfile:

crossfade: audio_buffer_size too small for computed MixRamp overlap

I ended up with the following setting in /etc/mpd.conf (I left the default commented):

#audio_buffer_size              "2048"
audio_buffer_size               "8192"

 

Adding ReplayGain to the mix

Even though I have been using mp3’s for ages, I have never taken a serious look at ReplayGain. In combination with MixRamp, it seems to be the icing on the cake for a good party-player.

ReplayGain is also tag-based. Adding tags can be done with mp3gain, which is available in Debian (and has been since 2004). So, apt-get install mp3gain.

ReplayGain has two modes of operation: “Track gain” and “Album gain”. For simplicity, we use only “Track gain” here. A few notes on the use of mp3gain:

  • mp3gain writes APE tags by default. Specify -s i to use ID3v2 tags. MPD only looks at the ID3 tags.
  • when you specify multiple input files, mp3gain assumes it’s an album, unless -e is given.

To avoid confusion, I’ll only feed mp3gain one file at a time. That gives me the following command, to be run in a directory that contains mp3 files:

for f in *.mp3; do mp3gain -e -r -k -s i $f; done

You can run mp3gain -h to see what all the options mean.

Happy DJ’ing!!

Zsh ZLE tip

In my home directory, I have several subdirectories that contain my software projects, for example:

/home/me
        /src
             /wp-plugin-x
             /project-y
        /config
               /puppet
               /nagios
               /package-z

Some of these trees can get quite deep, and sometimes, when I’m working in one of the directories deep in the tree, I need to access a file somewhere else in the tree. Now, you can do that via ../../../path/to/file, or ~/src/project/path/to/file, but neither are very efficient. I wanted a way to efficiently refer to the root of the current project.

Finding the root is easy. In my case, $(pwd) | cut -d / -f 1-5 gives me what I need. Now I use some Zsh trickery to efficiently use that in commands. I want ‘~~‘ to expand to this directory. Enter the following code in my .zshrc:

my-expand-tilde() {
  local MATCH
  if [[ $LBUFFER = *~ ]]; then
    p=$(pwd | cut -d / -f 1-5)
    LBUFFER=${LBUFFER%~}
    LBUFFER+="${p}/"
  else
    LBUFFER+=~
  fi
}

zle -N my-expand-tilde
bindkey "~" my-expand-tilde

Every time you press ‘~’, the widget ‘my-expand-tilde’ is run. If this is the second ‘~’ in a row, it will strip of the previous ‘~’ and add the root of the current project to the command I am typing. So effectively, whenever I type ‘~~’, it is immediately substituted by the directory that I need.

Ideas for this code where borrowed from ZSH-LOVERS(1), look in that page for a widget named ‘rationalise-dot‘.

Policykit adventures

After installing Debian on a laptop this week, once again, I ran into the “problem” of not being able to shutdown or reboot the computer, when another user is logged in, for example via SSH. If you’re a Linux user, maybe you have seen it:

System policy prevents restarting the system
when other users are logged in

The cause of this behaviour is something called policykit, and a policy defined in /usr/share/polkit-1/actions/org.freedesktop.consolekit.policy. I found several pages on the web, that suggested to modify this file to change the policy. However, as this file is shipped by a package, and living below /usr/share, it is not intended to be modified by users to override the policies it contains.

The correct way to fix the problem is in something called PolicyKit Local Authority, or pklocalauthority. To enable all users to shutdown or reboot the computer, even when other users are logged in, create a file named /etc/polkit-1/localauthority/50-local.d/usershutdown.pkla (the name must end in .pkla) and put the following in it:

[Allow Shutdown]
Identity=unix-user:*
Action=org.freedesktop.consolekit.system.stop-multiple-users
ResultAny=yes
ResultInactive=yes
ResultActive=yes

[Allow Restart]
Identity=unix-user:*
Action=org.freedesktop.consolekit.system.restart-multiple-users
ResultAny=yes
ResultInactive=yes
ResultActive=yes

You may have to reboot the computer (or at least log out and back in) for the policy override to take effect.