From 2365b8f460d888a6728f6f557e1e1e3cacddc15e Mon Sep 17 00:00:00 2001 From: Jerome Petazzoni Date: Thu, 8 Aug 2019 07:37:05 -0500 Subject: [PATCH] Add web server to make it easier to generate cards from CNC node --- .gitignore | 1 + prepare-vms/lib/commands.sh | 17 +++++++++++++++++ prepare-vms/www/README | 4 ++++ prepare-vms/www/index.html | 0 4 files changed, 22 insertions(+) create mode 100644 prepare-vms/www/README create mode 100644 prepare-vms/www/index.html diff --git a/.gitignore b/.gitignore index 21ae9d25..29ad9ad8 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ *~ prepare-vms/tags prepare-vms/infra +prepare-vms/www slides/*.yml.html slides/autopilot/state.yaml slides/index.html diff --git a/prepare-vms/lib/commands.sh b/prepare-vms/lib/commands.sh index 807120ac..5fb3ed76 100644 --- a/prepare-vms/lib/commands.sh +++ b/prepare-vms/lib/commands.sh @@ -33,9 +33,14 @@ _cmd_cards() { ../../lib/ips-txt-to-html.py settings.yaml ) + ln -sf ../tags/$TAG/ips.html www/$TAG.html + ln -sf ../tags/$TAG/ips.pdf www/$TAG.pdf + info "Cards created. You can view them with:" info "xdg-open tags/$TAG/ips.html tags/$TAG/ips.pdf (on Linux)" info "open tags/$TAG/ips.html (on macOS)" + info "Or you can start a web server with:" + info "$0 www" } _cmd deploy "Install Docker on a bunch of running VMs" @@ -568,6 +573,18 @@ EOF" sudo systemctl start webssh.service" } +_cmd www "Run a web server to access card HTML and PDF" +_cmd_www() { + cd www + IPADDR=$(curl -sL canihazip.com/s) + info "The following files are available:" + for F in *; do + echo "http://$IPADDR:8000/$F" + done + info "Press Ctrl-C to stop server." + python -m http.server +} + greet() { IAMUSER=$(aws iam get-user --query 'User.UserName') info "Hello! You seem to be UNIX user $USER, and IAM user $IAMUSER." diff --git a/prepare-vms/www/README b/prepare-vms/www/README new file mode 100644 index 00000000..1499f3a6 --- /dev/null +++ b/prepare-vms/www/README @@ -0,0 +1,4 @@ +This directory will contain symlinks to HTML and PDF files for the cards +with the IP address, login, and password for the training environments. + +The file "index.html" is empty on purpose: it prevents listing the files. diff --git a/prepare-vms/www/index.html b/prepare-vms/www/index.html new file mode 100644 index 00000000..e69de29b