Skip to content

A fully functional terminal for edrys, based on pyxterm.js

License

Notifications You must be signed in to change notification settings

Cross-Lab-Project/edrys_module-pyxtermjs

 
 

Repository files navigation

Edrys PyxTerm.js Module

This module runs a full terminal within edrys, an open remote teaching platform. It is based on pyxterm.js by Chad Smith.

screenshot

Usage

To use this URL to add the module to your class:

https://cross-lab-project.github.io/edrys_module-pyxtermjs/index.html

additionally you will have to clone this project and start the pyxterm.js terminal server:

python3 -m pyxtermjs --cors True

To secure the usage, you can also start a docker-container, which is used as a secure environment or, as it is shown below, you can run and restrict the command-line access via firejail. The --private-home is not necessarily required, it simply copies my zsh configuration to the firejail home folder.

python3 -m pyxtermjs --cors True --tmp True --command firejail --cmd-args='--noroot --private --quiet --cpu=1 --nice=19 --hostname=host --net=none --no3d --nosound --rlimit-cpu=1 --allow-debuggers --shell=/bin/zsh --private-home=/home/andre/.zshrc --private-home=/home/andre/.oh-my-zsh'

You may optionally specify any of the following station-only settings:

{ "server": "http://localhost:5000/pty"
, "execute": "execute"
, "script": "echo $CODE | base64 --decode"
, "enable": {
  "teacher": true,
  "student": true
  }
}

the server contains the default terminal-server, and via execute it is possible to define a subject on which this module will listen for code to be executed. The following view is only visible on station-mode. Whenever another module sends some code/commands via the predefined "execute"-topic, the script on top will be executed, whereby $CODE will be substituted with the code passed from another module. By default students and teachers cannot directly access the terminal, they will see only the output. You will have to grant access via the checkboxes, which are only visible on the station.

station-control

API

> python3 -m pyxtermjs --help

usage: __main__.py [-h] [-p PORT] [--cors CORS] [--host HOST] [--debug] [--version] [--command COMMAND] [--cmd-args CMD_ARGS] [--tmp TMP]

A fully functional terminal in your browser. https://github.com/cs01/pyxterm.js

optional arguments:
  -h, --help            show this help message and exit
  -p PORT, --port PORT  port to run server on (default: 5000)
  --cors CORS           enable CORS by default this is disabled (default: False)
  --host HOST           host to run server on (use 0.0.0.0 to allow access from other hosts) (default: 127.0.0.1)
  --debug               debug the server (default: False)
  --version             print version and exit (default: False)
  --command COMMAND     Command to run in the terminal (default: bash)
  --cmd-args CMD_ARGS   arguments to pass to command (i.e. --cmd-args='arg1 arg2 --flag') (default: )
  --tmp TMP             use a temporary folder as base, which comes handy when using firejail (default: False)

Docker

To enable an even more secure usage, you can also start and or modify the included Dockerfile.

Build and run it via:

$ docker-compose up

or directly load our prebuild image from dockerhub:

$ docker run -it -p 5000:5000 crosslab/edrys_pyxtermjs:latest

However, if you want to build more elaborate docker images, you can have a look at the included Docker- and docker-compose files in docker. Or, if you want to directly run them, simply use:

$ docker run -it -p 5000:5000 crosslab/edrys_pyxtermjs_development:latest

to start an entire development server with gcc, java, python, nodejs, etc. installed, or:

$ docker run -it -p 5000:5000 crosslab/edrys_pyxtermjs_arduino:latest \
  --device=/dev/ttyACM0:/dev/ttyACM0 \
  --device-cgroup-rule='c 166:* rmv' \
  --device-cgroup-rule='c 189:* rmv'

to start a container with arduino support.

Edrys - Classroom

You can try out the following classroom/lab configuration for sharing a terminal with your students:

https://raw.githubusercontent.com/Cross-Lab-Project/edrys_module-pyxtermjs/master/laboratory.yaml

see the configuration here.

About

A fully functional terminal for edrys, based on pyxterm.js

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Shell 96.5%
  • Python 1.9%
  • Other 1.6%