2019-03-22 18:08:42 +01:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
SESSION="circolog"
|
|
|
|
DAEMON="d"
|
|
|
|
WINDOW="${SESSION}:${DAEMON}"
|
|
|
|
|
|
|
|
send_command() {
|
|
|
|
tmux send-keys -t "${WINDOW}.${1}" "${2}" Enter
|
|
|
|
}
|
|
|
|
|
|
|
|
digit_command() {
|
|
|
|
local input=$2
|
|
|
|
for (( i=0; i<${#input}; i++ ))
|
|
|
|
do
|
|
|
|
sleep 0.1
|
|
|
|
tmux send-keys -t "${WINDOW}.${1}" "${input:$i:1}"
|
|
|
|
done
|
|
|
|
sleep 2
|
|
|
|
tmux send-keys -t "${WINDOW}.${1}" Enter
|
|
|
|
}
|
|
|
|
|
2019-03-23 19:09:19 +01:00
|
|
|
digit_comment() {
|
|
|
|
local input=$2
|
|
|
|
for (( i=0; i<${#input}; i++ ))
|
|
|
|
do
|
|
|
|
sleep 0.1
|
|
|
|
tmux send-keys -t "${WINDOW}.${1}" "${input:$i:1}"
|
|
|
|
done
|
|
|
|
sleep 2
|
|
|
|
for (( i=0; i<${#input}; i++ ))
|
|
|
|
do
|
|
|
|
tmux send-keys -t "${WINDOW}.${1}" "C-h"
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2019-03-22 18:08:42 +01:00
|
|
|
config() {
|
|
|
|
tmux new -s $SESSION -n $DAEMON -d
|
|
|
|
tmux set-option -t $SESSION status off
|
|
|
|
tmux split-window -v -t $WINDOW
|
|
|
|
send_command 0 "bash"
|
|
|
|
send_command 1 "bash"
|
|
|
|
send_command 0 "PS1='my-server ~ '"
|
|
|
|
send_command 1 "PS1='my-server ~ '"
|
|
|
|
send_command 0 "clear"
|
|
|
|
send_command 1 "clear"
|
|
|
|
}
|
|
|
|
|
|
|
|
start_circologd() {
|
|
|
|
sleep 3;
|
2019-03-23 19:09:19 +01:00
|
|
|
digit_comment 0 "Let's start circologd in foreground. It can be put in background as an ordinary unix process and will keep on listening."
|
2019-03-22 18:08:42 +01:00
|
|
|
digit_command 0 "circologd"
|
|
|
|
}
|
|
|
|
|
|
|
|
start_ctl() {
|
2019-03-23 19:09:19 +01:00
|
|
|
sleep 20;
|
|
|
|
digit_comment 1 "Let's also play with the control utility for circologd, circologctl."
|
|
|
|
sleep 1
|
2019-03-22 18:08:42 +01:00
|
|
|
digit_command 1 "circologctl status"
|
2019-03-23 19:09:19 +01:00
|
|
|
sleep 3
|
|
|
|
digit_comment 1 "circologd can be paused..."
|
2019-03-22 18:08:42 +01:00
|
|
|
digit_command 1 "circologctl pause"
|
2019-03-23 19:09:19 +01:00
|
|
|
sleep 3;
|
|
|
|
digit_comment 1 "...and unpaused"
|
2019-03-22 18:08:42 +01:00
|
|
|
digit_command 1 "circologctl pause"
|
2019-03-23 19:09:19 +01:00
|
|
|
sleep 3
|
|
|
|
digit_comment 1 "A filter can be applied, so that circologd record only some messages."
|
|
|
|
digit_command 1 "circologctl filter 'msg LIKE \"%interested%\"'"
|
|
|
|
sleep 1
|
|
|
|
digit_command 1 "circologctl status"
|
2019-03-22 18:08:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
attach_session() {
|
|
|
|
tmux attach -t $SESSION
|
|
|
|
}
|
|
|
|
|
|
|
|
cleanup() {
|
|
|
|
send_command 0 "C-c"
|
|
|
|
tmux kill-session -t $SESSION
|
|
|
|
}
|
|
|
|
|
|
|
|
trap cleanup 2 15
|
|
|
|
config
|
|
|
|
start_circologd &
|
|
|
|
start_ctl &
|
|
|
|
attach_session
|