2022-09-01 18:51:23 +00:00
|
|
|
#!/bin/ash
|
|
|
|
trap 'kill -TERM $PID' TERM INT
|
|
|
|
echo "Starting Tailscale daemon"
|
2023-12-30 03:36:35 +00:00
|
|
|
tailscaled --tun=userspace-networking --statedir="${TS_STATE_DIR}" ${TS_TAILSCALED_EXTRA_ARGS} &
|
2022-09-01 18:51:23 +00:00
|
|
|
PID=$!
|
2023-12-29 04:20:00 +00:00
|
|
|
until tailscale up --authkey="${TS_AUTHKEY}" --hostname="${TS_HOSTNAME}"; do
|
2023-12-28 19:25:49 +00:00
|
|
|
sleep 0.1
|
2022-09-01 18:51:23 +00:00
|
|
|
done
|
|
|
|
tailscale status
|
2023-12-28 19:26:24 +00:00
|
|
|
if [ -n "${TS_SERVE_PORT}" ]; then
|
2023-12-29 19:43:50 +00:00
|
|
|
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
|
2023-12-29 15:48:11 +00:00
|
|
|
fi
|
|
|
|
fi
|
2022-09-01 18:51:23 +00:00
|
|
|
wait ${PID}
|