mirror of
https://github.com/jbowdre/tailscale-docker.git
synced 2024-11-23 18:32:17 +00:00
21 lines
656 B
Bash
21 lines
656 B
Bash
#!/bin/ash
|
|
trap 'kill -TERM $PID' TERM INT
|
|
echo "Starting Tailscale daemon"
|
|
tailscaled --tun=userspace-networking --statedir="${TS_STATE_DIR}" ${TS_TAILSCALED_EXTRA_ARGS} &
|
|
PID=$!
|
|
until tailscale up --authkey="${TS_AUTHKEY}" --hostname="${TS_HOSTNAME}"; do
|
|
sleep 0.1
|
|
done
|
|
tailscale status
|
|
if [ -n "${TS_SERVE_PORT}" ]; then
|
|
if [ -n "${TS_FUNNEL}" ]; then
|
|
if ! tailscale funnel status | grep -q -A1 '(Funnel on)' | grep -q "${TS_SERVE_PORT}"; then
|
|
tailscale funnel --bg "${TS_SERVE_PORT}"
|
|
fi
|
|
else
|
|
if ! tailscale serve status | grep -q "${TS_SERVE_PORT}"; then
|
|
tailscale serve --bg "${TS_SERVE_PORT}"
|
|
fi
|
|
fi
|
|
fi
|
|
wait ${PID}
|