Setting Up Your Free Private Feed Reader

I’ve tried several RSS feed readers, offline as well as online: aKregator, Liferea, rss2email being the ones tried for a long time. One drawback with these offline tools is they may miss feeds when I’m offline for prolonged periods (travel, vacations, etc.). Also, they’re tied to one device; can’t switch laptops and have the feeds be in sync. I tried Google Reader for a while as well, for a solution in the “cloud”, which worked for a while, but not anymore.

So I started to search for an online feed reader, preferably with hosting services, since I didn’t want to keep up with updates to the software. I found several free readers, and Tiny Tiny RSS seemed like a really good option.  The developer hosts an online version of the reader, which I used for quite a while.  (The online service is soon going to be discontinued.)  I was quite content with that option, but when OpenShift was launched, I thought I’d try hosting tt-rss myself: it initially began as an experiment to using OpenShift. Then, when I moved this blog to OpenShift, I realised it didn’t really take much effort to host the blog, and that I could switch my primary instance of tt-rss from the developer-hosted instance to my own. It turned out to be really easy, and here I’ll share my recipe.

I first grabbed the ttrss sources from the git repo:

cd ~/src/
git clone git://github.com/gothfox/Tiny-Tiny-RSS.git

I then created an OpenShift php app.

cd ~/openshift
rhc app create -a ttr -t php-5.3

Then, added a mysql db and the phpmyadmin tool to manage the db, in case something goes wrong sometime.

rhc-ctl-app -e add-mysql-5.1 -a ttr
rhc-ctl-app -e add-phpmyadmin-3.4 -a ttr

After this initial setup, I copied all the files from the ttrss src dir to the php/ directory of the OpenShift repo:

cp -r ~/src/Tiny-Tiny-RSS/* ~/openshift/ttr/php/

Next is to add all the files to the git repo:

cd ~/openshift/ttr/
git add php
git commit -m 'Add tt-rss sources'

Now to set up the environment on the server for tt-rss to work in. E.g. creating directories where tt-rss will store its feed icons, temporary files, etc. This is needed, as the OpenShift git directory is transient: it’s deleted and re-created whenever ‘git push’ is done. So to store persistent data between git pushes, we need to use the OpenShift data directory. Create an app build-time action hook to setup the proper directory structure each time the app is built (i.e. after a git push). Learn more about the different build hooks here.

Edit the .openshift/action_hooks/build file, so it looks like this:

#!/bin/bash
# This is a simple build script, place your post-deploy but pre-start commands
# in this script.  This script gets executed directly, so it could be python,
# php, ruby, etc.

TMP_DIR=$OPENSHIFT_DATA_DIR/tmp
LOCK_DIR=$OPENSHIFT_DATA_DIR/lock
CACHE_DIR=$OPENSHIFT_DATA_DIR/cache

ln -sf $OPENSHIFT_DATA_DIR/icons $OPENSHIFT_REPO_DIR/php/ico
if [ ! -d $TMP_DIR ]; then
    mkdir $TMP_DIR
fi

if [ ! -d $LOCK_DIR ]; then
    mkdir $LOCK_DIR
fi

if [ ! -d $CACHE_DIR ]; then
    mkdir $CACHE_DIR
fi

if [ ! -d $CACHE_DIR/export ]; then
    mkdir $CACHE_DIR/export
fi

if [ ! -d $CACHE_DIR/images ]; then
    mkdir $CACHE_DIR/images
fi

Make this file executable, and commit the result:

chmod +x .openshift/action_hooks/build
git add .openshift/action_hooks/build
git commit -m 'build hook: create and link to persistent RW directories'

Next was to create the tt-rss config file from the provided template:

cd ~/openshift/ttr/php/
cp config.php-dist config.php

And then editing the config file.

First, the DB info. I created a new db user via the phpmyadmin interface, but you can use the default admin user as well.

        define('DB_TYPE', "mysql");
        define('DB_HOST', $_ENV['OPENSHIFT_DB_HOST']);
        define('DB_USER', "<user>");
        define('DB_NAME', "ttr");
        define('DB_PASS', "<your pass>");
        //define('DB_PORT', '5432'); // when neeeded, PG-only

Next come the files and directories section:

        define('LOCK_DIRECTORY', $_ENV['OPENSHIFT_DATA_DIR'] . "/lock");
        // Directory for lockfiles, must be writable to the user you run
        // daemon process or cronjobs under.

        define('CACHE_DIR', $_ENV['OPENSHIFT_DATA_DIR'] . '/cache');
        // Local cache directory for RSS feed content.

        define('TMP_DIRECTORY', $_ENV['OPENSHIFT_DATA_DIR'] . "/tmp");
        // Directory for temporary files

        define('ICONS_DIR',  $_ENV['OPENSHIFT_DATA_DIR'] . '/icons');
        define('ICONS_URL', "ico");

The last icons bit is a modification from the default of ‘feed-icons’. If you’re setting up a new repo, there’s no need to deviate from the default, but when I had deployed the tt-rss instance, the default icons directory was ‘icons’, which unfortunatley clashes with Apache’s idea of what $URL/icons is. So I used ‘ico’. Remember to modify the bit in the build hook above to create the appropriate symlink if this ICONS_URL is changed.

These config settings are the ones specific to OpenShift. Modify the others to suit your needs.

Lastly, add a cron job to update the feeds at an hourly interval:

cd ~/openshift/ttr
mkdir .openshift/cron/hourly

I created a new file, called update-feeds.sh, in the new .openshift/cron/hourly directory, and added the following to it:

#!/bin/bash

$OPENSHIFT_REPO_DIR/php/update.php -feeds >/dev/null 2>&1
date >> $OPENSHIFT_LOG_DIR/update-feeds.log

For troubleshooting cron jobs, you can append custom output to any file in the log directory, like the date being output above. For other ways to update feeds, refer to the tt-rss documentation.

Add this file to git:

cd ~/openshift/ttr
git add .openshift/cron/hourly/update-feeds.sh
git commit -m 'add hourly cron job to update feeds'

Lastly, push the result to the OpenShift servers:

git push

That’s it! Enjoy your completely free (free as in freedom, as well as free as in beer) and personal feed reader in the clouds.

5 thoughts on “Setting Up Your Free Private Feed Reader

  1. Mace Moneta

    Since you didn’t mention it, what’s the problem with Google Reader? It seems to meet all your criteria, it’s free (as in beer), runs across most platforms, and provides a consistent view across devices.

    Reply
  2. Pingback: R.I.P. Google Reader

  3. mohan

    Hello, I really appreciate this guide. I was wondering if you could help me with this step:

    “So to store persistent data between git pushes, we need to use the OpenShift data directory. Create an app build-time action hook to setup the proper directory structure each time the app is built (i.e. after a git push).”

    I don’t have an openshift directory, just the ttr directory that was created in my home folder in my distro. Thanks in advance.

    Reply
    1. Amit Shah Post author

      The openshift directory is hidden: the actual name is “.openshift” in the root of the git tree.

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>