Provision Fantom for Vagrant

Tuesday, 12 August 2014 3:11pm

Vagrant is an awesome tool for anyone who needs to develop or test against predictable OS configurations. If you’ve never played with – definitely check it out:

If you have a Linux box, the steps below will get Fantom up and running. These steps are for Debian/Ubnutu – so you may need to tweak for other distros.

1. Init your box

For this tutorial we’ll use the built-in Ubuntu box:

$ mkdir example
$ cd example
$ vagrant init hashicorp/precise32

2. Configure your Vagrantfile

Edit your Vagrantfile to add a provision step:

# -*- mode: ruby -*-
# vi: set ft=ruby :

# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| = "hashicorp/precise32"
  config.vm.provision :shell, path: ""

  # any other config you need


3. Add your script

Add a script in the same directory as your Vagrantfile:

#! /bin/bash

quiet() {
  # if provision is failing uncomment/comment to see full output
  "$@" &> /dev/null

# Unzip
echo "Install unzip..."
quiet apt-get install unzip

#   To install another version update 'JAVA_VER'
#   For example: JAVA_VER="7"
#   Note: if you use JDK7+ for compiling, then any compiled Fantom
#   pods will require a Java 7 or later runtime.  If you wish to target
#   Java 1.5 or 1.6 runtimes then you must use JDK 1.6 (JAVA_VER="6")
echo "Install JDK $JAVA_VER..."
echo "deb precise main" \
  >> /etc/apt/sources.list
echo "deb-src precise main" \
  >> /etc/apt/sources.list
echo "debconf shared/accepted-oracle-license-v1-1 select true" \
  | debconf-set-selections
echo "debconf shared/accepted-oracle-license-v1-1 seen true" \
  | debconf-set-selections
quiet apt-key adv --keyserver --recv-keys EEA14886
quiet apt-get update
quiet apt-get -y -f install oracle-java${JAVA_VER}-installer

# Fantom
#   To install a different version of Fantom update 'FAN_VER'
#   For example: FAN_VER="1.0.64'
echo "Installing Fantom ${FAN_VER}..."
wget -q$FAN_ZIP
unzip -q $FAN_ZIP -d /opt
mv /opt/fantom-$FAN_VER /opt/fantom
bash /opt/fantom/adm/unixsetup
echo "export PATH=$PATH:/opt/fantom/bin/" >> /etc/profile
rm -f $FAN_ZIP

4. Boot your box

$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'hashicorp/precise32'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'hashicorp/precise32' is up to date...
==> default: Setting the name of the VM: linux-arm_default_1407852247628_86495
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 => 2222 (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address:
    default: SSH username: vagrant
    default: SSH auth method: private key
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
    default: The guest additions on this VM do not match the installed version of
    default: VirtualBox! In most cases this is fine, but in rare cases it can
    default: prevent things such as shared folders from working properly. If you see
    default: shared folder errors, please make sure the guest additions within the
    default: virtual machine match the version of VirtualBox you have installed on
    default: your host and reload your VM.
    default: Guest Additions Version: 4.2.0
    default: VirtualBox Version: 4.3
==> default: Mounting shared folders...
    default: /vagrant => /Users/andy/example
==> default: Running provisioner: shell...
    default: Running: /var/folders/2v/0phd0cks4t1d4922gq7yl6kw0000gn/T/
==> default: stdin: is not a tty
==> default: Install unzip...
==> default: Install JDK 6...
==> default: Installing Fantom 1.0.66...
==> default: ###
==> default: ### FAN_HOME=/opt/fantom
==> default: ###

5. SSH in and Happy Fantom-ing!

$ vagrant ssh
vagrant@precise32:~$ fan -version
Fantom Launcher
Copyright (c) 2006-2013, Brian Frank and Andy Frank
Licensed under the Academic Free License version 3.0

Java Runtime:
  java.version:    1.6.0_45    Java HotSpot(TM) Client VM
  java.vm.vendor:  Sun Microsystems Inc.
  java.vm.version: 20.45-b01
  java.home:       /usr/lib/jvm/java-6-oracle/jre
  fan.platform:    linux-x86
  fan.version:     1.0.66
  fan.env:         sys::BootEnv
  fan.home:        /opt/fantom

Fantom wrapper for Mailgun

Wednesday, 17 April 2013 2:26pm

Posted a Fantom wrapper for Mailgun. Has first-class support for basics (send, unsub, spam, bounces, logs, stats). But really simple to work with raw REST API too.

The Fantom Linode Guide

Wednesday, 27 February 2013 1:57pm

I’ve stubbed out a basic guide for getting Fantom up and running on Linode. Its a bit of a work in progress – but mostly gets you from start to finish:

  • Installing Fantom on Debian
  • Setting up init scripts
  • Configuring ngnix as proxy server
  • Setting up automated deployments

Its hosted on BitBucket – so feel free to send me pull requests if you have corrections or improvements (I’m by no means a linux guru…):

init.d example for Fantom

Wednesday, 15 August 2012 8:31am

Update 27 Feb 2013 – While this should still be valid advice – it’s been superseded by a more comprehensive guide covering the whole process of getting Fantom up and running on Debian:

Been meaning to post this for awhile. Below is the init.d script I use to run Fantom on my personal sites. I'm running Debian 6 – but should be straightforward to tweak for other distros. Might need to apt-get a few things like pgrep - can't remember what came out of the box.

A few caveats:

  1. I always install and run each "app" using a dedicated user with its own Fantom runtime. I find this really simplifies security, process management, and versioning. This example uses the fan user.

  2. This script should properly block until process cleanly exits. But don't have a good way to know when start is complete - so just waits a few seconds. You can tweak depending on your app.

  3. This script redirects stdout and stderr to the same log file. You can tweak as necessary.

  4. I'm using a script ( to launch my site. But you can launch Wisp or another main directly from bash string.

Example server layout:

~/               User home directory
  fantom/        Fantom runtime
  dist/          App path env
    fan.props    Empty fan.props to force PathEnv
    lib/         PathEnv lib for App

Example init.d script for Fantom:

#! /bin/bash
# /etc/init.d/example

FIND_PID="pgrep -u fan java"

case "$1" in
    PID=$( $FIND_PID )
    if [ -f $PID ]; then
      echo "Starting"
      sudo -u fan bash -c  'cd ~/dist; ~/fantom/bin/fan &' &> $STDOUT
      sleep 3
      echo " is already running"
    echo "Stopping"
    PID=$( $FIND_PID )
    if [ -f $PID ]; then
      echo " is not running"
      kill $PID
      while kill -0 $PID 2> /dev/null; do
        sleep 0.5
      echo "stopped"
    PID=$( $FIND_PID )
    if [ -f $PID ]; then
      echo " is not running"
      echo " is running"
    $0 stop
    $0 start
    echo "Usage: /etc/init.d/example {start|stop|restart|status}"
    exit 1

exit 0

Cinco de Mayo meets Kentucky Derby

Saturday, 24 March 2012 8:23pm

Weekend project for a friend.

Cinco de Mayo meets Kentucky Derby

Converting Linksys WRT54G to Wireless Bridge

Monday, 5 March 2012 3:44am

We've been doing some repurposing of rooms the past week or two. In the process, an office got moved to the opposite side of the house from our FiOS modem. That office unfortunately is home to a circa 2005 Dell Workstation with no WiFi support.

Since I had an unused Linksys WRT54G router collecting dust, I spent a few minutes googling if I could use that to avoid stringing Cat5 down my hallway. Turns out with the help of some open source firmware DD-WRT, you can do just that (and more).

The overall process is pretty straightforward – but as is common for this type of thing – lots of out-dated, inaccurate, or not fully defined documentation. So I thought I'd add to the mix ;)

What This Post Covers

Just so you don't waste time readings this – this post specifically covers:

  • Linksys WRT54G ver 2.0
  • Installing DD-WRT firmware v24 SP2 [Beta] Build 13064
  • Configuring router as a Client Bridge
  • Issues using WPA2 security
  • Primary router is a Verizon FiOS ActionTec MI424WR-GEN2 (firmware version 20.19.8)
  • Date just for reference: March 2012

Bridge vs Repeater vs Yadda Yadda

I'm no expert in this area, so I took some time to get my bearings on what I actually needed to accomplish. There are lots of terms and setups, and overlaps between setups, but a bit of googling should set you straight.

In my case, I simply wanted to join a second LAN network over a wireless "bridge." The second network would not provide wireless access, so the primary router is the only wireless access point for clients. So we want to setup our second router as a Client Bridge.

If you wish to also provide wireless access from the second router, I believe you want to configure it as a Repeater Bridge - which **requires different instructions** than I present here. More information on the different modes:

If any of this information is inaccurate, please let me know.

Installing DD-WRT firmware

DD-WRT is a Linux distribution which replaces the factory firmware, opening up lots of additional features for routers like the WRT54G. Since I only really cared about the bridge capability, I chose the micro binary. Wikipedia has a good overview of what each version supports:

This video covers very simple and clear instructions on installing DD-WRT firmware onto the WRT54G (ver 2.0) – from downloading the binary to uploading the firmware onto the router:

I had no issues following these instructions – and were alot simpler than some other ones I came across. Once complete you should see the new DD-WRT admin console when you pull up in your browser.

Configuring Router as a Client Bridge

Once you have DD-WRT up and running, we need to configure the router to act as a client bridge. The best instructions I found for this are here:

These again worked (almost) without incident. If the primary router is configured for WPA2, things will likely not work from my experience and what I could find online. Luckily it's very simple to isolate the issue to security. Disable security on both the primary router and your second router, then retry, and everything should work like a charm.

Using WPA2 Security

If your primary router is setup to use WPA2, and things didn't work, you have a few options:

  • Drop to WEP security
  • Drop to WPA security
  • Enable WPA2 TKIP + AES support on primary router, WPA on secondary

Both WEP and WPA should work just fine between the DD-WRT and your primary router. I spent a good deal of time trying to find a way to maintain WPA2 on my network, and the only real solution was to enable mixed mode.

So configure your primary router to use WPA2 TKIP + AES, then set the DD-WRT to use normal WPA security. This worked for me without a hitch. I would assume this only reduces protection for the traffic over the bridge, while all traffic over the primary router should be using the more secure AES encryption. But I really don't know enough about this stuff to say for sure.

Would love to know if this is accurate, or if enabling TKIP + AES reduces security overall.

Markdown for Fantom

Sunday, 5 February 2012 3:37pm

Sunday Funday project for today – Markdown for Fantom:

Markdown is a great little plain-text format created by John Gruber that converts nicely to HTML. Fantom's own Fandoc was heavily inspired by Markdown. We just simplified a few things and added some Fantom conventions in a few places. But I've wanted the full Markdown syntax at my disposal for some time now.

Luckily it was a pretty simple project – I was able to essentially take the great Markdownj work as-is and wrap with a native Fantom API. Code is available over at BitBucket and is licensed under the BSD license.

LESS for Fantom

Sunday, 22 January 2012 5:50pm

I worked up a Fantom wrapper around LESS this week. Code and docs over on BitBucket:

LESS is a great little "extension" to CSS that adds lots of convenient features like variables, mixins, and nested rules that make developing and managing complex CSS much easier.

The Fantom wrapper adds:

  • An API interface to compile LESS files from a Str input or a File reference
  • A simple command line interface for compiling LESS files to CSS files
  • A BuildTask for integrating LESS into your Fantom build pipeline

Draft Mini Web Framework

Sunday, 24 July 2011 4:13pm

I've posted a project I've been working on in my spare time recently:

Draft Mini Web Framework

Draft is a small web framework designed to notch in above WebMod, provide some useful features, while trying to leave as much freedom as possible for your app. Details over on the project site.

Its still a work in progress, but decided it was far enough along to start being useful to anyone who doesn't mind getting their hands dirty. Hopefully I'll have it wrapped up here in the next few months, and can be more generally useful to developers looking for a simple and lightweight solution for developing web apps in Fantom.

Sketching Logos

Wednesday, 5 January 2011 1:31pm

Was flipping thru an old moleskin and found two sketches I made back in Fall 2009.

Fantom logo sketch

First was a little sketch of a potential logo for the Fantom language. For whatever reason, when we changed the name to Fantom, I got this 1920s/Art Deco motif concept in my head (hence the typeface). I'm pretty sure its because of the movie The Shadow, but I keep trying to tell myself thats not the case... Never really had time to come up with a real logo – but this is one I sorta liked.

Axon logo sketch

Second was a logo for the Axon scripting language we designed for our day job at SkyFoundry. Would love to give these both some good Photoshop treatment if I ever find the time.

Blue Collar Languages

Monday, 27 September 2010 5:58pm

Cay Horstmann wrote an interesting response to Stephen Colebourne's NBJL post:

Creating a "blue collar" language isn't something that happens every day.

When done by "blue collar" people who have sketchy knowledge of programming language theory, the result is often problematic. Look at PHP--I trust that I won't have to elaborate... Or Groovy, many of whose properties (particularly in the MOP) are under-specified and constantly shifting.

Few "white collar" people have an interest in designing a blue-collar language. They give us languages that dazzle us with their brilliance and innovation. After all, that's what a researcher is rewarded for.

Interestingly he made no mention of Fantom in this context, which means I assume he hasn't looked at it any detail. That was one of the explicit design goals.

Which makes me wonder - do people pass over Fantom because of the exact same reasons they search for new languages? You want a simpler, more expressive language, with great APIs, that make your life easier 9-5. But you take a look at Fantom, and move right along, since you don't see buzzwords like monads, or some ground breaking new syntax?

Beer Mile

Monday, 27 September 2010 5:02pm

Koozie artwork for a friend's annual Stew & Brew party. Theme was a Beer Mile.

Beer Mile

Fantom's History and Future with JavaScript

Wednesday, 2 June 2010 2:04pm

One of Fantom's primary design goals from day one was portability between the JVM and CLR. Naturally we got to thinking, if we can run on both of the popular VM's, why not on JavaScript too? That would enable enormous opportunities for code reuse and greatly simplify the huge impedance mismatch of developing backend server code and user interfaces in the browser.

Read the full post at


Monday, 12 April 2010 3:41pm

The product we have been crafting at SkyFoundry for the past year and a half has officially been christened as SkySpark.


SkySpark is turning out to be an awesome platform for visualizing, analyzing, and managing mountains of data. We've updated the website to include some high level technical documentation on the software stack. Its built 100% in Fantom - including all the client-side browser code using the Fantom JavaScript compiler.

This software has really validated the years of effort we've put into making Fantom a first-class language. I don't think we'd have been able to build anything even close without it. I'm excited to show off more as we move towards the official release.


Wednesday, 17 March 2010 3:54pm

Played with the new Inbox2 beta today. Very promising application. Really tries to build a new email model from the start instead of trying to bolt things to the side of a 10-year design. Looking forward to see where it goes.