circolog-website/circolog-resources/rec-server.sh

64 lines
1.3 KiB
Bash
Raw Normal View History

#!/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
}
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;
#send_command 1 "docker run --name clogd -h my-server -ti testcircolog"
digit_command 0 "circologd"
}
start_ctl() {
sleep 5;
# send_command 0 "docker exec clogd /go/bin/circologctl status"
digit_command 1 "circologctl status"
sleep 5;
digit_command 1 "circologctl pause"
sleep 5;
digit_command 1 "circologctl pause"
}
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