forked from karpathy/ulogme
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathulogme_tmux.sh
executable file
·44 lines (36 loc) · 1.66 KB
/
ulogme_tmux.sh
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
#!/bin/bash
# ulogme_tmux.sh for https://github.com/Naereen/uLogMe/
# MIT Licensed, https://lbesson.mit-license.org/
#
# Script to start a new tab in a tmux session, launching the data collection on the right & and Python web server on the left.
# http://redsymbol.net/articles/unofficial-bash-strict-mode/
set -o pipefail
set -eu
# Use https://bitbucket.org/lbesson/bin/src/master/.color.sh to add colors in Bash scripts
echo "WARNING If you don't see colors correctly, remove the 'color.sh' file in 'uLogMe/scripts' to remove the colors, or modify it to suit your need (if you have a light background for instance)." # See https://github.com/Naereen/uLogMe/issues/17
[ -f ~/bin/.color.sh ] && . ~/bin/.color.sh
echo -e "${yellow}Starting '${black}ulogme_tmux.sh'${reset} ..."
if [ -L "${BASH_SOURCE[0]}" ]; then
# We have a symlink... how to deal with it?
cd "$( dirname "$(readlink -f "${BASH_SOURCE[0]}")" )"
else
cd "$( dirname "${BASH_SOURCE[0]}" )"
fi;
# XXX assume runing inside a tmux session
if [ "X${TMUX}" = "X" ]; then
echo -e "${red}This script ${black}${0}${red} has to be run inside a tmux session.${reset}"
exit 1
fi
port="${1:-8443}" # Default is port=8124
IP="${2:-localhost}"
protocol="${3:-https}"
# Reference tmux man page (eg. https://linux.die.net/man/1/tmux)
# start a new window,
# name it ulogme
tmux new-window -a -n 'uLogMe' "tmux split-window -d \"./ulogme_serve.sh ${port} ${IP} ${protocol} | tee /tmp/ulogme_serve_$$.log\" ; ./ulogme_data.sh | tee /tmp/ulogme_data_$$.log"
# launch './ulogme_data.sh' in first one
# split it half
# launch './ulogme_serve.sh' in second one
sleep 12
# return to current tab at the end
tmux last-window