Sunday, 9 June 2013

SFTP Chroot Setup for Group ScriptCraft Session

For the next Madlab CoderDojo I'm going to try running a group session scripting Minecraft with Javascript using ScriptCraft.  One problem with this is that there will be a room full of kids with laptops that I've never seen before who will need access to the ScriptCraft server to edit Javascript files.  My plan is to use Notepad++ for Windows and TextWrangler for Mac machines, and SFTP over to the server.  In order to restrict any potential damage I'm going to use the SSH server to enforce an SFTP chroot jail.  This is the server side of the setup...
  1. sudo adduser coderdojo
  2. sudo vi /etc/ssh/sshd_config
  3. Add the following to the end of the config file:
    Match User coderdojo
        ChrootDirectory /home/coderdojo
        AllowTCPForwarding no
        X11Forwarding no
        ForceCommand internal-sftp
  4. sudo /etc/init.d/ssh restart
  5. Finally the user's directory needs to be owned by root so:  sudo chown root:root /home/coderdojo
  6. Create a folder on the scriptcraft server for the coderdojo files:  sudo mkdir /home/coderdojo/dojo
  7. sudo chown coderdojo:coderdojo /home/coderdojo/dojo
  8. Now set up a symbolic link from the ScriptCraft plugin directory back to the coderdojo user's directory: sudo ln -s  /home/coderdojo/dojo /home/scriptcraft/bukkit/js-plugins/dojo
  9. sudo chmod a+w /home/coderdojo/dojo

With this setup in place, users can use SFTP to edit files on the ScriptCraft server that are then picked up and run by the ScriptCraft Javascript module.

The instructions I followed for this setup are on the Debian Admin site.

ScriptCraft Server Updated for Latest "classroom" Module

Walter Higgins from ScriptCraft has just added a "classroom" module to ScriptCraft. (Here's what changed on GitHub).  Here are the steps I followed to upgrade the Madlab Miners ScriptCraft server:

  1. Log on to the server as the scriptcraft user
  2. wget http://scriptcraftjs.org/download/2013-06-09/ScriptCraft.jar
  3. Re-attach to the scriptcraft screen session  (screen -r)
  4. Type "stop" at the server prompt, and wait for it to stop (takes several seconds to save the chunks from all the Multiverse worlds)
  5. mv ~/ScriptCraft.jar ~/bukkit/plugins
  6. Restart the server using the bash file: ./startserver.sh
  7. Once the server is up login and check that you can turn on the classroom with: /js classroom.allowScripting(true)
  8. Works like a charm!

Saturday, 8 June 2013

Method for Archiving Gmail

My sister-in-law runs a fashion business and as a consequence sends and receives a  lot of big emails.  Even Google Apps for Business' 25GB mail box allowance is used up within a couple of years.  I needed a way to archive emails out of Gmail and on to local storage.  Here's how I do it:

  1. Install the getmail tool.  I'm running it under Cygwin on Windows, but it should run equally well on Linux.  Here are the Cygwin steps:
    1. Run the Cygwin installer and make sure that you have python installed
    2. Make a directory for the getmail install: mkdir getmail
    3. cd getmail
    4. Download the latest release: wget http://pyropus.ca/software/getmail/old-versions/getmail-4.43.0.tar.gz
    5. tar -zxvf getmail-4.43.0.tar.gz
    6.  cd getmail-4.43.0
    7.  python setup.py install
  2. Log into the Gmail web UI of the account you want to archive
  3. Search for the files that you want to archive.  E.g. to find all the files sent or received in 2011 search for:  "before: 2012/01/01 after: 2010/12/31"
  4. Now we need to give all the search results a unique label.  The trick here is that you need to label all the search results not just the first page, so:
    1. In the Gmail web UI click the select "all" check box
    2. When you do this, Gmail will ask "All 20 conversations on this page are selected. Select all conversations that match this search", click on the link to make sure you select all of them
    3. Click on the label icon
    4. Fill something unique in the "Label as:" box, e.g. "Mail2011"
    5. Click the "Create New" link
    6. The "New Label" dialogue box will pop up.  Click "Create"
    7. A warning box will explain that this will affect all conversations in the search.  Click "OK"
    8. Wait a few seconds until the "Loading..." box goes way to give Google time to make all its changes
  5. Next we need to set up a config file that will let you download all the selected emails
    1. First make a new directory for the archive
    2. mkdir emailarchive
    3. cd emailarchive
    4. Then edit a new config file
    5. vi getmail.conf
    6. Adapt my config to your use:
      [retriever]
      type = SimpleIMAPSSLRetriever
      server = imap.gmail.com
      username = user@gmailaccount.com
      password = topsecret
      mailboxes = ("Mail2011",)
      port = 993


      [destination]
      type = Mboxrd
      path = /home/dave/emailarchive/Mail2011.mbox


      [options]
      received = false
      delivered_to = false
      read_all = false
      verbose = 1

  6. The next step is a gotcha, the archive file has to exist before you try to run the getmail program, so do: touch Mail2011.mbox
  7. You are ready to run the program now with:
    getmail --getmaildir /home/dave/emailarchive --rcfile getmail.conf
  8. Some time later you will have all the emails downloaded to a local mbox format mail store
  9. Finally you can now go back into Gmail, select the label you created earlier and delete all the emails.  Note that Gmail won't free up your space until the emails are emptied from your trash folder

If you need instructions on how to read mbox format mail store files take a look at these instructions for several different mail reading clients.

Thanks to Matt Cutts for outlining the general approach to Gmail archiving that I have adapted here.



Monday, 20 May 2013

Setting Up ScriptCraft

I've been looking at ScriptCraft as something for us to play with at the next MadLab CoderDojo.  Here are my notes on getting the server running...

(1) First I created a new "scriptcraft" user on the server
(2) I then installed Bukkit.  I'm running the "02110_1.5.2-R0.1" beta version of Bukkit so that the 1.5.2 Minecraft client works
(3) I set up a startserver.sh batch file to hold the commands to start things up
(4) I edited the server.properties file to bind Bukkit to port 25566.  There is the vanilla Minecraft server already running on the standard port 25565
(5) I changed to the plugins directory and pulled down the latest ScriptCraft.jar file


wget http://scriptcraftjs.org/download/2013-03-31/ScriptCraft.jar

(6) I then restarted the server and logged in with the Minecraft client, added my user to ops.txt,  typed

/js up().box('35:15', 4, 9, 1)

...and made myself a nice 2001: A Space Odyssey style monolith.


Saturday, 18 May 2013

10 Functions of the Comma

Really useful post about how to use the English comma correctly from Daily Writing Tips.



aptitude Broken in Debian 7.0

Having updated to Debian 7.0, my normal cycle of keeping things up-to-date with aptitude suggested that I install linux-libc-dev.  When I tried to install, things broke saying:

" warning: 'ldconfig' not found in PATH or not executable"

Google initially sent me down the wrong path to a solution to a slightly different problem on the Ubuntu forums.

Taking a moment to actually read the error message, the fix was a simple addition of /sbin and /usr/sbin to my path.  Quite a nice write up of the issue is here.

What I can't explain is why Debian 7.0 removed the sbin directories from my PATH.  It seems to have done it on all the Debian servers I look after.  I can't find any reference to this on the internet.

Saturday, 11 May 2013

Upgrading to Debian 7.0 Safety Tip

Note to self: if you are running aptitude to upgrade a Debian version remotely on an unreliable network link then use screen!!!