-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathorb.yaml
63 lines (61 loc) · 2.79 KB
/
orb.yaml
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
version: 2.1
description: >
CircleCI Orb for using Tailscale
display:
home_url: "https://github.com/threecommaio/circleci-tailscale"
source_url: "https://github.com/threecommaio/circleci-tailscale"
commands:
connect:
description: Connect tailscale
parameters:
tailscale-auth-key:
type: env_var_name
description: Your Tailscale authentication key, from the admin panel.
default: TAILSCALE_AUTH_KEY
tailscale-proxy-address:
type: string
description: Proxy address where tailscale should listen.
default: localhost
tailscale-version:
type: string
description: Tailscale version to use.
default: "1.24.2"
steps:
- run:
name: "Download tailscale if not installed"
command: |
if ! command -v tailscale --version >/dev/null 2>&1; then
echo "Tailscale is not installed, installing..."
VERSION=<< parameters.tailscale-version >>
MINOR=$(echo << parameters.tailscale-version >> | awk -F '.' {'print $2'})
if [ $((MINOR % 2)) -eq 0 ]; then
URL="https://pkgs.tailscale.com/stable/tailscale_${VERSION}_amd64.tgz"
else
URL="https://pkgs.tailscale.com/unstable/tailscale_${VERSION}_amd64.tgz"
fi
curl $URL -o tailscale.tgz
tar -C ${HOME} -xzf tailscale.tgz
rm tailscale.tgz
TSPATH=${HOME}/tailscale_${VERSION}_amd64
sudo mv "${TSPATH}/tailscale" "${TSPATH}/tailscaled" /usr/bin
else
echo "Tailscale is already installed"
fi
- run:
name: "Run tailscale"
background: true
command: |
tailscaled --tun=userspace-networking --outbound-http-proxy-listen=<< parameters.tailscale-proxy-address >>:1054 --socks5-server=<< parameters.tailscale-proxy-address >>:1055 --socket=/tmp/tailscaled.sock 2>~/tailscaled.log
- run:
name: "Auth tailscale"
command: |
HOSTNAME="circleci-$(cat /etc/hostname)"
until tailscale --socket=/tmp/tailscaled.sock up --authkey ${<< parameters.tailscale-auth-key >>} --hostname=${HOSTNAME} --accept-routes
do
sleep 1
done
echo "export ALL_PROXY=socks5h://<< parameters.tailscale-proxy-address >>:1055/" >> $BASH_ENV
echo "export HTTP_PROXY=http://<< parameters.tailscale-proxy-address >>:1054/" >> $BASH_ENV
echo "export HTTPS_PROXY=http://<< parameters.tailscale-proxy-address >>:1054/" >> $BASH_ENV
echo "export http_proxy=http://<< parameters.tailscale-proxy-address >>:1054/" >> $BASH_ENV
echo "export https_proxy=http://<< parameters.tailscale-proxy-address >>:1054/" >> $BASH_ENV