aboutsummaryrefslogtreecommitdiffstats
path: root/core/entrypoint.bash
blob: e2d15c1ac33f1e82cc7a3ac77afb5e1f76e3789a (plain)
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
#!/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