Up to Main Index                          Up to Journal for February, 2014

                   JOURNAL FOR THURSDAY 6TH FEBRUARY, 2014
______________________________________________________________________________

SUBJECT: WolfMUD Go server running on unrooted Nexus 7
   DATE: Thu  6 Feb 21:47:50 GMT 2014

While chatting with another developer who was interested in WolfMUD I was
asked if I could do another of my 'WolfMUD related but not WolfMUD' posts.
Something a bit more interesting than: progress is slow, been busy, yada yada
yada... :P

So here goes...

First a rarity on this site - a picture! Nexus7-WolfMUD.png

So what is that a picture of? It's a screen shot of the WolfMUD Go server
running natively on an unrooted Nexus 7 (2013) running Android 4.4.2 KitKat.
You can also substitute WolfMUD for any Go console program and Nexus 7 for
tablet if you want to keep things generic ;)

This should work for any console based Go program but I'm going to tell you
what I had to do to get WolfMUD running.

First of all it's easy and straight forward: no hacking, no rooting, no
packaging of apps, no Google Android NDK - and everything is easily reversible
if desired. What more could you ask for?

I did take few short cuts to keep things simple - this initially started out
as just a quick experiment.

So, step by step, here we Go:

1. Statically compile Go
========================

  For this I compiled Go from source on my Raspberry Pi running Raspbian.
  Cross compiling should work just as well but the Pi was handy. On the Pi
  first compile Go for static compiling as root:


    cd /usr/local/go/src
    CGO_ENABLED=0 ./all.bash


  For cross compiling I'll do a separate post or if this becomes a popular
  entry maybe I'll expand everything into an actual article for the site. Also
  note that compiling on the Pi creates an ARMv6 binary whereas the Nexus 7 is
  ARMv7 so the binary will probably not take advantage of all features
  available.


2. Statically compile WolfMUD server
====================================

  Then I statically compiled the WolfMUD server as a normal user:


    cd /home/diddymus/WolfMUD
    GOPATH=/home/diddymus/WolfMUD CGO_ENABLED=0; go install -v ./...


  So we now have the static binary in /home/diddymus/WolfMUD/bin and can check
  it is statically compiled using ldd:


    ldd /home/diddymus/WolfMUD/bin/server

      not a dynamic executable


3. Get your tablet's IP address
===============================

  You will need to update the config.wrj file with your tablet's IP address.
  So goto Settings->Wireless & Networks->Wi-Fi select your connection and it
  should display your IP address. This needs to be set in the config.wrj file
  where we change the address to listen on. For example:


    listen.address: 192.168.0.131


4. Get binary and data files onto the Nexus 7
=============================================

  For this I already had my desktop Chrome with Google Drive and I had Google
  Drive on the Nexus 7 - so I used that to transfer the server and data files
  config.wrj and zinara.wrj. Alternatively you could email the files to your
  tablet, use a USB cable or a removeable SD card - lots of options.

  Eventually the files should end up in Downloads on the tablet - which is
  usually /sdcard/Download on the filesystem.


5. Setup & make the server executable
=====================================

  To make the server executable we need to install a terminal app on the
  tablet. This will also give us shell access for actually running the server.
  For this I picked 'Android Terminal Emulator' by Jack Palevich. You can
  download from the play store here:


    https://play.google.com/store/apps/details?id=jackpal.androidterm


  On Android apps get their own directory and have more freedom to do stuff in
  their own directory than they normally would elsewhere on the filesystem.
  This is handy as from Android 4.3 and up - I think - you can not 'su to
  root' any more unless you root your device. A problem when we need to set
  the execute permission flag on the server binary to run it.

  So Android Terminal has it's own little sandbox directory:


    /data/data/jackpal.androidterm/shared_prefs


  What we do is fire up the terminal app to get a command line and copy our
  files from /sdcard/Download to the app's directory and then set the execute
  permission flag:


    cd /data/data/jackpal.androidterm/shared_prefs
    mkdir wolfmud
    cd wolfmud
    mkdir data
    cp /sdcard/Download/server .
    cp /sdcard/Download/*.wrj data/
    chmod 755 server


6. Run the server!
==================

  Finally we can run the WolfMUD server:


    ./server


  Refer to screen shot at beginning of this entry for what you should see :)


7. Connect!
===========

  From another machine telnet into your tablet on port 4001. For example using
  the IP address from step 3 above:


    telnet 192.168.0.131 4001


8. End of the world
===================

  Currently you end the server by sending a Ctrl-C. If you are using the
  Android Terminal Emulator you can send a Ctrl-C by pressing volume-down then
  c on the virtual keyboard. Other terminal apps may differ.


If you have any comments or questions feel free to drop me an email:

  diddymus@wolfmud.org


UPDATE: Since publishing this and the avalanche of email it generated I
        followed it up with a small Q&A here: 7.html

--
Diddymus


  Up to Main Index                          Up to Journal for February, 2014