Created
February 14, 2018 00:12
-
-
Save hemna/056b03b5d1ad8fba0497f4140b8445cd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This tmux script is to be used in conjunction with running devstack | |
# services. After devstack is up, this script opens up a tmux session | |
# with windows for every devstack service that tails the journalctl log | |
# for that service | |
cmd_dir="$(dirname "$(readlink -e ${0})")" | |
session="devstack" | |
active_sessions=`tmux ls 2>/dev/null | grep ${session}` | |
services=`systemctl | grep devstack | awk '{if ($1 ~ /^devstack\@/) print $1;}'` | |
journal_cmd="journalctl -a -f --unit" | |
# see if we have an existing session with that name. | |
# If we do, use it, and don't create new windows. | |
# This prevents our tmux session from getting new windows | |
# to each vm every time we fire tmux.sh up | |
if [[ ${active_sessions:0:${#session}} == ${session} ]]; | |
then | |
# We already have a session running with that name. use it. | |
${DEBUG:+echo} tmux select-window -t :0 | |
${DEBUG:+echo} tmux attach -d -t "${session}" | |
else | |
${DEBUG:+echo} tmux new -d -s "${session}" | |
for service in $services | |
do | |
${DEBUG:+echo} tmux neww -n "${service}" "${journal_cmd} ${service}" | |
done | |
${DEBUG:+echo} tmux select-window -t :0 | |
${DEBUG:+echo} tmux attach -d -t "${session}" | |
fi | |
exit 0 |
Author
hemna
commented
Feb 14, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment