]> piware.de Git - talk-cockpit-auth-anywhere.git/blobdiff - demo.sh
Rework demo scripts
[talk-cockpit-auth-anywhere.git] / demo.sh
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