From 65b5eacaa500e702b982c6848e1ffc18094bc9a9 Mon Sep 17 00:00:00 2001 From: Alice Frosi Date: Fri, 9 Jun 2023 11:07:25 +0200 Subject: demo: with mknod and podman Splited common functions in web/common.sh and created new script for mknod demo. The demo uses the mount namespace of the caller. Additionally, this removes extra commented lines in demo/mknod.hjson. --- web/common.sh | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 web/common.sh (limited to 'web/common.sh') diff --git a/web/common.sh b/web/common.sh new file mode 100644 index 0000000..b815dd4 --- /dev/null +++ b/web/common.sh @@ -0,0 +1,86 @@ +#!/bin/sh -ef +# +# SPDX-License-Identifier: GPL-2.0-or-later +# +# web/demo_connect.sh: Prepare asciinema(1) demo for connect example +# +# Copyright (c) 2023 Red Hat GmbH +# Author: Stefano Brivio +# Alice Frosi + +SEITAN_DIR=$(pwd) + +setup_common() { + tmux new-session -d -s $SESSION + tmux send-keys -t $SESSION 'PS1="$ "' + tmux send-keys -t $SESSION C-m + tmux send-keys -t $SESSION clear + tmux send-keys -t $SESSION C-m + + tmux set -t $SESSION window-status-format '#W' + tmux set -t $SESSION window-status-current-format '#W' + tmux set -t $SESSION status-left '' + tmux set -t $SESSION window-status-separator '' + + tmux set -t $SESSION window-status-style 'bg=colour1 fg=colour15 bold' + tmux set -t $SESSION status-right '' + tmux set -t $SESSION status-style 'bg=colour1 fg=colour15 bold' + tmux set -t $SESSION status-right-style 'bg=colour1 fg=colour15 bold' + tmux send-keys -t $SESSION "cd ${SEITAN_DIR}" ENTER + sleep 1 +} + +script() { + IFS=' +' + for line in $(eval printf '%s\\\n' \$SCRIPT_${1}); do + unset IFS + case ${line} in + "@") tmux send-keys -t $SESSION C-m ;; + "#"*) sleep ${#line} ;; + *) cmd_write "${line}" ;; + esac + IFS=' +' + done + unset IFS +} + +cmd_write() { + __str="${@}" + while [ -n "${__str}" ]; do + __rem="${__str#?}" + __first="${__str%"$__rem"}" + if [ "${__first}" = ";" ]; then + tmux send-keys -t $SESSION -l '\;' + else + tmux send-keys -t $SESSION -l "${__first}" + fi + sleep 0.05 || : + __str="${__rem}" + done + sleep 2 + tmux send-keys -t $SESSION "C-m" +} + +wait_seitan_exit() { + while [ "$(pgrep seitan)" != "" ] ; do sleep 1; done +} + +clear_panes() { + wait_seitan_exit + panes=$(tmux list-panes |awk '{ print $1 }' | sed 's/://') + for p in $panes + do + tmux select-pane -t $p + tmux send-keys -t $SESSION clear + tmux send-keys -t $SESSION C-m + done + sleep 1 +} + +teardown_common() { + sleep 5 + tmux kill-session -t $SESSION + sleep 5 +} -- cgit v1.2.3