TurnKey Linux Virtual Appliance Library

TKLPatch: Booktype

Booktype is a web application for writing, editing, and publishing books that keeps collaboration in mind every step of the way.

Here's the promo blurb from Sourcefabric (source):

Booktype is a free, open source platform that produces beautiful, engaging books formatted for print, Amazon, iBooks and almost any ereader within minutes. Create books on your own or with others via an easy-to-use web interface. Build a community around your content with social tools and use the reach of mobile, tablet and ebook technology to engage new audiences.

There's an open demo here.

Compared to Sourcefabric's other open projects, the documentation is disappointing: https://github.com/sourcefabric/Booktype/blob/master/INSTALL. Booktype relies on Django and either sqlite3 or postgres.
 What little I know about Django I picked up from working toward a patch solution for this; I find patching appliances that are reliant on postgres quite a challenge. Keeping all this in mind: I couldn't get this build on a TKL LAPP stack or a Django appliance. I have in the past, but couldn't recreate the process.

I did have success, however, building a patch for Core 12RC that uses Apache2 and mod_wsgi.

This patch disables default apache site, and relies on sqlite3 where Postgres is recommended (but not documented).

It has a cludge of an inithook to set the superuser password and email for Booktype. I'll elaborate more very soon.

There's discussion here with a particularly helpful post if this patch were to be revised with a more elegant inithook in mind.

Rather than buildnotes, here's the conf script

I have built and revised this so much I know longer have build notes that make sense. Here's the conf script with elaboration:

#!/bin/bash -ex

#overlay: /etc/confconsole/services.txt
#overlay: /usr/lib/inithooks/firstboot.d - runs booki.env followed by django-admin createsuperuser

#Set Hostname
echo "$HOSTNAME" > /etc/hostname
sed -i "s| \(.*\)| $HOSTNAME|" /etc/hosts

#install function; unnecessary in this case
    apt-get update
    DEBIAN_FRONTEND=noninteractive apt-get -y \
        -o DPkg::Options::=--force-confdef \
        -o DPkg::Options::=--force-confold \
        install $@

#Install from Repos
install libapache2-mod-wsgi \
    python-django \
    python-dev \
    python-django-south \
    sqlite3 \
    git-core \
    python-setuptools \
    python-pip \
    redis-server \
    libxml2-dev \
    build-essential \
    libxslt-dev \

#Python imaging might need more for graphics to publish. Don't know what, however.

#Easy Install; other easy_install candidates are handled with apt above
easy_install lxml

pip install unidecode

#Clone Source (git)
git clone https://github.com/sourcefabric/Booktype.git /opt/booktype/

#create the thing at /var/www/booktype, with settings.py configured for sqlite.
/opt/booktype/scripts/createbooki --database sqlite /var/www/booktype

#hard to script for me; I try to avoid changing directories in scripts, but I couldn't find a way around it.
#straight from the docs, except loaddata is done before createsuperuser.

cd /var/www/booktype
. ./booki.env
django-admin syncdb --noinput
django-admin migrate
django-admin loaddata documentation_licenses
cd ~

a2dissite default
a2ensite booktype
service apache2 reload
chown -R www-data:www-data /opt/booktype/
chown -R www-data:www-data /var/www/booktype/

Jeremy Davis's picture

Theoretically yes

But in practice it will depend. You may have to tweak TKLBAM to ensure all the data is included. But it should be relatively straight forward.

Where it becomes problematic is when you move from a patched appliance to an official appliance. In that instance I would probably recommend a manual migration. Although perhaps TKLBAM would work ok?

Also FYI it's generally not required to update from one minor version to the next (ie from 11.2 to 11.3) These updates are more for new users that don't want to wait for all the security updates to download. If your appliance is up to date (ie all updates downloaded and installed) then there is generally no advantage to going to the new version. Issues such as the udev bug make doing a full upgrade a bit of a pain though.

Jeremy Davis's picture

Moving between minor versions should prove no issue

But as you suggest going between major version (ie v11.x to v12.x) may involve a bit more effort. This will especially be the case when the software itself has had major updates. Often between major software updates things like DB schemas can change significantly - to the point of the software not working until the DB is updated. Often there are 'migration' scripts available from upstream which will help you out there (by changing the DB layout to be compatible with the new version).

Booktype and 12.0 Core

Works perfectly. Couldn't go more smoothly.

Post new comment

The content of this field is kept private and will not be shown publicly. If you have a Gravatar account, used to display your avatar.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <p> <span> <div> <h1> <h2> <h3> <h4> <h5> <h6> <img> <map> <area> <hr> <br> <br /> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <em> <b> <u> <i> <strong> <font> <del> <ins> <sub> <sup> <quote> <blockquote> <pre> <address> <code> <cite> <strike> <caption>

More information about formatting options

Leave this field empty. It's part of a security mechanism.
(Dear spammers: moderators are notified of all new posts. Spam is deleted immediately)