How to fix your pump.io site name

A newbie mistake that is quite easy to do on pump.io is to set a name for your instance, then decide to change and… oops, you changed /etc/pump.io.json but it doesn’t change! WTF!?

In my case I was particularly pissed off because there’s a bug on pump.io with certain characters, I had named my instance 1407’s Pumps but apparently pump.io doesn’t like that quote there… displayed instead 1407s Pumps. ANGRRRY!

After digging through all keys in my instance, I found out that mine was service:urn:uuid:b0f6e849-4a8b-4b8a-9f3d-1ee221d62d58 (faked uuid), but there may be a lot of service:urn:uuid: entries (234 when I did this)!

Here’s how you can fix it on your database as well (I’m using redis, you’ll have to adjust to your particular case if using another DB).

echo "keys service:urn:uuid:*" | redis-cli > uuids.txt
cat uuids.txt | while read KEY ; do
    echo "set $KEY '$(echo get $KEY | redis-cli)'" >> uuids-set.txt
done
grep "MISTAKEN TITLE" uuids-set.txt > title-fix.txt

So now you can edit title-fix.txt with your favorite text editor and fix the field displayName to your pleasure, and after saving your change you are now ready to apply it:

redis-cli < title-fix.txt

I doubt restarting is needed, but I did it anyway, you can try. 🙂

Forgot to set email in your pump.io? Fix it!

Pump.io is an awesome distributed/federated social network, but it’s still green software and has many rough edges. One boring one is that when you’re setting up your instance you may run into the pitfall of not setting your email, and then after you posted more than you’d want to loose by resetting it… you can’t enable requireEmail anymore because you’ll be kept out of your own instance.

Sucks, innit? But there’s a fix, all you need to do is add the email field to your user’s data. In my example I’ll be using redis so your millage may vary according to your choice of databank, but the idea is the same, just figure out what your particular case needs to do to implement the same idea.

You can get your user’s data and fix it like this (note, lines broken for blog display):

redis your.ip.addr.ess:6379> get user:RuiSeabra
"{\"nickname\":\"RuiSeabra\",\"updated\":\"2013-08-15T20:42:58Z\",
   \"published\":\"2013-08-15T20:42:58Z\",\"_passwordHash\":\"haha",
   \"profile\":{\"objectType\":\"person\",
   \"id\":\"acct:RuiSeabra@p.1407.org\"}}"

redis your.ip.addr.ess:6379> set user:RuiSeabra
"{\"nickname\":\"RuiSeabra\",\"updated\":\"2013-08-15T20:42:58Z\",
   \"published\":\"2013-08-15T20:42:58Z\",\"_passwordHash\":\"haha",
   \"profile\":{\"objectType\":\"person\",
   \"email\":\"my-rms-email@1407.org\",
   \"id\":\"acct:RuiSeabra@p.1407.org\"}}"

So now it’s fixed and you can re-enable requireEmail in your pump.io.json:

[rms@pump ~]$ sudo grep -i requir /etc/pump.io.json
    "requireEmail": true,

Raising awareness of Pump.io

Hey guys, let’s try to expand pump.io awareness ok?

  • Do make an effort to post to Public (Evan… grrr…. why can’t we have a default “To:”)
  • Plug your public activity url on your web page like I did here (check the “Follow me…” box on the right)! 🙂
  • Link people’s names on your blog posts to their public activity urls

Come on, just do it!

pump.io as systemd service

So what’s wrong with this first very basic attempt to start pump.io as a systemd service?

[Unit]
Description=Pump.io
Requires=redis.service
After=redis.service

[Service]
Type=simple
ExecStart=/opt/pump.io/pump.io/bin/pump
Restart=on-abort

[Install]
WantedBy=multi-user.target

This is what’s wrong….

Sep 05 20:49:38 p.1407.org sudo[17482]: rms : TTY=pts/1 ; PWD=/opt/pump.io/pump.io ; USER=root ; COMMAND=/bin/systemctl start pumpio.service
Sep 05 20:49:38 p.1407.org systemd[1]: Starting Pump.io...
Sep 05 20:49:39 p.1407.org pump[17485]: path.js:360
Sep 05 20:49:39 p.1407.org pump[17485]: throw new TypeError('Arguments to path.join must be strings');
Sep 05 20:49:39 p.1407.org pump[17485]: ^
Sep 05 20:49:39 p.1407.org pump[17485]: TypeError: Arguments to path.join must be strings
Sep 05 20:49:39 p.1407.org pump[17485]: at path.js:360:15
Sep 05 20:49:39 p.1407.org pump[17485]: at Array.filter (native)
Sep 05 20:49:39 p.1407.org pump[17485]: at Object.exports.join (path.js:358:36)
Sep 05 20:49:39 p.1407.org pump[17485]: at getConfig (/opt/pump.io/pump.io/bin/pump:58:23)
Sep 05 20:49:39 p.1407.org pump[17485]: at main (/opt/pump.io/pump.io/bin/pump:40:18)
Sep 05 20:49:39 p.1407.org pump[17485]: at Object.<anonymous> (/opt/pump.io/pump.io/bin/pump:151:1)
Sep 05 20:49:39 p.1407.org pump[17485]: at Module._compile (module.js:456:26)
Sep 05 20:49:39 p.1407.org pump[17485]: at Object.Module._extensions..js (module.js:474:10)
Sep 05 20:49:39 p.1407.org pump[17485]: at Module.load (module.js:356:32)
Sep 05 20:49:39 p.1407.org pump[17485]: at Function.Module._load (module.js:312:12)
Sep 05 20:49:39 p.1407.org systemd[1]: pumpio.service: control process exited, code=exited status=8
Sep 05 20:49:39 p.1407.org systemd[1]: Failed to start Pump.io.
Sep 05 20:49:39 p.1407.org systemd[1]: Unit pumpio.service entered failed state.

An ideas why? Starting from the console with sudo /opt/pump.io/pump.io/bin/pump works fine.

Grrr…

HOWTO: pump.io behind Apache

Pump.io is very interesting, but it used to be very hard to put to work behind a frontend, mostly because of web sockets and being designed to be directly connected.

This means that your nodejs-enabled pump.io consumed an IP:port pair and since pump.io is an https oriented application (can be run in http but you really don’t want that) that means your https port (who has more than one IP either at home or his VPS?) is now BUSY with one single application… sucks and I gave up for some time and wasted my connection’s IP address at the standard https port.

Meanwhile… Good news, everyone!

I recently came up a new Apache module for web sockets: mod_proxy_wstunnel.

Searching for pump.io and wstunnel… it turns out my irrational friend Mark Jaroski also published a note about that! Please note that you may not need to build the module, if you have a recent enough Apache 2.4.x version it may already be there, check your bundled modules!

So here’s my setup: the OpenWRT router forwards port 443 incoming into a frontend KVM guest running Apache httpd which then forwards to some of my sites, one of which is my pump at https://p.1407.org/

The frontend’s web site looks like this:

<VirtualHost *:443>
        ServerName p.1407.org
        CustomLog logs/https-p.1407.org-access_log common
        ErrorLog logs/https-p.1407.org-error_log
        DocumentRoot /var/www/html/default

        SSLEngine On
        SSLCertificateFile conf/ssl.crt/p.1407.org.crt
        SSLCertificateKeyFile conf/ssl.key/p.1407.org.key
        SSLCertificateChainFile conf/ssl.crt/startssl-chain.crt
        SSLCACertificateFile conf/ssl.crt/startssl-chain.crt

        SSLProxyEngine On

        <Location /main/realtime/sockjs>
                ProxyPass wss://192.168.x.y/main/realtime/sockjs
                ProxyPassReverse wss://192.168.x.y/main/realtime/sockjs
        </Location>

        <LocationMatch ".*\.(jpg|png|gif)$">
                CacheEnable disk
        </LocationMatch>

        ProxyPreserveHost On

        ProxyPass               /       https://192.168.x.y/
        ProxyPassReverse        /       https://192.168.x.y/
</VirtualHost>

And at my pump.io KVM guest, 192.168.x.y, I have…

{
    "driver":  "redis",
    "noweb":  false,
    "site":  "1407 Pump",
    "owner":  "Rui Seabra",
    "ownerURL":  "https://blog.1407.org/",
    "port":  443,
    "hostname":  "p.1407.org",
    "nologger":  false,
    "serverUser":  "pumpio",
    "key":  "/etc/pump.io/p.1407.org.key",
    "cert":  "/etc/pump.io/unified-p.1407.org.crt",
    "uploaddir": "/opt/pump.io/uploads",
    "logfile": "/var/log/pump.io/activity.json",
    "debugClient": false,
    "firehose": "ofirehose.com",
    "disableRegistration": true,
    "requireEmail": false,
    "smtpserver": "put.your.own.here",
    "smtpuser": "aLoginAtYourServer",
    "smtppass": "some good password",
    "smtpusetls": true,
    "smtpport": 587,
    "smtpfrom": "pump@1407.org",
    "secret": "some good secret"
}

So there you go…

 

Fixing the FirefoxOS default search provider

WTF? FirefoxOS uses Bing as default search provider?

Yuck, I must fix that. Finally after almost a week I have had some time for me and that’s the first thing I must fix. Thanks to the very helpful comment from Mathieu in this blog post, I wrote a very small shell script that replaces the search provider to your favorite one, defaulting to Google.

It uses sudo for the privileged commands but doesn’t need to completely run as root. Its your choice, run ./fix-ffos-search-provider.sh or sudo ./fix-ffos-search-provider.sh taking as optional arguments (in this order), the Title, the URL and it’s Favicon url. Miss one and the Google default will be used 🙂 eg:

./fix-ffos-search-provider.sh \
  "Duck Duck Go" https://duckduckgo.com/ https://duckduckgo.com/favicon.ico

First, it sets the options, then starts adb-server and fetches the browser application (note that you need the android-tools package in Fedora or the Android SDK):

#!/bin/sh

TITLE=${1:-Google}
URL=${2:-www.google.com/m}
ICO=${3:-https://www.google.com/favicon.ico}

sudo adb start-server

sudo adb pull \
  /system/b2g/webapps/browser.gaiamobile.org/application.zip
sudo chown $USER:$GROUP application.zip

mkdir application
cd application/
unzip ../application.zip

Then, it does the magic with the help of Perl:

perl -pi -e " \
    s|(DEFAULT_SEARCH_PROVIDER_URL: ?)'.*?'|\$1'$URL'|; \
    s|(DEFAULT_SEARCH_PROVIDER_TITLE: ?)'.*?'|\$1'$TITLE'|; \
    s|(DEFAULT_SEARCH_PROVIDER_ICON: ?)'.*?'|\$1'$URL'|; \
    " js/browser.js gaia_build_defer_index.js

Finally, it rebuilds the browser application and pushes it back to the phone and reboots it (it shouldn’t need a reboot, maybe there’s a way to avoid this?):

zip -fr ../application.zip .
cd ..

sudo adb remount
sudo adb push application.zip \
   /system/b2g/webapps/browser.gaiamobile.org/application.zip
sudo adb reboot

So, here it is, finally fixed 🙂 Well, temporarily (it will be better fixed following the results of https://github.com/mozilla-b2g/gaia/pull/9454 and https://github.com/gasolin/gaia/commit/47072a825d9e7c2859f4f8de4fb200cc7450e10b or something similar) at least.

Screenshot of FirefoxOS browser googling for 'test'
Googling for ‘test’


CC0
To the extent possible under law, Rui Miguel Silva Seabra has waived all copyright and related or neighboring rights to Fix FirefoxOS Default Search Provider. This work is published from Portugal.

My first #Drupal related patch

I’ve recently installed the Corporate Clean theme on ANSOL’s website because of it’s fluid design and top slides.

However, the slides are implemented directly in php code in the page.tpl.php file. I hated that. So I pushed my hate towards a positive result: a fix proposal.

So now you just put some PHP block on the Slideshow region, add a custom field to the pages you want to show up there and use the Summary for the content. Seems simple enough and it’s possible to change the slides without needing direct access to the code, so you can let less experienced people just post content.

Setup front slides feature, new theme and Planet ANSOL

These last few days I’ve added a theme with slides feature to ANSOL’s website, changed the way it did them so it’s much, much more useful, and setup a feed aggregator for ANSOL’s members, that is Planet ANSOL. Read on to know more about what, and how it it changed.

The theme

…is called Corporate Clean, which not only carried a slides feature, but also has a more flexible layout for smaller screens like phones and tablets.

First I tried the default color, but then I changed to warmer colors as it was too cold for my taste, at least, and fixed up the logo which was looking a bit like, well, crap.

Went on to checkout how the slides worked and shrieked… this feature is hard coded on the page template! That will not do. So I hacked it in order to contain a region for the slides, duly called Slideshow, where I would be able to put a block.

Next, I added a custom Boolean field to the Basic and Event pages to mark whether that page’s Teaser/Summary was to be considered a slide. One only has to edit the Teaser/Summary and check the Slide check box by the end of the node edition page.

Finally, I wrote a small piece of PHP code that uses Entity API to query the database for nodes with that field set to true and display it’s teasers in the same manner that the theme had them hard coded.

The result is nice, and now you don’t need to hack code in order to make slides, although they do seem a bit too big to me, but maybe it will work.

The planet

… was very quick to setup with the Views and Feeds modules. I created an aggregation of the blogs I knew some members had, then hammered the view presentation options until I was satisfied with the result.

The main trick is to include all the feed fields you want to use, hide them from visibility and then use a generic text field to display them (using placeholders) in a more adequate form than the default one. Magic!

 

My favorite quote from Frankenweenie, applied to software

Frankenweenie is a very cool movie by Tim Burton, get it, watch it. My favorite quote from it is when the science teacher, Mr. Rzykruski, refutes the scaremongering against science that is launched by the mayor, who was very angry since his boy fell down a roof in a very unwise science project he and his friend were doing.

Ladies, gentleman.
I think the confusion here is that you are all very ignorant.
Is that right word, ignorant? I mean stupid, primitive , unenlightened.
You do not understand science so you are afraid of it, like a dog is afraid of thunder or balloons.
To you science is magic and witchcraft because, because you have small minds.
I cannot make your heads bigger, but your children’s is. I can take them and crack them open.
This is what I try to do. To get at their brains!
Ah, thank you.

This quote always reminds me of how so many people treat computers (well, the software) as some kind of magical thunder or witchcraft balloons and then proceed to make all sorts of bad decisions.

These go from colleagues and bosses to politicians and statesmen (in a generic form, not trying to tie out these roles to anyone in particular, mind you) and often the unwise decisions stemming from this ignorance have very, very bad results like wasting money of bad software solutions just because they have “support” (often so bad that it’s much worse than non SLA bases community support we’re used to on healthy Free Software projects) or stupid, primitive, unenlightened law proposals, some of which haven’t been stopped in time, some of which return in attempt after attempt like zombies from a B movie.

How can we fix this? Sigh.