run: improve log

This commit is contained in:
Gilles Grandou 2021-11-29 09:12:57 +01:00
parent 1ba5abb584
commit ef186496c7

17
run
View File

@ -7,6 +7,8 @@ session="tic2mqtt"
cmd=""
quiet=""
cd $rundir
while [ $# -gt 0 ]; do
case "$1" in
start) cmd=$1;;
@ -57,9 +59,18 @@ case "$cmd" in
;;
log)
if [ -n "$is_running" ]; then
tmux capture -b $session -p -S - | head -15
echo "[...]"
tmux capture -b $session -p -E -
tmp=$(mktemp)
tmux capture -b $session -p -S - >$tmp
if [ $(cat $tmp |wc -l) -gt 30 ]; then
head -10 $tmp
echo
echo "[...]"
echo
tail -20 $tmp
else
cat $tmp
fi
rm -f $tmp
else
echo "no tic2mqtt running"
fi