-
Notifications
You must be signed in to change notification settings - Fork 3
/
run.sh
executable file
·48 lines (38 loc) · 1.1 KB
/
run.sh
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
#! /bin/sh
export PATH=$PATH:/tailscale/bin
AUTH_KEY="${AUTH_KEY:-}"
ROUTES="${ROUTES:-}"
EXTRA_ARGS="${EXTRA_ARGS:-}"
USERSPACE="${USERSPACE:-true}"
# If AUTH_KEY is not in env, attempt to find it under $AUTH_KEY_LOCAL_PATH
if [ -z "${AUTH_KEY}" ] && [ ! -z "${AUTH_KEY_LOCAL_PATH}" ]; then
AUTH_KEY=$(cat ${AUTH_KEY_LOCAL_PATH})
fi
set -e
TAILSCALED_ARGS="--socket=/tmp/tailscaled.sock"
if [[ "${USERSPACE}" == "true" ]]; then
TAILSCALED_ARGS="${TAILSCALED_ARGS} --tun=userspace-networking --outbound-http-proxy-listen=localhost:1055"
else
if [[ ! -d /dev/net ]]; then
mkdir -p /dev/net
fi
if [[ ! -c /dev/net/tun ]]; then
mknod /dev/net/tun c 10 200
fi
fi
echo "Starting tailscaled"
tailscaled ${TAILSCALED_ARGS} &
PID=$!
UP_ARGS="--accept-dns=false"
if [[ ! -z "${ROUTES}" ]]; then
UP_ARGS="--advertise-routes=${ROUTES} ${UP_ARGS}"
fi
if [[ ! -z "${AUTH_KEY}" ]]; then
UP_ARGS="--authkey=${AUTH_KEY} ${UP_ARGS}"
fi
if [[ ! -z "${EXTRA_ARGS}" ]]; then
UP_ARGS="${UP_ARGS} ${EXTRA_ARGS:-}"
fi
echo "Running tailscale up"
tailscale --socket=/tmp/tailscaled.sock up ${UP_ARGS}
wait ${PID}