Giter Site home page Giter Site logo

swc-demo-sandbox's Introduction

Software Carpentry Demonstration Sandbox

This repository contains code to set up a Bash terminal running inside a Linux Container, so that it is in a more-or-less fresh installation of a recent Ubuntu. The primary motivation is to allow an instructor to demonstrate setting up Git configuration and SSH keys without clobbering their existing setup.

The terminal uses a fork of Raniere Silva's swc-shell-split-window script. One major difference is that the history pane is shown at the bottom rather than the top, so that the active prompt line is nearer the middle of the window.

You must have LXD installed on your system before running the setup script.

First time setup

./make-swc-lxc.sh

This creates a basic LXC image instance swc and installs a usercmd alias for running simple commands as the ubuntu user (i.e. not root) in a given container.

If the usercmd alias already exists, the existing definition will be printed to the screen before it is clobbered, so you have a chance to save it under a different name or restore it after finishing with this code.

Additional setup steps before a given workshop

To erase any previous changes:

lxc restore swc clean

Additional setup for individual lessons:

  • SWC Shell lesson

    lxc usercmd swc --env CMD=setup-shell.sh

    This installs the latest data files under ~/Desktop/shell-lesson-data.

  • LC Shell lesson

    lxc usercmd swc --env CMD=setup-lcshell.sh

    This installs the latest data files under ~/Desktop/shell-lesson.

  • SWC Git lesson (probably not necessary)

    lxc usercmd swc --env CMD=setup-git.sh

    This installs a couple of Mars pictures (source: NASA/JPL/Cornell) as ~/Pictures/sky/mars.jpg and ~/Pictures/surface/mars.jpg in case you would rather use these than random binary files.

The technical difficulties associated with accessing Jupyter Lab or RStudio inside a Linux Container means this is more trouble than it is worth: run these lessons directly on your computer.

Using the image for teaching

To launch the demo terminal:

lxc usercmd swc --env CMD=demo-terminal.sh

To launch a second demo terminal:

lxc usercmd swc --env SESSION=swc2 --env CMD=demo-terminal.sh

Tear down

I recommend stopping the container if you don't need it, so it doesn't take up system resources:

lxc stop swc

Once it is stopped, you can update your container to the latest code:

lxc delete swc
./make-swc-lxc.sh

Demo terminal options

The demo terminal can be customised with the following environment variables:

  • SESSION: The identifier for the session (default: swc).

  • LOG_FILE: The location where the log file will be stored (default: /tmp/$SESSION-split-log-file).

  • HISTORY_LINES: How many lines of history to be shown (default: 5).

  • BGCOLOR: Background colour of the session panes (0-255, default: transparent). Note that the panes do not necessarily reach the edges, so you will get a border consisting of the default terminal background.

  • PTCOLOR: Colour of the prompt (0-255, default: 8).

You can pass these to the script using the --env option of lxc usercmd as in the examples above.

To see what the numeric colours look like on your terminal, run this:

for i in {0..255} ; do echo -en "\e[1;38;5;${i}m#\e[0m $i\n" ; done

swc-demo-sandbox's People

Contributors

alex-ball avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.