Booktype Installation for TurnKey Linux, Part 1
  • In the interest of eventually building a patch to bring Turnkey LAPP 11.2 to a booktype appliance, I've made build notes for my first successful installation. It's posted here for now. These build notes are for TurnKey Linux's Django appliance. My next set of notes will be for LAPP.
  • 13 Comments sorted by
  • Hi Rik,

    Very nice. Please keep us posted on your progress and let us know if you come across any issues.

    adam
  • If I'm able to revise a post, I'll keep the newest version here.

    Starting point: TKL LAPP; for timebeing, using sqlite first.

    Revision 2/21/12: 13:15 est

    1. #!/bin/bash -ex
    2. # Set Hostname
    3. HOSTNAME=booktype
    4. echo "$HOSTNAME" > /etc/hostname
    5. sed -i "s|127.0.1.1 \(.*\)|127.0.1.1 $HOSTNAME|" /etc/hosts
    6. apt-get update
    7. DEBIAN_FRONTEND=noninteractive apt-get -y \
    8.     -o DPkg::Options::=--force-confdef \
    9.     -o DPkg::Options::=--force-confold \
    10.     install libapache2-mod-wsgi
      python-dev libxml2-dev libxslt-dev python-django build-essential
      python-psycopg2 git-core python-setuptools redis-server
    11. easy_install simplejson
    12. easy_install South
    13. easy_install pip
    14. pip install unidecode
    15. pip install pil
    16. ./Booktype/scripts/createbooki --database sqlite /var/www/mybooktype/
    17. cd /var/www/mybooktype
    18. . ./booki.env
    19. django-admin syncdb --noinput
    20. django-admin migrate
    21. django-admin loaddata documentation_licenses
    22.  
    23. ###############
    24. #This interactive step needs to be automated
    25. #Ideally, on install of the patched ISO, user is prompted for
    26. #root, postgres, and django passwords
    27. ###############
    28. django-admin createsuperuser
    29.  
    30. ###############
    31. #django-admin runserver 0.0.0.0:8080
    32. ##
    33. #Create a startup script to manage the service in init.d
    34. #Or rely on Apache2
    35. ###############
    36. # When adapted for LAPP, Add DB User
    37. #su -c - postgres "createuser -s booktype" && true
    38. #### Create Fresh Postgre DB
    39. #### ensure no active connections to old one
    40. #service apache2 stop
    41. #su -c - postgres "dropdb booktype" && true
    42. #su -c - postgres "createdb -O booktype booktype"
    43. #su -c - postgres "createlang plpgsql -d booktype"
    44. # Add Role Password
    45. #if [ ! -e "$TMP_DIR/booktype.sql" ]; then
    46. #cat < "$TMP_DIR/booktype.sql"
    47. #ALTER ROLE booktype WITH PASSWORD 'booktype';
    48. #EOF
    49. #fi
    50. #su -c - postgres "psql -d booktype -f '$TMP_DIR/booktype.sql'"

    Post edited by rik goldman at 2012-02-21 14:16:06
  • Great. Please also post the url if you update your blog with part 2 etc 

    Looking good Rik...many thanks for sharing this info.

    adam
  • Some questions. I'm feeling pretty confident about this patch working out and sincerely appreciate the encouragement. For this to work out, ultimately, I need some guidance.

    1. mod_wsgi: I've worked through the install guide and followed the link to mod_wsgi. Nothing I try is working. I'm told I can add two lines and have it working. I haven't discovered those two lines.
    Given: module enabled
    Given: the following in 000-default in /etc/apache2/sites-enabled:
    NameVirtualHost *:80
    NameVirtualHost *:443

    <VirtualHost *:80>
            ServerAdmin webmaster@localhost
            DocumentRoot /var/www/
    </VirtualHost>

    <VirtualHost *:443>
            SSLEngine on
            SSLCertificateFile /etc/ssl/certs/cert.pem
            ServerAdmin webmaster@localhost
            DocumentRoot /var/www/
    </VirtualHost>

    ScriptAlias /cgi-bin/ /var/www/cgi-bin/

    <Directory /var/www/>
            Options Indexes FollowSymLinks MultiViews
            Order allow,deny
            allow from all
    </Directory>

    Given: path to booktype /var/www/mybooktype

    In this scenario, what lines do I add, and within what stanza? Do I need additional lines in httpd.conf, which in the scenario is empty.

    1. [2, really] I need to set an inithook so the django-admin password setting happens on intallation of the distro. Or, alternatively and less acceptably, include a scripted solution that sets the password non-interactively.
    Any thoughts?

    Post edited by rik goldman at 2012-02-21 14:15:33
  • I will ask Aco the lead dev to give you a tip or two :)

    adam
  • Okay, I'm stuck. Booktype worked when I worked from the install instructions. Then it didn't work with the script - threw an error I'll show in a minute. So I rebuilt manually, to find that I still have an error; this is some of what I end up with in the browser:

    ImportError at /

    cannot import name Feed

    Request Method: GET
    Request URL: http://booktype.23eyes.org:8080/
    Exception Type: ImportError
    Exception Value:

    cannot import name Feed

    Exception Location: /root/Booktype/lib/booki/portal/feeds.py in , line 17
    Python Executable: /usr/bin/python
    Python Version: 2.6.5
    Python Path: ['/usr/bin', '/usr/local/lib/python2.6/dist-packages/simple_json-1.1-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/South-0.7.3-py2.6.egg', '/var/www/mybooktype', '/var/www', '/var/www/mybooktype/lib', '/root/Booktype/lib', '/usr/lib/python2.6', '/usr/lib/python2.6/plat-linux2', '/usr/lib/python2.6/lib-tk', '/usr/lib/python2.6/lib-old', '/usr/lib/python2.6/lib-dynload', '/usr/lib/python2.6/dist-packages', '/usr/lib/python2.6/dist-packages/PIL', '/usr/lib/pymodules/python2.6', '/usr/local/lib/python2.6/dist-packages']
    Server time: Wed, 22 Feb 2012 02:36:07 +0100

    Anyone have an idea what I may be missing?
  • Reply to @rik+goldman:
    Setting the password without user interaction is not possible with default tools. The only way to do it is:
     $ django-admin createsuperuser --username=john --email=john@gmail.com --noinput

    Superuser account is created but that user can't log in now. To change the password you need to run python script like this (path to django and booktype project and booktype and DJANGO_SETTINGS_MODULE must be defined... or everything what is in booki.env).

    from django.contrib.auth.models import User
    u = User.objects.get(username__exact='john')
    u.set_password('new password')
    u.save()

    Speaking about apache config. I am not sure what kind of problems you have but apache config file is in
    /var/www/mybooktype/wsgi.apache. On debian/ubuntu machine you need to copy it to /etc/apache2/sites-available/ (under name mybooktype for instance). Then you enable it with "a2ensite mybooktype. You just need to install mod_wsgi module before that (we tested libapache2-mod-wsgi).
  • thank you! this fills in some significant blanks. ill have at it tomorrow.
  • Everything is doing well except mod_wsgi.

    a2enmod wsgi #done
    a2dissite 000-default #done
    cp /var/www/mybooktype/wsgi.apache /etc/apache2/sites-available #no problem
    a2ensite wsgi.apache #no problem
    service apache2 restart #no problem

    However, when I navigate to ipaddress/mybooktype I get error type 500.

    Any insights? Need more info?
  • Solved. Booktype/ is in /root. www-data hasn't permission. git clone to /opt seems conventional...
  • good work! :) 


  • Patch for Turnkey Linux complete. I've attached a patch for consideration by TurnKey Linux here: http://www.turnkeylinux.org/forum/general/20120514/tklpatch-booktype. It brings TurnKey Linux Core 12RC (Squeeze) to Booktype with Apache and sqlite (I couldn't make it build using postgres this time). The patch and the patched ISO appliance are also available at http://www.23eyes.org/9while9. I anticipate one problem already: missing libraries for Python imaging. Also, since my Python is weak, the firstboot init hook is a cludge. I'll go ahead and attach the patch here. There's a brief tutorial for patching TKL at http://www.turnkeylinux.org/docs/tklpatch/apply.
    Post edited by rik goldman at 2012-05-15 04:13:09
  • Vote Up0Vote Down adamadam
    Posts: 88Member
    wow awesome. im busy these next days but will take a look at it shortly


    adam

    On Mon, May 14, 2012 at 10:37 PM, rik goldman
    wrote:
    > Patch for Turnkey Linux complete. I've attached a patch for consideration by
    > TurnKey Linux here:
    > http://www.turnkeylinux.org/forum/general/20120514/tklpatch-booktype. It
    > brings TurnKey Linux Core 12RC (Squeeze) to Booktype with Apache and sqlite
    > (I couldn't make it build using postgres this time). The patch the patched
    > ISO appliance are also available at http://www.23eyes.org/9while9. I
    > anticipate one problem already: missing libraries for Python imaging. Also,
    > since my Python is weak, the firstboot init hook is a cludge.
    >
    >