]> piware.de Git - talk-cockpit-auth-anywhere.git/commitdiff
Rework demo scripts
authorMartin Pitt <martin@piware.de>
Wed, 8 Jan 2020 12:11:23 +0000 (13:11 +0100)
committerMartin Pitt <martin@piware.de>
Wed, 8 Jan 2020 12:22:04 +0000 (13:22 +0100)
Merge prep.sh and cleanup.sh into demo.sh that does everything.

Add "bots" and "download" make targets, and let demo.sh run the VMs

.gitignore
Makefile
cleanup.sh [deleted file]
cockpit-auth-anywhere.md
demo.sh [new file with mode: 0755]
prep.sh [deleted file]

index 5a7ecf68d9fc9dcc63ee30c1b46b15e3ffc629aa..1e91a7fccf9021c65b2e5f0af8c5d8286cd2f52f 100644 (file)
@@ -1 +1,3 @@
 cockpit-auth-anywhere.pdf
+bots
+tmp
index 9e2846744219e8f1a57d0bf067e2c138faf0fd04..9b0ef6dfc6841afce42b8a6921363738751c6abe 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -6,6 +6,13 @@ clean:
 
 # install the necessary tools to build this presentation
 deps:
-       sudo dnf install -y pandoc texlive-beamer texlive-latex-bin texlive-collection-fontsrecommended texlive-hyphen-german texlive-hyphen-english texlive-dehyph texlive-fancyhdr texlive-dinbrief texlive-german texlive-a4wide
+       which pandoc || sudo dnf install -y pandoc texlive-beamer texlive-latex-bin texlive-collection-fontsrecommended texlive-hyphen-german texlive-hyphen-english texlive-dehyph texlive-fancyhdr texlive-dinbrief texlive-german texlive-a4wide
+
+bots:
+       git clone --depth=1 https://github.com/cockpit-project/bots
+
+# download test VMs
+download: bots
+       bots/image-download rhel-7-8 windows-10
 
 .PHONY: deps clean
diff --git a/cleanup.sh b/cleanup.sh
deleted file mode 100755 (executable)
index e329830..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/sh -x
-sudo vgremove -f vg0
-sudo rmmod scsi_debug
-sudo rm -f /etc/cockpit.cockpit.conf /etc/cockpit/machines.d/* /etc/ssh/ssh_known_hosts
index e633e2bb73294353cffc2b532d2b88fc8c62513a..05298e25f34b64ec5032c15f1eaf66ea6e9ae0da 100644 (file)
@@ -48,7 +48,6 @@ resize2fs /dev/vg0/data1
  - Zero configuration
 
 :::notes
-- TODO: check out bots in "make deps", add ./vm-run windows-10 to prep.sh
 - Switch to Windows virt-viewer, open Edge, show Cockpit
 - Quit virt-viewer
 - Zero configuration so far, other than possibly installing cockpit pkg and enabling cockpit.socket
@@ -107,7 +106,6 @@ resize2fs /dev/vg0/data1
 nothing Cockpit specific running outside of the user session
 
 :::notes
-- TODO: start rhel7 VM in prep.sh, set hostname
 - ws and the login session don't need to run on the same machine
 - cockpit-session is meant to be customizable for your purposes
 - most obvious replacement is to let ssh start a session; that already does the
diff --git a/demo.sh b/demo.sh
new file mode 100755 (executable)
index 0000000..b63f4d9
--- /dev/null
+++ b/demo.sh
@@ -0,0 +1,87 @@
+#!/bin/sh
+# Run this script before starting the presention/demo.
+# Before you must run "make download".
+set -ex
+
+# specific for Martin Pitt
+VM_PREFIX="toolbox run -c devel"
+
+printf '[Session]\nIdleTimeout=0\n' | sudo tee /etc/cockpit.cockpit.conf
+sudo systemctl stop cockpit
+
+echo '127.0.0.2 cockpit.dev' | sudo tee -a /etc/hosts
+
+# LV resizing demo
+sudo modprobe scsi_debug dev_size_mb=512
+# sanity check
+m=$(cat /sys/block/sdb/device/model)
+[ "${m%% *}" = scsi_debug ]
+
+cat <<EOF | sudo sfdisk /dev/sdb
+label: dos
+label-id: 0x4e3c0cf8
+device: /dev/sdb
+unit: sectors
+
+/dev/sdb1 : start=        2048, size=      524288, type=83
+/dev/sdb2 : start=      526336, size=      522240, type=83
+EOF
+sudo pvcreate /dev/sdb1
+sudo vgcreate vg0 /dev/sdb1
+sudo lvcreate -n data1 -l '100%FREE' vg0
+sudo mkfs.ext4 -L data1 /dev/vg0/data1
+
+firefox http://localhost:9090/storage
+
+# for remote ssh session demo
+$VM_PREFIX sh -exc "cd $PWD"'
+mkfifo /tmp/r7vm
+env TEST_DATA=/tmp bots/machine/testvm.py rhel-7-8 > /tmp/r7vm &
+echo $! > /tmp/r7vm.pid
+
+read ssh_cmd < /tmp/r7vm
+echo "ssh command: $ssh_cmd"
+read _  < /tmp/r7vm  # URL, uninteresting
+read running < /tmp/r7vm
+[ "${running#RUNNING}" != "$running" ]  # sanity check
+rm /tmp/r7vm
+
+$ssh_cmd hostnamectl set-hostname server1
+sleep infinity
+' &
+R7VM_PID=$!
+
+sleep 20 # let the above VM initialize
+
+# Windows demo
+xhost +local: # allow X in toolbox
+cat <<EOF
+===============================================================
+Windows demo:
+ - In virt-viewer window, open Edge and log into https://10.0.2.2:9090
+ - Press F11 for fullscreen
+ - Minimize browser, to show the desktop
+ - When done, close virt-viewer (F11 and Ctrl+Shift+Q) to resume this script
+===============================================================
+EOF
+$VM_PREFIX `pwd`/bots/vm-run -C2 windows-10
+
+
+cat <<EOF
+===============================================================
+ssh demo: rhel-7-8 VM is still running, host name "cockpit.dev"
+When done, press Enter to clean up and finish
+===============================================================
+EOF
+read
+
+echo "Cleaning up..."
+set +e
+kill $R7VM_PID
+wait
+$VM_PREFIX sh -xc 'kill $(cat /tmp/r7vm.pid); rm -rf /tmp/r7vm.pid /tmp/tmp'
+rm -rf tmp/
+sudo vgremove -f vg0
+sudo rmmod scsi_debug
+sudo rm -f /etc/cockpit.cockpit.conf /etc/cockpit/machines.d/* /etc/ssh/ssh_known_hosts
+sudo sed -i '/^127.0.0.2 cockpit.dev$/d' /etc/hosts
diff --git a/prep.sh b/prep.sh
deleted file mode 100755 (executable)
index 7874fc3..0000000
--- a/prep.sh
+++ /dev/null
@@ -1,32 +0,0 @@
-#!/bin/sh -ex
-printf '[Session]\nIdleTimeout=0\n' | sudo tee /etc/cockpit.cockpit.conf
-sudo systemctl stop cockpit
-
-# LV resizing demo
-sudo modprobe scsi_debug dev_size_mb=512
-# sanity check
-m=$(cat /sys/block/sdb/device/model)
-[ "${m%% *}" = scsi_debug ]
-
-cat <<EOF | sudo sfdisk /dev/sdb
-label: dos
-label-id: 0x4e3c0cf8
-device: /dev/sdb
-unit: sectors
-
-/dev/sdb1 : start=        2048, size=      524288, type=83
-/dev/sdb2 : start=      526336, size=      522240, type=83
-EOF
-sudo pvcreate /dev/sdb1
-sudo vgcreate vg0 /dev/sdb1
-sudo lvcreate -n data1 -l '100%FREE' vg0
-sudo mkfs.ext4 -L data1 /dev/vg0/data1
-
-firefox http://localhost:9090/storage
-
-cat <<EOF
-Manual steps:
-=============
- - Log into Cockpit in browser
- - In Windows VM, open Edge and log into https://10.0.2.2:9090
-EOF