#!/bin/bash if [ ! -f /root/.tmate.conf ]; then cat > /root/.tmate.conf <<-EOF set -g mouse on set tmate-api-key "${API_KEY}" set tmate-session-name "${NAME_SESSION}" EOF fi while :; do if pgrep -f tmate > /dev/null; then sleep 3 else # background tmate -S /tmp/tmate.sock new-session -d &> /dev/null tmate -S /tmp/tmate.sock wait tmate-ready # show-messages tmate -S /tmp/tmate.sock display -p "web session read only: #{tmate_web_ro}" tmate -S /tmp/tmate.sock display -p "ssh session read only: #{tmate_ssh_ro}" tmate -S /tmp/tmate.sock display -p "web session: #{tmate_web}" tmate -S /tmp/tmate.sock display -p "ssh session: #{tmate_ssh}" fi done