forked from coder/sshcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.sh
More file actions
executable file
·35 lines (26 loc) · 707 Bytes
/
Copy pathtest.sh
File metadata and controls
executable file
·35 lines (26 loc) · 707 Bytes
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
#!/bin/bash
set -euxo pipefail
REMOTE_IP="$1"
VS_CODE_PORT=10010
result() {
rv="$?"
ssh "$REMOTE_IP" "pkill codessh" || true
pkill sshcode || true
exit "$rv"
}
trap "result" EXIT
go install
sshcode --port="$VS_CODE_PORT" --no-open "$REMOTE_IP" &
ATTEMPTS=0
MAX_ATTEMPTS=10
# Try to curl VS Code locally on a backoff retry.
until curl -o /dev/null --connect-timeout 5 -s "localhost:$VS_CODE_PORT" || [ "$ATTEMPTS" -eq "$MAX_ATTEMPTS" ]; do
sleep $(( ATTEMPTS++ ))
done
if [ "$ATTEMPTS" -eq "$MAX_ATTEMPTS" ];
then
echo "Timed out waiting for code server to start"
exit 1
fi
# Curl VS Code remotely.
ssh "$REMOTE_IP" "curl -o /dev/null --connect-timeout 5 -s localhost:$VS_CODE_PORT/"