aboutgitcodelistschat:MatrixIRC
path: root/web/demo_connect.sh
blob: 64938a24e79944c4e1769b293512b850a06c69c4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/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 <sbrivio@redhat.com>
#         Alice Frosi <afrosi@redhat.com>

SESSION=demo
VIDEO=seitan-connect

source web/common.sh

split_panes() {
	tmux split-window -h
	tmux send-keys -t $SESSION 'PS1="$ " && clear' ENTER
	tmux split-window -v
	tmux send-keys -t $SESSION 'PS1="$ " && clear' ENTER
}

SCRIPT_cooker='
cat demo/connect.hjson
###
clear
./seitan-cooker demo/connect.hjson demo/connect.gluten demo/connect.bpf
###
clear
'

SCRIPT_socat='
#
socat UNIX-LISTEN:/tmp/demo.sock -
#
'

SCRIPT_eater_connect='
#
./seitan-eater -i demo/connect.bpf -- socat OPEN:abcd UNIX-CONNECT:/cool.sock
#
'

SCRIPT_eater_connect_error='
#
./seitan-eater -i demo/connect.bpf -- socat OPEN:abcd UNIX-CONNECT:/error.sock
#
'

SCRIPT_seitan='
#
./seitan -p $(pgrep seitan-eater) -i demo/connect.gluten
'

printf '\e[8;22;80t'

setup_common

tmux send-keys -t $SESSION -l 'reset'
tmux send-keys -t $SESSION C-m
tmux rename-window -t $SESSION 'Seitan demo: generate input files'

asciinema rec --overwrite ${VIDEO}.cast -c 'tmux attach -t $SESSION' &
sleep 1
#tmux refresh-client

PSEITAN=$(get_first_pane)
PEATER=$((PSEITAN+1))
PSERVER=$((PEATER+1))

# Input generation
tmux select-pane -t $PSEITAN
script cooker

# First part
split_panes

tmux select-pane -t $PSERVER
tmux rename-window -t $SESSION 'Seitan demo: connect to another path'
script socat

tmux select-pane -t $PEATER
script eater_connect
tmux select-pane -t $PSEITAN
script seitan
sleep 4

# Use only 2 panes
clear_panes
tmux kill-pane -t $PSERVER

# Second part
tmux rename-window -t $SESSION 'Seitan demo: error injection (EPERM)'
tmux select-pane -t $PEATER
script eater_connect_error
tmux select-pane -t $PSEITAN
script seitan

teardown_common
gzip -fk9 ${VIDEO}.cast