EC2 launch script feedback valued.

From: Andrew Stuart <andrew.stuart@xxxxxxxxxxxxxxxxxx>

To: rumpkernel-users <rumpkernel-users@xxxxxxxxxxxxx>

Date: Sun, 26 Jul 2015 18:02:22 +1000

I’m interested to get feedback please on this. Any thoughts and opinions
valued. I’m not precious about it so no need to tiptoe around - rip it apart if
you want - it’s my first shell script larger than 3 lines so any improvement
ideas welcome.

This is a script for getting a rump kernel to work on EC2. Start point was the
MiraegOS script for doing a similar thing but this is substantially modified.

You must modify rumprun/platform/xen/callmain.c before building rumprun (which
is done with ./build-rr.sh xen) and include hardcoded_jsoncfg. Here is an
example:

ensure your environment has the AWS keys set up
export AWS_ACCESS_KEY=XXXXXXXXXXX
export AWS_SECRET_KEY=YYYYYYYYYYYYY

In addition to creating an EC2 AMI for the unikernel, this script creates and
attaches an ext2 formatted block device. The script copies files onto that
block device so that your rump kernel is able to access them. You tell the
script which directory to copy onto the block device via the -p /filesystempath
parameter.

The script must be run from an EC2 instance and cannot run outside EC2.

For now, it creates a unikernel in the EC2 availability zone that the instance
is on that executes the script. I’ll change that at some point sp it can built
for other availability zones.

A final important note is that right now the launched unikernel doesn’t work as
there’s an issues currently being resolved I suspect with vbd mapping but
waiting to hear ideas on how to resolve it from this list.

#!/bin/bash

# todo need to give snapshots a name
# todo need to finalise block mapping for AMI when its working

# this script is copied from the Mirage-OS project and modified for rump
kernels.
# IMPORTANT: script must be run from an EC2 instance - it won't work outside EC2
#set -x
SUDO=sudo
UNIKERNELMOUNTPOINT=/mnt/unikernel
FILESYSTEMMOUNTPOINT=/mnt/filesystem

##########################################################################################
##########################################################################################
###### ask EC2 what block devices are attached to this instance.
###### unmount and detach the block devices in case they are still attached for
some reason
##########################################################################################
##########################################################################################

##########################################################################################
##########################################################################################
###### prepare block device
###### this will be the root file system for the unikernel
##########################################################################################
##########################################################################################

##########################################################################################
###### unmount and detach the block devices in case they are still attached for
some reason
##########################################################################################

echo You can now start this instance via:
echo ec2-run-instances --region ${THISREGION} ${AMIID}
echo ""
echo Don\'t forget to customise this with a security group, as the
echo default one won\'t let any inbound traffic in.